|
28 | 28 | import java.util.Collection; |
29 | 29 | import java.util.Collections; |
30 | 30 | import java.util.List; |
| 31 | +import java.util.Optional; |
31 | 32 | import java.util.concurrent.atomic.AtomicBoolean; |
32 | 33 | import java.util.stream.Collectors; |
33 | 34 | import java.util.stream.StreamSupport; |
34 | 35 |
|
35 | 36 | import static org.elasticsearch.cluster.routing.allocation.decider.EnableAllocationDecider.CLUSTER_ROUTING_REBALANCE_ENABLE_SETTING; |
36 | 37 | import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked; |
37 | | -import static org.hamcrest.Matchers.equalTo; |
38 | 38 | import static org.hamcrest.Matchers.greaterThanOrEqualTo; |
39 | 39 | import static org.hamcrest.Matchers.hasSize; |
40 | 40 | import static org.hamcrest.Matchers.instanceOf; |
41 | | -import static org.hamcrest.Matchers.not; |
42 | 41 |
|
43 | 42 | @ESIntegTestCase.ClusterScope(numDataNodes = 0, scope = ESIntegTestCase.Scope.TEST) |
44 | 43 | public class TransportClusterStateActionDisruptionIT extends ESIntegTestCase { |
@@ -212,11 +211,12 @@ public void runRepeatedlyWhileChangingMaster(Runnable runnable) throws Exception |
212 | 211 | } |
213 | 212 | } |
214 | 213 |
|
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 | + ); |
220 | 220 |
|
221 | 221 | shutdown.set(true); |
222 | 222 | assertingThread.join(); |
|
0 commit comments