-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Use file-based discovery not MockUncasedHostsProvider #33554
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
DaveCTurner
merged 11 commits into
elastic:master
from
DaveCTurner:2018-09-09-unmock-host-provider
Sep 13, 2018
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
57a24ad
Use file-based discovery not MockUncasedHostsProvider
DaveCTurner 721a179
Imports
DaveCTurner ca8407a
Merge branch 'master' into 2018-09-09-unmock-host-provider
DaveCTurner 924768f
Configure file-based discovery in security test
DaveCTurner 4adf965
Use LifecycleListener rather than onTransportServiceStarted
DaveCTurner 82a5329
Whitespace
DaveCTurner edf1feb
Just pass the settings directly to the nodes as they are started
DaveCTurner 13b6046
TODO resolved (no we don't)
DaveCTurner 2947a7a
No need for a file here
DaveCTurner 31c1d7d
Rebuild the discovery file as each transport service restarts
DaveCTurner 24a91aa
Move field
DaveCTurner File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 81 additions & 0 deletions
81
server/src/test/java/org/elasticsearch/discovery/zen/SettingsBasedHostProviderIT.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| /* | ||
| * Licensed to Elasticsearch under one or more contributor | ||
| * license agreements. See the NOTICE file distributed with | ||
| * this work for additional information regarding copyright | ||
| * ownership. Elasticsearch licenses this file to you under | ||
| * the Apache License, Version 2.0 (the "License"); you may | ||
| * not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, | ||
| * software distributed under the License is distributed on an | ||
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| * KIND, either express or implied. See the License for the | ||
| * specific language governing permissions and limitations | ||
| * under the License. | ||
| */ | ||
|
|
||
| package org.elasticsearch.discovery.zen; | ||
|
|
||
| import org.elasticsearch.action.admin.cluster.node.info.NodesInfoRequest; | ||
| import org.elasticsearch.action.admin.cluster.node.info.NodesInfoResponse; | ||
| import org.elasticsearch.common.settings.Settings; | ||
| import org.elasticsearch.test.ESIntegTestCase; | ||
|
|
||
| import static org.elasticsearch.discovery.DiscoveryModule.DISCOVERY_HOSTS_PROVIDER_SETTING; | ||
| import static org.elasticsearch.discovery.zen.SettingsBasedHostsProvider.DISCOVERY_ZEN_PING_UNICAST_HOSTS_SETTING; | ||
| import static org.elasticsearch.discovery.zen.SettingsBasedHostsProvider.LIMIT_LOCAL_PORTS_COUNT; | ||
| import static org.elasticsearch.transport.TcpTransport.PORT; | ||
|
|
||
| @ESIntegTestCase.ClusterScope(scope = ESIntegTestCase.Scope.TEST, numDataNodes = 0, numClientNodes = 0) | ||
| public class SettingsBasedHostProviderIT extends ESIntegTestCase { | ||
|
|
||
| @Override | ||
| protected Settings nodeSettings(int nodeOrdinal) { | ||
| Settings.Builder builder = Settings.builder().put(super.nodeSettings(nodeOrdinal)); | ||
|
|
||
| // super.nodeSettings enables file-based discovery, but here we disable it again so we can test the static list: | ||
| if (randomBoolean()) { | ||
| builder.putList(DISCOVERY_HOSTS_PROVIDER_SETTING.getKey()); | ||
| } else { | ||
| builder.remove(DISCOVERY_HOSTS_PROVIDER_SETTING.getKey()); | ||
| } | ||
|
|
||
| // super.nodeSettings sets this to an empty list, which disables any search for other nodes, but here we want this to happen: | ||
| builder.remove(DISCOVERY_ZEN_PING_UNICAST_HOSTS_SETTING.getKey()); | ||
|
|
||
| return builder.build(); | ||
| } | ||
|
|
||
| public void testClusterFormsWithSingleSeedHostInSettings() { | ||
| final String seedNodeName = internalCluster().startNode(); | ||
| final NodesInfoResponse nodesInfoResponse | ||
| = client(seedNodeName).admin().cluster().nodesInfo(new NodesInfoRequest("_local")).actionGet(); | ||
| final String seedNodeAddress = nodesInfoResponse.getNodes().get(0).getTransport().getAddress().publishAddress().toString(); | ||
| logger.info("--> using seed node address {}", seedNodeAddress); | ||
|
|
||
| int extraNodes = randomIntBetween(1, 5); | ||
| internalCluster().startNodes(extraNodes, | ||
| Settings.builder().putList(DISCOVERY_ZEN_PING_UNICAST_HOSTS_SETTING.getKey(), seedNodeAddress).build()); | ||
|
|
||
| ensureStableCluster(extraNodes + 1); | ||
| } | ||
|
|
||
| public void testClusterFormsByScanningPorts() { | ||
| // This test will fail if all 4 ports just less than the one used by the first node are already bound by something else. It's hard | ||
| // to know how often this might happen in reality, so let's try it and see. | ||
|
|
||
| final String seedNodeName = internalCluster().startNode(); | ||
| final NodesInfoResponse nodesInfoResponse | ||
| = client(seedNodeName).admin().cluster().nodesInfo(new NodesInfoRequest("_local")).actionGet(); | ||
| final int seedNodePort = nodesInfoResponse.getNodes().get(0).getTransport().getAddress().publishAddress().getPort(); | ||
| final int minPort = randomIntBetween(seedNodePort - LIMIT_LOCAL_PORTS_COUNT + 1, seedNodePort - 1); | ||
| final String portSpec = minPort + "-" + seedNodePort; | ||
|
|
||
| logger.info("--> using port specification [{}]", portSpec); | ||
| internalCluster().startNode(Settings.builder().put(PORT.getKey(), portSpec)); | ||
| ensureStableCluster(2); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we were effectively testing the settings-based host provider via all the other integ tests, but not after this change, I thought it prudent to add this.