Skip to content

Commit

Permalink
Test: use assertBusy to fix timing issue
Browse files Browse the repository at this point in the history
  • Loading branch information
martijnvg committed Mar 2, 2015
1 parent 358fd17 commit 2b00ecb
Showing 1 changed file with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -598,7 +598,7 @@ public void testStaleMasterNotHijackingMajority() throws Exception {
// TODO: on mac OS multicast threads are shared between nodes and we therefore we can't simulate GC and stop pinging for just one node
// find a way to block thread creation in the generic thread pool to avoid this.
// 3 node cluster with unicast discovery and minimum_master_nodes set to 2:
List<String> nodes = startUnicastCluster(3, null, 2);
final List<String> nodes = startUnicastCluster(3, null, 2);

// Save the current master node as old master node, because that node will get frozen
final String oldMasterNode = internalCluster().getMasterName();
Expand Down Expand Up @@ -666,7 +666,15 @@ public void onFailure(String source, Throwable t) {

// Make sure that the end state is consistent on all nodes:
assertDiscoveryCompleted(nodes);
assertMaster(newMasterNode, nodes);
// Use assertBusy(...) because the unfrozen node may take a while to actually join the cluster.
// The assertDiscoveryCompleted(...) can't know if the joining has finished or still needs to begin.
// (the discovery only kicks in when unfrozen node steps down, which isn't immediately)
assertBusy(new Runnable() {
@Override
public void run() {
assertMaster(newMasterNode, nodes);
}
});


assertThat(masters.size(), equalTo(2));
Expand Down

0 comments on commit 2b00ecb

Please sign in to comment.