Skip to content

Commit e2ec28d

Browse files
authored
[Test] Wait for clsuter to form before assertions (#130973)
The original cluster should be properly formed before the tests kick off. This PR ensures that. Relates: #129118 Resolves: #130883 Resolves: #130979
1 parent 167a943 commit e2ec28d

File tree

2 files changed

+13
-20
lines changed

2 files changed

+13
-20
lines changed

muted-tests.yml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -564,15 +564,9 @@ tests:
564564
- class: org.elasticsearch.cluster.ClusterStateSerializationTests
565565
method: testSerializationPreMultiProject
566566
issue: https://github.com/elastic/elasticsearch/issues/130872
567-
- class: org.elasticsearch.cluster.coordination.votingonly.VotingOnlyNodePluginTests
568-
method: testPreferFullMasterOverVotingOnlyNodes
569-
issue: https://github.com/elastic/elasticsearch/issues/130883
570567
- class: org.elasticsearch.search.SearchWithRejectionsIT
571568
method: testOpenContextsAfterRejections
572569
issue: https://github.com/elastic/elasticsearch/issues/130821
573-
- class: org.elasticsearch.cluster.coordination.votingonly.VotingOnlyNodePluginTests
574-
method: testVotingOnlyNodesCannotBeMasterWithoutFullMasterNodes
575-
issue: https://github.com/elastic/elasticsearch/issues/130979
576570
- class: org.elasticsearch.packaging.test.DockerTests
577571
method: test082CannotUseEnvVarsAndFiles
578572
issue: https://github.com/elastic/elasticsearch/issues/129808

x-pack/plugin/voting-only-node/src/internalClusterTest/java/org/elasticsearch/cluster/coordination/votingonly/VotingOnlyNodePluginTests.java

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -96,12 +96,12 @@ public void testPreferFullMasterOverVotingOnlyNodes() throws Exception {
9696
internalCluster().setBootstrapMasterNodeIndex(0);
9797
internalCluster().startNodes(2);
9898
internalCluster().startNode(addRoles(Set.of(DiscoveryNodeRole.VOTING_ONLY_NODE_ROLE)));
99-
internalCluster().startDataOnlyNodes(randomInt(2));
100-
assertBusy(
101-
() -> assertThat(
102-
clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState().getLastCommittedConfiguration().getNodeIds().size(),
103-
equalTo(3)
104-
)
99+
final int numDataNodes = randomInt(2);
100+
internalCluster().startDataOnlyNodes(numDataNodes);
101+
internalCluster().validateClusterFormed();
102+
103+
awaitClusterState(
104+
state -> state.getLastCommittedConfiguration().getNodeIds().size() == 3 && state.nodes().size() == 3 + numDataNodes
105105
);
106106
final String originalMaster = internalCluster().getMasterName();
107107

@@ -157,15 +157,14 @@ public void testVotingOnlyNodesCannotBeMasterWithoutFullMasterNodes() throws Exc
157157
internalCluster().setBootstrapMasterNodeIndex(0);
158158
internalCluster().startNode();
159159
internalCluster().startNodes(2, addRoles(Set.of(DiscoveryNodeRole.VOTING_ONLY_NODE_ROLE)));
160-
internalCluster().startDataOnlyNodes(randomInt(2));
161-
assertBusy(
162-
() -> assertThat(
163-
clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState().getLastCommittedConfiguration().getNodeIds().size(),
164-
equalTo(3)
165-
)
160+
final int numDataNodes = randomInt(2);
161+
internalCluster().startDataOnlyNodes(numDataNodes);
162+
internalCluster().validateClusterFormed();
163+
164+
awaitClusterState(
165+
state -> state.getLastCommittedConfiguration().getNodeIds().size() == 3 && state.nodes().size() == 3 + numDataNodes
166166
);
167-
awaitMasterNode();
168-
final String oldMasterId = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState().nodes().getMasterNodeId();
167+
final String oldMasterId = internalCluster().getMasterName();
169168

170169
internalCluster().stopCurrentMasterNode();
171170
awaitMasterNotFound();

0 commit comments

Comments
 (0)