Skip to content

Commit 042f6d8

Browse files
authored
Ensure correct no-master block applied on restart (#54800)
This commit addresses a long-standing `// TODO` in the coordinator tests to ensure that the correct no-master block is applied when a node restarts while disconnected from the cluster. It also strengthens this test to check that the no-master block is applied correctly on all nodes, not just the previous master.
1 parent a92c1dd commit 042f6d8

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

server/src/test/java/org/elasticsearch/cluster/coordination/CoordinatorTests.java

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -920,13 +920,23 @@ private void testAppliesNoMasterBlock(String noMasterBlockSetting, ClusterBlock
920920
}, (source, e) -> {});
921921
cluster.runFor(DEFAULT_CLUSTER_STATE_UPDATE_DELAY, "committing setting update");
922922

923-
leader.disconnect();
924-
cluster.runFor(defaultMillis(FOLLOWER_CHECK_TIMEOUT_SETTING) + defaultMillis(FOLLOWER_CHECK_INTERVAL_SETTING)
923+
final ClusterNode removedNode = cluster.getAnyNode();
924+
925+
removedNode.disconnect();
926+
cluster.runFor(
927+
Math.max(defaultMillis(FOLLOWER_CHECK_TIMEOUT_SETTING) + defaultMillis(FOLLOWER_CHECK_INTERVAL_SETTING),
928+
defaultMillis(LEADER_CHECK_TIMEOUT_SETTING) + defaultMillis(LEADER_CHECK_INTERVAL_SETTING))
925929
+ DEFAULT_CLUSTER_STATE_UPDATE_DELAY, "detecting disconnection");
926930

927-
assertThat(leader.getLastAppliedClusterState().blocks().global(), hasItem(expectedBlock));
931+
assertThat(removedNode.getLastAppliedClusterState().blocks().global(), hasItem(expectedBlock));
928932

929-
// TODO reboot the leader and verify that the same block is applied when it restarts
933+
removedNode.close();
934+
final ClusterNode restartedNode = removedNode.restartedNode();
935+
cluster.clusterNodes.replaceAll(cn -> cn == removedNode ? restartedNode : cn);
936+
restartedNode.disconnect();
937+
938+
cluster.stabilise();
939+
assertThat(restartedNode.getLastAppliedClusterState().blocks().global(), hasItem(expectedBlock));
930940
}
931941
}
932942

0 commit comments

Comments
 (0)