Skip to content

Commit

Permalink
Fix Flaky Test SpecificClusterManagerNodesIT.testElectOnlyBetweenClus…
Browse files Browse the repository at this point in the history
…terManagerNodes

Signed-off-by: kkewwei <[email protected]>
  • Loading branch information
kkewwei committed Sep 20, 2024
1 parent 9537d39 commit 1b3920b
Showing 1 changed file with 22 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -224,19 +224,6 @@ public void testElectOnlyBetweenClusterManagerNodes() throws Exception {
.getName(),
equalTo(clusterManagerNodeName)
);
assertThat(
internalCluster().nonClusterManagerClient()
.admin()
.cluster()
.prepareState()
.execute()
.actionGet()
.getState()
.nodes()
.getClusterManagerNode()
.getName(),
equalTo(clusterManagerNodeName)
);
assertThat(
internalCluster().clusterManagerClient()
.admin()
Expand All @@ -254,8 +241,10 @@ public void testElectOnlyBetweenClusterManagerNodes() throws Exception {
logger.info("--> closing cluster-manager node (1)");
client().execute(AddVotingConfigExclusionsAction.INSTANCE, new AddVotingConfigExclusionsRequest(clusterManagerNodeName)).get();
// removing the cluster-manager from the voting configuration immediately triggers the cluster-manager to step down
assertBusy(() -> {
assertThat(

// make sure `nextClusterManagerEligableNodeName` has been elected as the new cluster-manager
waitUntil(
() -> nextClusterManagerEligableNodeName.equals(
internalCluster().nonClusterManagerClient()
.admin()
.cluster()
Expand All @@ -265,23 +254,24 @@ public void testElectOnlyBetweenClusterManagerNodes() throws Exception {
.getState()
.nodes()
.getClusterManagerNode()
.getName(),
equalTo(nextClusterManagerEligableNodeName)
);
assertThat(
internalCluster().clusterManagerClient()
.admin()
.cluster()
.prepareState()
.execute()
.actionGet()
.getState()
.nodes()
.getClusterManagerNode()
.getName(),
equalTo(nextClusterManagerEligableNodeName)
);
});
.getName()
)
);

assertThat(
internalCluster().clusterManagerClient()
.admin()
.cluster()
.prepareState()
.execute()
.actionGet()
.getState()
.nodes()
.getClusterManagerNode()
.getName(),
equalTo(nextClusterManagerEligableNodeName)
);

internalCluster().stopRandomNode(InternalTestCluster.nameFilter(clusterManagerNodeName));
assertThat(
internalCluster().nonClusterManagerClient()
Expand Down

0 comments on commit 1b3920b

Please sign in to comment.