Skip to content

Commit de68cb0

Browse files
Fix NullPointerExceptions failing TransportClusterStateActionDisruptionIT (#127523)
Replaces the use of InternalTestCluster.getMasterName() with a ClusterServiceUtils.addTemporaryStateListener() call that waits for a new master node other than the previous master node. InternalTestCluster.getMasterName() is not safe to use in unstable clusters, per PR 127213. Closes #127466 Closes #127443 Closes #127424 Closes #127423 Closes #127422
1 parent ba95390 commit de68cb0

File tree

2 files changed

+7
-16
lines changed

2 files changed

+7
-16
lines changed

muted-tests.yml

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -429,18 +429,9 @@ tests:
429429
- class: org.elasticsearch.xpack.esql.heap_attack.HeapAttackIT
430430
method: testLookupExplosionNoFetch
431431
issue: https://github.com/elastic/elasticsearch/issues/127365
432-
- class: org.elasticsearch.action.admin.cluster.state.TransportClusterStateActionDisruptionIT
433-
method: testNonLocalRequestAlwaysFindsMasterAndWaitsForMetadata
434-
issue: https://github.com/elastic/elasticsearch/issues/127422
435432
- class: org.elasticsearch.xpack.esql.qa.single_node.PushQueriesIT
436433
method: testPushCaseInsensitiveEqualityOnDefaults
437434
issue: https://github.com/elastic/elasticsearch/issues/127431
438-
- class: org.elasticsearch.action.admin.cluster.state.TransportClusterStateActionDisruptionIT
439-
method: testLocalRequestAlwaysSucceeds
440-
issue: https://github.com/elastic/elasticsearch/issues/127423
441-
- class: org.elasticsearch.action.admin.cluster.state.TransportClusterStateActionDisruptionIT
442-
method: testLocalRequestWaitsForMetadata
443-
issue: https://github.com/elastic/elasticsearch/issues/127466
444435
- class: org.elasticsearch.xpack.esql.qa.single_node.GenerativeIT
445436
method: test
446437
issue: https://github.com/elastic/elasticsearch/issues/127536

server/src/internalClusterTest/java/org/elasticsearch/action/admin/cluster/state/TransportClusterStateActionDisruptionIT.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,16 @@
2828
import java.util.Collection;
2929
import java.util.Collections;
3030
import java.util.List;
31+
import java.util.Optional;
3132
import java.util.concurrent.atomic.AtomicBoolean;
3233
import java.util.stream.Collectors;
3334
import java.util.stream.StreamSupport;
3435

3536
import static org.elasticsearch.cluster.routing.allocation.decider.EnableAllocationDecider.CLUSTER_ROUTING_REBALANCE_ENABLE_SETTING;
3637
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
37-
import static org.hamcrest.Matchers.equalTo;
3838
import static org.hamcrest.Matchers.greaterThanOrEqualTo;
3939
import static org.hamcrest.Matchers.hasSize;
4040
import static org.hamcrest.Matchers.instanceOf;
41-
import static org.hamcrest.Matchers.not;
4241

4342
@ESIntegTestCase.ClusterScope(numDataNodes = 0, scope = ESIntegTestCase.Scope.TEST)
4443
public class TransportClusterStateActionDisruptionIT extends ESIntegTestCase {
@@ -212,11 +211,12 @@ public void runRepeatedlyWhileChangingMaster(Runnable runnable) throws Exception
212211
}
213212
}
214213

215-
assertBusy(() -> {
216-
final String nonMasterNode = randomValueOtherThan(masterName, () -> randomFrom(internalCluster().getNodeNames()));
217-
final String claimedMasterName = internalCluster().getMasterName(nonMasterNode);
218-
assertThat(claimedMasterName, not(equalTo(masterName)));
219-
});
214+
final String nonMasterNode = randomValueOtherThan(masterName, () -> randomFrom(internalCluster().getNodeNames()));
215+
awaitClusterState(
216+
logger,
217+
nonMasterNode,
218+
state -> Optional.ofNullable(state.nodes().getMasterNode()).map(m -> m.getName().equals(masterName) == false).orElse(false)
219+
);
220220

221221
shutdown.set(true);
222222
assertingThread.join();

0 commit comments

Comments
 (0)