From 4a7ffc89855880636d2a1f0f9d0c400844bd5312 Mon Sep 17 00:00:00 2001 From: Andrew Ross Date: Wed, 30 Apr 2025 13:20:31 -0700 Subject: [PATCH] Fail fast if initial delete call fails in CreateIndexIT Previously if the delete call failed then the test would block indefinitely on the latch as nothing would count it down. The test would then hit the overall timeout and report thread leak failures. This change captures the exception and fails immediately in the test thread if the delete call fails. Signed-off-by: Andrew Ross --- .../action/admin/indices/create/CreateIndexIT.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/server/src/internalClusterTest/java/org/opensearch/action/admin/indices/create/CreateIndexIT.java b/server/src/internalClusterTest/java/org/opensearch/action/admin/indices/create/CreateIndexIT.java index b41b3f07d3ac1..62e417014eb86 100644 --- a/server/src/internalClusterTest/java/org/opensearch/action/admin/indices/create/CreateIndexIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/action/admin/indices/create/CreateIndexIT.java @@ -73,6 +73,7 @@ import java.util.UUID; import java.util.concurrent.CountDownLatch; import java.util.concurrent.atomic.AtomicInteger; +import java.util.concurrent.atomic.AtomicReference; import java.util.function.BiFunction; import static org.opensearch.cluster.metadata.IndexMetadata.SETTING_WAIT_FOR_ACTIVE_SHARDS; @@ -257,6 +258,7 @@ public void testCreateAndDeleteIndexConcurrently() throws InterruptedException { synchronized (indexVersionLock) { // not necessarily needed here but for completeness we lock here too indexVersion.incrementAndGet(); } + final AtomicReference deleteFailure = new AtomicReference<>(); client().admin().indices().prepareDelete("test").execute(new ActionListener() { // this happens async!!! @Override public void onResponse(AcknowledgedResponse deleteIndexResponse) { @@ -284,7 +286,8 @@ public void run() { @Override public void onFailure(Exception e) { - throw new RuntimeException(e); + deleteFailure.set(e); + latch.countDown(); } }); numDocs = randomIntBetween(100, 200); @@ -304,6 +307,7 @@ public void onFailure(Exception e) { } } latch.await(); + assertNull(deleteFailure.get()); refresh(); // we only really assert that we never reuse segments of old indices or anything like this here and that nothing fails with