[TEST] Use assertBusy to check assertMaster property in presence of a low publish timeout
The assertion assertMaster checks if all nodes have each other in the cluster state and the correct master set. It is usually called after a disruption has been healed and ensureStableCluster been called. In presence of a low publish timeout of 1s in this test class, publishing might not be fully done even after ensureStableCluster returns. This commit adds an assertBusy to assertMaster so that the node has a bit more time to apply the cluster state from the master, even if it's a bit slow.
This commit is contained in:
parent
e7cfe101e4
commit
37228f924a
|
@ -761,15 +761,7 @@ public class DiscoveryWithServiceDisruptionsIT extends ESIntegTestCase {
|
||||||
oldMasterNodeSteppedDown.await(30, TimeUnit.SECONDS);
|
oldMasterNodeSteppedDown.await(30, TimeUnit.SECONDS);
|
||||||
// Make sure that the end state is consistent on all nodes:
|
// Make sure that the end state is consistent on all nodes:
|
||||||
assertDiscoveryCompleted(nodes);
|
assertDiscoveryCompleted(nodes);
|
||||||
// Use assertBusy(...) because the unfrozen node may take a while to actually join the cluster.
|
|
||||||
// The assertDiscoveryCompleted(...) can't know if all nodes have the old master node in all of the local cluster states
|
|
||||||
assertBusy(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
assertMaster(newMasterNode, nodes);
|
assertMaster(newMasterNode, nodes);
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
assertThat(masters.size(), equalTo(2));
|
assertThat(masters.size(), equalTo(2));
|
||||||
for (Map.Entry<String, List<Tuple<String, String>>> entry : masters.entrySet()) {
|
for (Map.Entry<String, List<Tuple<String, String>>> entry : masters.entrySet()) {
|
||||||
|
@ -1366,7 +1358,8 @@ public class DiscoveryWithServiceDisruptionsIT extends ESIntegTestCase {
|
||||||
}, 10, TimeUnit.SECONDS);
|
}, 10, TimeUnit.SECONDS);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void assertMaster(String masterNode, List<String> nodes) {
|
private void assertMaster(String masterNode, List<String> nodes) throws Exception {
|
||||||
|
assertBusy(() -> {
|
||||||
for (String node : nodes) {
|
for (String node : nodes) {
|
||||||
ClusterState state = getNodeClusterState(node);
|
ClusterState state = getNodeClusterState(node);
|
||||||
String failMsgSuffix = "cluster_state:\n" + state.prettyPrint();
|
String failMsgSuffix = "cluster_state:\n" + state.prettyPrint();
|
||||||
|
@ -1374,6 +1367,7 @@ public class DiscoveryWithServiceDisruptionsIT extends ESIntegTestCase {
|
||||||
String otherMasterNodeName = state.nodes().getMasterNode() != null ? state.nodes().getMasterNode().getName() : null;
|
String otherMasterNodeName = state.nodes().getMasterNode() != null ? state.nodes().getMasterNode().getName() : null;
|
||||||
assertThat("wrong master on node [" + node + "]. " + failMsgSuffix, otherMasterNodeName, equalTo(masterNode));
|
assertThat("wrong master on node [" + node + "]. " + failMsgSuffix, otherMasterNodeName, equalTo(masterNode));
|
||||||
}
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void assertDiscoveryCompleted(List<String> nodes) throws InterruptedException {
|
private void assertDiscoveryCompleted(List<String> nodes) throws InterruptedException {
|
||||||
|
|
Loading…
Reference in New Issue