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>
  • Loading branch information
ankitkala authored Dec 6, 2023
1 parent c204585 commit a3c7952
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 a3c7952

Please sign in to comment.