-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Disc: Move AbstractDisruptionTC to filebased D. #34461
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
Changes from all commits
d7ef985
427b7c3
72f34e5
199c41e
8fe964d
7b4072d
7f9b849
5503164
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -19,6 +19,7 @@ | |||||||
|
|
||||||||
| package org.elasticsearch.discovery; | ||||||||
|
|
||||||||
| import java.nio.file.Path; | ||||||||
| import org.elasticsearch.cluster.ClusterState; | ||||||||
| import org.elasticsearch.cluster.block.ClusterBlock; | ||||||||
| import org.elasticsearch.cluster.block.ClusterBlockLevel; | ||||||||
|
|
@@ -33,7 +34,8 @@ | |||||||
| import org.elasticsearch.env.NodeEnvironment; | ||||||||
| import org.elasticsearch.plugins.Plugin; | ||||||||
| import org.elasticsearch.test.ESIntegTestCase; | ||||||||
| import org.elasticsearch.test.discovery.ClusterDiscoveryConfiguration; | ||||||||
| import org.elasticsearch.test.InternalTestCluster; | ||||||||
| import org.elasticsearch.test.NodeConfigurationSource; | ||||||||
| import org.elasticsearch.test.discovery.TestZenDiscovery; | ||||||||
| import org.elasticsearch.test.disruption.NetworkDisruption; | ||||||||
| import org.elasticsearch.test.disruption.NetworkDisruption.Bridge; | ||||||||
|
|
@@ -52,17 +54,17 @@ | |||||||
| import java.util.HashSet; | ||||||||
| import java.util.List; | ||||||||
| import java.util.Set; | ||||||||
| import java.util.concurrent.ExecutionException; | ||||||||
| import java.util.concurrent.TimeUnit; | ||||||||
|
|
||||||||
| import static org.elasticsearch.discovery.DiscoveryModule.DISCOVERY_HOSTS_PROVIDER_SETTING; | ||||||||
| import static org.hamcrest.Matchers.equalTo; | ||||||||
| import static org.hamcrest.Matchers.not; | ||||||||
|
|
||||||||
| public abstract class AbstractDisruptionTestCase extends ESIntegTestCase { | ||||||||
|
|
||||||||
| static final TimeValue DISRUPTION_HEALING_OVERHEAD = TimeValue.timeValueSeconds(40); // we use 30s as timeout in many places. | ||||||||
|
|
||||||||
| private ClusterDiscoveryConfiguration discoveryConfig; | ||||||||
| private NodeConfigurationSource discoveryConfig; | ||||||||
|
|
||||||||
| @Override | ||||||||
| protected Settings nodeSettings(int nodeOrdinal) { | ||||||||
|
|
@@ -116,18 +118,14 @@ protected void beforeIndexDeletion() throws Exception { | |||||||
| } | ||||||||
| } | ||||||||
|
|
||||||||
| List<String> startCluster(int numberOfNodes) throws ExecutionException, InterruptedException { | ||||||||
| List<String> startCluster(int numberOfNodes) { | ||||||||
| return startCluster(numberOfNodes, -1); | ||||||||
| } | ||||||||
|
|
||||||||
| List<String> startCluster(int numberOfNodes, int minimumMasterNode) throws ExecutionException, InterruptedException { | ||||||||
| return startCluster(numberOfNodes, minimumMasterNode, null); | ||||||||
| } | ||||||||
|
|
||||||||
| List<String> startCluster(int numberOfNodes, int minimumMasterNode, @Nullable int[] unicastHostsOrdinals) throws | ||||||||
| ExecutionException, InterruptedException { | ||||||||
| configureCluster(numberOfNodes, unicastHostsOrdinals, minimumMasterNode); | ||||||||
| List<String> nodes = internalCluster().startNodes(numberOfNodes); | ||||||||
| List<String> startCluster(int numberOfNodes, int minimumMasterNode) { | ||||||||
| configureCluster(numberOfNodes, minimumMasterNode); | ||||||||
| InternalTestCluster internalCluster = internalCluster(); | ||||||||
| List<String> nodes = internalCluster.startNodes(numberOfNodes); | ||||||||
| ensureStableCluster(numberOfNodes); | ||||||||
|
|
||||||||
| // TODO: this is a temporary solution so that nodes will not base their reaction to a partition based on previous successful results | ||||||||
|
|
@@ -154,20 +152,11 @@ protected Collection<Class<? extends Plugin>> nodePlugins() { | |||||||
| return Arrays.asList(MockTransportService.TestPlugin.class); | ||||||||
| } | ||||||||
|
|
||||||||
| void configureCluster( | ||||||||
| int numberOfNodes, | ||||||||
| @Nullable int[] unicastHostsOrdinals, | ||||||||
| int minimumMasterNode | ||||||||
| ) throws ExecutionException, InterruptedException { | ||||||||
| configureCluster(DEFAULT_SETTINGS, numberOfNodes, unicastHostsOrdinals, minimumMasterNode); | ||||||||
| void configureCluster(int numberOfNodes, int minimumMasterNode) { | ||||||||
| configureCluster(DEFAULT_SETTINGS, numberOfNodes, minimumMasterNode); | ||||||||
| } | ||||||||
|
|
||||||||
| void configureCluster( | ||||||||
| Settings settings, | ||||||||
| int numberOfNodes, | ||||||||
| @Nullable int[] unicastHostsOrdinals, | ||||||||
| int minimumMasterNode | ||||||||
| ) throws ExecutionException, InterruptedException { | ||||||||
| void configureCluster(Settings settings, int numberOfNodes, int minimumMasterNode) { | ||||||||
| if (minimumMasterNode < 0) { | ||||||||
| minimumMasterNode = numberOfNodes / 2 + 1; | ||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As far as I can tell, we allow tests to set
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @DaveCTurner Aren't we only ever passing
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry, let me clarify. I do not think this method should receive an explicit elasticsearch/server/src/test/java/org/elasticsearch/discovery/ClusterDisruptionIT.java Line 366 in d7ef985
elasticsearch/server/src/test/java/org/elasticsearch/discovery/SnapshotDisruptionIT.java Line 62 in d7ef985
elasticsearch/server/src/test/java/org/elasticsearch/discovery/DiscoveryDisruptionIT.java Line 141 in 8fe964d
In the first two cases this is actually correct because
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @DaveCTurner given the short exchange in Slack, wanna keep this around for now maybe?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, let's do this in a follow-up. NB the action to take here is to make this a cluster with 1 master node and 1 data node, which'd then mean that we can fall back on |
||||||||
| } | ||||||||
|
|
@@ -177,14 +166,21 @@ void configureCluster( | |||||||
| .put(settings) | ||||||||
| .put(NodeEnvironment.MAX_LOCAL_STORAGE_NODES_SETTING.getKey(), numberOfNodes) | ||||||||
| .put(ElectMasterService.DISCOVERY_ZEN_MINIMUM_MASTER_NODES_SETTING.getKey(), minimumMasterNode) | ||||||||
| .putList(DISCOVERY_HOSTS_PROVIDER_SETTING.getKey(), "file") | ||||||||
| .build(); | ||||||||
|
|
||||||||
| if (discoveryConfig == null) { | ||||||||
| if (unicastHostsOrdinals == null) { | ||||||||
| discoveryConfig = new ClusterDiscoveryConfiguration.UnicastZen(numberOfNodes, nodeSettings); | ||||||||
| } else { | ||||||||
| discoveryConfig = new ClusterDiscoveryConfiguration.UnicastZen(numberOfNodes, nodeSettings, unicastHostsOrdinals); | ||||||||
| } | ||||||||
| discoveryConfig = new NodeConfigurationSource() { | ||||||||
| @Override | ||||||||
| public Settings nodeSettings(final int nodeOrdinal) { | ||||||||
| return nodeSettings; | ||||||||
| } | ||||||||
|
|
||||||||
| @Override | ||||||||
| public Path nodeConfigPath(final int nodeOrdinal) { | ||||||||
| return null; | ||||||||
| } | ||||||||
| }; | ||||||||
| } | ||||||||
| } | ||||||||
|
|
||||||||
|
|
||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -59,7 +59,8 @@ | |
| public class DiscoveryDisruptionIT extends AbstractDisruptionTestCase { | ||
|
|
||
| public void testIsolatedUnicastNodes() throws Exception { | ||
| List<String> nodes = startCluster(4, -1, new int[]{0}); | ||
| internalCluster().setHostsListContainsOnlyFirstNode(true); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this has to happen before you start the cluster, or else the cluster will start with full knowledge.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Right fixing |
||
| List<String> nodes = startCluster(4, -1); | ||
| // Figure out what is the elected master node | ||
| final String unicastTarget = nodes.get(0); | ||
|
|
||
|
|
@@ -98,7 +99,8 @@ public void testIsolatedUnicastNodes() throws Exception { | |
| * The rejoining node should take this master node and connect. | ||
| */ | ||
| public void testUnicastSinglePingResponseContainsMaster() throws Exception { | ||
| List<String> nodes = startCluster(4, -1, new int[]{0}); | ||
| internalCluster().setHostsListContainsOnlyFirstNode(true); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this has to happen before you start the cluster, or else the cluster will start with full knowledge.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Right fixing |
||
| List<String> nodes = startCluster(4, -1); | ||
| // Figure out what is the elected master node | ||
| final String masterNode = internalCluster().getMasterName(); | ||
| logger.info("---> legit elected master node={}", masterNode); | ||
|
|
@@ -194,7 +196,7 @@ public void testClusterJoinDespiteOfPublishingIssues() throws Exception { | |
| } | ||
|
|
||
| public void testClusterFormingWithASlowNode() throws Exception { | ||
| configureCluster(3, null, 2); | ||
| configureCluster(3, 2); | ||
|
|
||
| SlowClusterStateProcessing disruption = new SlowClusterStateProcessing(random(), 0, 0, 1000, 2000); | ||
|
|
||
|
|
@@ -210,7 +212,7 @@ public void testClusterFormingWithASlowNode() throws Exception { | |
| } | ||
|
|
||
| public void testElectMasterWithLatestVersion() throws Exception { | ||
| configureCluster(3, null, 2); | ||
| configureCluster(3, 2); | ||
| final Set<String> nodes = new HashSet<>(internalCluster().startNodes(3)); | ||
| ensureStableCluster(3); | ||
| ServiceDisruptionScheme isolateAllNodes = | ||
|
|
||
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.
I would like to see if it's possible to pass in all the settings by implementing this method directly, rather than using the
NodeConfigurationSourceetc.For instance it looks like these settings could be here:
I also think these aren't needed and we can just make use of the machinery in
ESIntegTestCaseto set them appropriately:We use non-default settings in very few places; moving the affected tests into their own fixtures so they can override
nodeSettingsthemselves seems worth investigating.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.
@DaveCTurner Let me try :) What makes this a little tricky (requiring more changes maybe?) is that we have this code in
org.elasticsearch.discovery.ClusterDisruptionIT#testSearchWithRelocationAndSlowClusterStateProcessingto override these defaults (though this could just be me not being so fluent in this code yet :)). Maybe do this in a follow up PR?
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.
Right, that's one of the tests that I think could be in its own fixture since it needs different cluster settings.
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.
@DaveCTurner wanna handle this here or can we move that to the next PR? (this one is already doing quite a few things)
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.
Sure, a follow-up is ok.