Skip to content

Commit 84f6088

Browse files
authored
Fail fast if initial delete call fails in CreateIndexIT (#18169)
1 parent 2cde121 commit 84f6088

File tree

1 file changed

+5
-1
lines changed
  • server/src/internalClusterTest/java/org/opensearch/action/admin/indices/create

1 file changed

+5
-1
lines changed

server/src/internalClusterTest/java/org/opensearch/action/admin/indices/create/CreateIndexIT.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@
7373
import java.util.UUID;
7474
import java.util.concurrent.CountDownLatch;
7575
import java.util.concurrent.atomic.AtomicInteger;
76+
import java.util.concurrent.atomic.AtomicReference;
7677
import java.util.function.BiFunction;
7778

7879
import static org.opensearch.cluster.metadata.IndexMetadata.SETTING_WAIT_FOR_ACTIVE_SHARDS;
@@ -257,6 +258,7 @@ public void testCreateAndDeleteIndexConcurrently() throws InterruptedException {
257258
synchronized (indexVersionLock) { // not necessarily needed here but for completeness we lock here too
258259
indexVersion.incrementAndGet();
259260
}
261+
final AtomicReference<Exception> deleteFailure = new AtomicReference<>();
260262
client().admin().indices().prepareDelete("test").execute(new ActionListener<AcknowledgedResponse>() { // this happens async!!!
261263
@Override
262264
public void onResponse(AcknowledgedResponse deleteIndexResponse) {
@@ -284,7 +286,8 @@ public void run() {
284286

285287
@Override
286288
public void onFailure(Exception e) {
287-
throw new RuntimeException(e);
289+
deleteFailure.set(e);
290+
latch.countDown();
288291
}
289292
});
290293
numDocs = randomIntBetween(100, 200);
@@ -304,6 +307,7 @@ public void onFailure(Exception e) {
304307
}
305308
}
306309
latch.await();
310+
assertNull(deleteFailure.get());
307311
refresh();
308312

309313
// we only really assert that we never reuse segments of old indices or anything like this here and that nothing fails with

0 commit comments

Comments
 (0)