Fix IndexShardTests.testStressRelocated

Closes #16364
This commit is contained in:
Yannick Welsch 2016-02-02 12:57:19 +01:00
parent 58825773eb
commit 51862ce5ae
1 changed files with 4 additions and 5 deletions

View File

@ -816,7 +816,6 @@ public class IndexShardTests extends ESSingleNodeTestCase {
} }
} }
@AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/16364")
public void testStressRelocated() throws Exception { public void testStressRelocated() throws Exception {
assertAcked(client().admin().indices().prepareCreate("test").setSettings( assertAcked(client().admin().indices().prepareCreate("test").setSettings(
Settings.builder().put("index.number_of_shards", 1).put("index.number_of_replicas", 0) 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 IndexShard shard = test.getShardOrNull(0);
final int numThreads = randomIntBetween(2, 4); final int numThreads = randomIntBetween(2, 4);
Thread[] indexThreads = new Thread[numThreads]; Thread[] indexThreads = new Thread[numThreads];
CountDownLatch somePrimaryOperationLockAcquired = new CountDownLatch(1); CountDownLatch allPrimaryOperationLocksAcquired = new CountDownLatch(numThreads);
CyclicBarrier barrier = new CyclicBarrier(numThreads + 1); CyclicBarrier barrier = new CyclicBarrier(numThreads + 1);
for (int i = 0; i < indexThreads.length; i++) { for (int i = 0; i < indexThreads.length; i++) {
indexThreads[i] = new Thread() { indexThreads[i] = new Thread() {
@Override @Override
public void run() { public void run() {
try (Releasable operationLock = shard.acquirePrimaryOperationLock()) { try (Releasable operationLock = shard.acquirePrimaryOperationLock()) {
somePrimaryOperationLockAcquired.countDown(); allPrimaryOperationLocksAcquired.countDown();
barrier.await(); barrier.await();
} catch (InterruptedException | BrokenBarrierException e) { } catch (InterruptedException | BrokenBarrierException e) {
throw new RuntimeException(e); throw new RuntimeException(e);
@ -848,8 +847,8 @@ public class IndexShardTests extends ESSingleNodeTestCase {
shard.relocated("simulated recovery"); shard.relocated("simulated recovery");
relocated.set(true); relocated.set(true);
}); });
// ensure we wait for at least one primary operation lock to be acquired // ensure we wait for all primary operation locks to be acquired
somePrimaryOperationLockAcquired.await(); allPrimaryOperationLocksAcquired.await();
// start recovery thread // start recovery thread
recoveryThread.start(); recoveryThread.start();
assertThat(relocated.get(), equalTo(false)); assertThat(relocated.get(), equalTo(false));