From 51862ce5aec97ba1e7bfd8f765129ce395a976b6 Mon Sep 17 00:00:00 2001 From: Yannick Welsch Date: Tue, 2 Feb 2016 12:57:19 +0100 Subject: [PATCH] Fix IndexShardTests.testStressRelocated Closes #16364 --- .../org/elasticsearch/index/shard/IndexShardTests.java | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/core/src/test/java/org/elasticsearch/index/shard/IndexShardTests.java b/core/src/test/java/org/elasticsearch/index/shard/IndexShardTests.java index bedda8d3c61..a77e75d1356 100644 --- a/core/src/test/java/org/elasticsearch/index/shard/IndexShardTests.java +++ b/core/src/test/java/org/elasticsearch/index/shard/IndexShardTests.java @@ -816,7 +816,6 @@ public class IndexShardTests extends ESSingleNodeTestCase { } } - @AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/16364") public void testStressRelocated() throws Exception { assertAcked(client().admin().indices().prepareCreate("test").setSettings( Settings.builder().put("index.number_of_shards", 1).put("index.number_of_replicas", 0) @@ -827,14 +826,14 @@ public class IndexShardTests extends ESSingleNodeTestCase { final IndexShard shard = test.getShardOrNull(0); final int numThreads = randomIntBetween(2, 4); Thread[] indexThreads = new Thread[numThreads]; - CountDownLatch somePrimaryOperationLockAcquired = new CountDownLatch(1); + CountDownLatch allPrimaryOperationLocksAcquired = new CountDownLatch(numThreads); CyclicBarrier barrier = new CyclicBarrier(numThreads + 1); for (int i = 0; i < indexThreads.length; i++) { indexThreads[i] = new Thread() { @Override public void run() { try (Releasable operationLock = shard.acquirePrimaryOperationLock()) { - somePrimaryOperationLockAcquired.countDown(); + allPrimaryOperationLocksAcquired.countDown(); barrier.await(); } catch (InterruptedException | BrokenBarrierException e) { throw new RuntimeException(e); @@ -848,8 +847,8 @@ public class IndexShardTests extends ESSingleNodeTestCase { shard.relocated("simulated recovery"); relocated.set(true); }); - // ensure we wait for at least one primary operation lock to be acquired - somePrimaryOperationLockAcquired.await(); + // ensure we wait for all primary operation locks to be acquired + allPrimaryOperationLocksAcquired.await(); // start recovery thread recoveryThread.start(); assertThat(relocated.get(), equalTo(false));