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 21, 2024
1 parent 036f6bc commit 4d812e9
Showing 1 changed file with 19 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
import org.opensearch.test.OpenSearchIntegTestCase.Scope;

import java.io.IOException;
import java.util.function.Supplier;

import static org.opensearch.test.NodeRoles.clusterManagerNode;
import static org.opensearch.test.NodeRoles.dataOnlyNode;
Expand Down Expand Up @@ -255,19 +256,24 @@ public void testElectOnlyBetweenClusterManagerNodes() throws Exception {
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(
internalCluster().nonClusterManagerClient()
.admin()
.cluster()
.prepareState()
.execute()
.actionGet()
.getState()
.nodes()
.getClusterManagerNode()
.getName(),
equalTo(nextClusterManagerEligableNodeName)
);
Supplier<String> clusterManagerName = () -> {
try {
return internalCluster().nonClusterManagerClient()
.admin()
.cluster()
.prepareState()
.execute()
.actionGet()
.getState()
.nodes()
.getClusterManagerNode()
.getName();
} catch (Exception e) {
logger.debug("failed to get cluster-manager name", e);
return null;
}
};
assertThat(clusterManagerName.get(), equalTo(nextClusterManagerEligableNodeName));
assertThat(
internalCluster().clusterManagerClient()
.admin()
Expand Down

0 comments on commit 4d812e9

Please sign in to comment.