From 411a85eb344eb0b1876b3728a727bfbf72a93744 Mon Sep 17 00:00:00 2001 From: Artem Prigoda Date: Wed, 16 Apr 2025 14:24:46 +0200 Subject: [PATCH] Fix `SimpleBlocksIT#testConcurrentAddBlock` Only one of concurrent `prepareAddBlock` calls actually wins a race to add the block, so we need to check `assertIndexHasBlock` if the add index block has been acknowledged Resolve #122324 --- muted-tests.yml | 3 --- .../java/org/elasticsearch/blocks/SimpleBlocksIT.java | 7 +++++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/muted-tests.yml b/muted-tests.yml index af2d32f3a94d1..e54b694623ffb 100644 --- a/muted-tests.yml +++ b/muted-tests.yml @@ -207,9 +207,6 @@ tests: - class: org.elasticsearch.smoketest.SmokeTestMonitoringWithSecurityIT method: testHTTPExporterWithSSL issue: https://github.com/elastic/elasticsearch/issues/122220 -- class: org.elasticsearch.blocks.SimpleBlocksIT - method: testConcurrentAddBlock - issue: https://github.com/elastic/elasticsearch/issues/122324 - class: org.elasticsearch.xpack.ilm.TimeSeriesLifecycleActionsIT method: testHistoryIsWrittenWithFailure issue: https://github.com/elastic/elasticsearch/issues/123203 diff --git a/server/src/internalClusterTest/java/org/elasticsearch/blocks/SimpleBlocksIT.java b/server/src/internalClusterTest/java/org/elasticsearch/blocks/SimpleBlocksIT.java index 0fb4959ee38d6..f0ae5b5032af2 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/blocks/SimpleBlocksIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/blocks/SimpleBlocksIT.java @@ -412,8 +412,11 @@ public void testConcurrentAddBlock() throws InterruptedException, ExecutionExcep try { startInParallel(threadCount, i -> { try { - indicesAdmin().prepareAddBlock(block, indexName).get(); - assertIndexHasBlock(block, indexName); + AddIndexBlockResponse response = indicesAdmin().prepareAddBlock(block, indexName).get(); + // Check that the block has been added only for the request that won the race + if (response.isAcknowledged() && response.getIndices().isEmpty() == false) { + assertIndexHasBlock(block, indexName); + } } catch (final ClusterBlockException e) { assertThat(e.blocks(), hasSize(1)); assertTrue(e.blocks().stream().allMatch(b -> b.id() == block.getBlock().id()));