Skip to content

Commit

Permalink
Fix for flaky test SimpleBlocksIT.testAddBlockWhileDeletingIndices (#…
Browse files Browse the repository at this point in the history
…11492)

Signed-off-by: Ankit Kala <ankikala@amazon.com>
(cherry picked from commit a3c7952)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
github-actions[bot] committed Dec 6, 2023
1 parent 11bbc63 commit 625353d
Showing 1 changed file with 15 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
import org.opensearch.cluster.block.ClusterBlockLevel;
import org.opensearch.cluster.metadata.IndexMetadata;
import org.opensearch.cluster.metadata.IndexMetadata.APIBlock;
import org.opensearch.cluster.metadata.ProcessClusterEventTimeoutException;
import org.opensearch.cluster.routing.ShardRouting;
import org.opensearch.common.settings.Settings;
import org.opensearch.index.IndexNotFoundException;
Expand Down Expand Up @@ -491,10 +492,20 @@ public void testAddBlockWhileDeletingIndices() throws Exception {
} catch (InterruptedException e) {
throw new AssertionError(e);
}
try {
assertAcked(client().admin().indices().prepareDelete(indexToDelete));
} catch (final Exception e) {
exceptionConsumer.accept(e);
int pendingRetries = 3;
boolean success = false;
while (success == false && pendingRetries-- > 0) {
try {
assertAcked(client().admin().indices().prepareDelete(indexToDelete));
success = true;
} catch (final Exception e) {
Throwable cause = ExceptionsHelper.unwrapCause(e);
if (cause instanceof ProcessClusterEventTimeoutException && pendingRetries > 0) {
// ignore error & retry
continue;
}
exceptionConsumer.accept(e);
}
}
}));
}
Expand Down

0 comments on commit 625353d

Please sign in to comment.