From 676fd2cd4e717be61c7db508c68eb85c2fdd6e44 Mon Sep 17 00:00:00 2001 From: Dimitris Rempapis Date: Mon, 28 Apr 2025 10:18:35 +0300 Subject: [PATCH 1/2] Add method specifying the timeout --- .../java/org/elasticsearch/test/ESTestCase.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/test/framework/src/main/java/org/elasticsearch/test/ESTestCase.java b/test/framework/src/main/java/org/elasticsearch/test/ESTestCase.java index bf0d61dbcb148..0e0618b2fae78 100644 --- a/test/framework/src/main/java/org/elasticsearch/test/ESTestCase.java +++ b/test/framework/src/main/java/org/elasticsearch/test/ESTestCase.java @@ -2312,6 +2312,22 @@ public static void safeAwait(CountDownLatch countDownLatch) { } } + /** + * Await on the given {@link CountDownLatch} with a supplied timeout, preserving the thread's interrupt status + * flag and asserting that the latch is indeed completed before the timeout. + */ + public static void safeAwait(CountDownLatch countDownLatch, TimeValue timeout) { + try { + assertTrue( + "safeAwait: CountDownLatch did not reach zero within the timeout", + countDownLatch.await(timeout.millis(), TimeUnit.MILLISECONDS) + ); + } catch (InterruptedException e) { + Thread.currentThread().interrupt(); + fail(e, "safeAwait: interrupted waiting for CountDownLatch to reach zero"); + } + } + /** * Acquire a single permit from the given {@link Semaphore}, with a timeout of {@link #SAFE_AWAIT_TIMEOUT}, preserving the thread's * interrupt status flag and asserting that the permit was successfully acquired. From 1e1ee634b28ad43f50fa25ce7eb14bc4805ab177 Mon Sep 17 00:00:00 2001 From: Dimitris Rempapis Date: Mon, 28 Apr 2025 10:23:30 +0300 Subject: [PATCH 2/2] Backport changes --- muted-tests.yml | 2 -- .../src/main/java/org/elasticsearch/test/ESIntegTestCase.java | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/muted-tests.yml b/muted-tests.yml index 5ec415112269d..b9573ad166636 100644 --- a/muted-tests.yml +++ b/muted-tests.yml @@ -220,8 +220,6 @@ tests: - class: org.elasticsearch.xpack.spatial.search.GeoGridAggAndQueryConsistencyIT method: testGeoShapeGeoHash issue: https://github.com/elastic/elasticsearch/issues/115664 -- class: org.elasticsearch.indices.mapping.UpdateMappingIntegrationIT - issue: https://github.com/elastic/elasticsearch/issues/116126 - class: org.elasticsearch.upgrades.FullClusterRestartIT method: testSnapshotRestore {cluster=OLD} issue: https://github.com/elastic/elasticsearch/issues/111777 diff --git a/test/framework/src/main/java/org/elasticsearch/test/ESIntegTestCase.java b/test/framework/src/main/java/org/elasticsearch/test/ESIntegTestCase.java index bb4ab15f312b7..5745f85bfae6a 100644 --- a/test/framework/src/main/java/org/elasticsearch/test/ESIntegTestCase.java +++ b/test/framework/src/main/java/org/elasticsearch/test/ESIntegTestCase.java @@ -1797,7 +1797,7 @@ public void indexRandom(boolean forceRefresh, boolean dummyDocuments, boolean ma } } for (CountDownLatch operation : inFlightAsyncOperations) { - safeAwait(operation); + safeAwait(operation, TEST_REQUEST_TIMEOUT); } if (bogusIds.isEmpty() == false) { // delete the bogus types again - it might trigger merges or at least holes in the segments and enforces deleted docs!