Skip to content

Commit 221bbc2

Browse files
Fix DiscoveryDisruptionIT.testElectMasterWithLatestVersion
The clusterAdmin() call at the end of the test uses a random node, which may not have been part of the current election, and may still have an old cluster state, prior to the creation of the index in the test. The fix uses awaitClusterState() to wait for a non-null master and saves the state to check for the test index. Resolves: #134748
1 parent 8a10ffa commit 221bbc2

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

muted-tests.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -516,9 +516,6 @@ tests:
516516
- class: org.elasticsearch.xpack.esql.expression.function.scalar.score.DecayTests
517517
method: "testEvaluateBlockWithNulls {TestCase=<integer>, <integer>, <integer>, <_source> #2}"
518518
issue: https://github.com/elastic/elasticsearch/issues/134679
519-
- class: org.elasticsearch.discovery.DiscoveryDisruptionIT
520-
method: testElectMasterWithLatestVersion
521-
issue: https://github.com/elastic/elasticsearch/issues/134748
522519
- class: org.elasticsearch.xpack.esql.ccq.MultiClusterSpecIT
523520
method: test {csv-spec:fork.ForkBeforeStatsByWithWhere}
524521
issue: https://github.com/elastic/elasticsearch/issues/134817

server/src/internalClusterTest/java/org/elasticsearch/discovery/DiscoveryDisruptionIT.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import java.util.Set;
3131
import java.util.concurrent.CountDownLatch;
3232
import java.util.concurrent.CyclicBarrier;
33+
import java.util.concurrent.atomic.AtomicReference;
3334

3435
/**
3536
* Tests for discovery during disruptions.
@@ -146,8 +147,14 @@ public void testElectMasterWithLatestVersion() throws Exception {
146147

147148
isolateAllNodes.stopDisrupting();
148149

149-
awaitMasterNode();
150-
final ClusterState state = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState();
150+
final var stateRef = new AtomicReference<ClusterState>();
151+
awaitClusterState(state -> {
152+
stateRef.set(state);
153+
return state.nodes().getMasterNode() != null;
154+
});
155+
156+
final var state = stateRef.get();
157+
assertNotNull(state);
151158
if (state.metadata().getProject().hasIndex("test") == false) {
152159
fail("index 'test' was lost. current cluster state: " + state);
153160
}

0 commit comments

Comments
 (0)