Skip to content

Commit 922892a

Browse files
opensearch-trigger-bot[bot]github-actions[bot]
authored andcommitted
Fix Flaky Test ClusterRerouteIT.testDelayWithALargeAmountOfShards (opensearch-project#14510) (opensearch-project#14540)
Signed-off-by: kkewwei [email protected] Signed-off-by: kkewwei [email protected] (cherry picked from commit badf851) Signed-off-by: kkewwei [email protected] Signed-off-by: kkewwei <[email protected]> Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Signed-off-by: kkewwei <[email protected]>
1 parent 94fd59b commit 922892a

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

server/src/internalClusterTest/java/org/opensearch/cluster/allocation/ClusterRerouteIT.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,8 @@ public void testDelayWithALargeAmountOfShards() throws Exception {
273273
internalCluster().stopRandomNode(InternalTestCluster.nameFilter(node_1));
274274

275275
// This might run slowly on older hardware
276-
ensureGreen(TimeValue.timeValueMinutes(2));
276+
// In some case, the shards will be rebalanced back and forth, it seems like a very low probability bug.
277+
ensureGreen(TimeValue.timeValueMinutes(2), false);
277278
}
278279

279280
private void rerouteWithAllocateLocalGateway(Settings commonSettings) throws Exception {

test/framework/src/main/java/org/opensearch/test/OpenSearchIntegTestCase.java

+15-1
Original file line numberDiff line numberDiff line change
@@ -863,6 +863,10 @@ public ClusterHealthStatus ensureGreen(TimeValue timeout, String... indices) {
863863
return ensureColor(ClusterHealthStatus.GREEN, timeout, false, indices);
864864
}
865865

866+
public ClusterHealthStatus ensureGreen(TimeValue timeout, boolean waitForNoRelocatingShards, String... indices) {
867+
return ensureColor(ClusterHealthStatus.GREEN, timeout, waitForNoRelocatingShards, false, indices);
868+
}
869+
866870
/**
867871
* Ensures the cluster has a yellow state via the cluster health API.
868872
*/
@@ -890,6 +894,16 @@ private ClusterHealthStatus ensureColor(
890894
TimeValue timeout,
891895
boolean waitForNoInitializingShards,
892896
String... indices
897+
) {
898+
return ensureColor(clusterHealthStatus, timeout, true, waitForNoInitializingShards, indices);
899+
}
900+
901+
private ClusterHealthStatus ensureColor(
902+
ClusterHealthStatus clusterHealthStatus,
903+
TimeValue timeout,
904+
boolean waitForNoRelocatingShards,
905+
boolean waitForNoInitializingShards,
906+
String... indices
893907
) {
894908
String color = clusterHealthStatus.name().toLowerCase(Locale.ROOT);
895909
String method = "ensure" + Strings.capitalize(color);
@@ -898,7 +912,7 @@ private ClusterHealthStatus ensureColor(
898912
.timeout(timeout)
899913
.waitForStatus(clusterHealthStatus)
900914
.waitForEvents(Priority.LANGUID)
901-
.waitForNoRelocatingShards(true)
915+
.waitForNoRelocatingShards(waitForNoRelocatingShards)
902916
.waitForNoInitializingShards(waitForNoInitializingShards)
903917
// We currently often use ensureGreen or ensureYellow to check whether the cluster is back in a good state after shutting down
904918
// a node. If the node that is stopped is the cluster-manager node, another node will become cluster-manager and publish a

0 commit comments

Comments
 (0)