From 22834bce5590710617ba3058a0b4778ce66a2623 Mon Sep 17 00:00:00 2001 From: Simon Willnauer Date: Wed, 13 Jan 2016 23:39:25 +0100 Subject: [PATCH] fix possible race in IndexServiceTests#testBaseAsyncTask and add mock plugin SearchWithRandomIOExceptionsIT --- .../org/elasticsearch/index/IndexServiceTests.java | 6 ++++-- .../search/basic/SearchWithRandomIOExceptionsIT.java | 10 +++++++--- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/core/src/test/java/org/elasticsearch/index/IndexServiceTests.java b/core/src/test/java/org/elasticsearch/index/IndexServiceTests.java index 3e118f4fd4a..4c892849ccd 100644 --- a/core/src/test/java/org/elasticsearch/index/IndexServiceTests.java +++ b/core/src/test/java/org/elasticsearch/index/IndexServiceTests.java @@ -169,11 +169,13 @@ public class IndexServiceTests extends ESSingleNodeTestCase { IndexService.BaseAsyncTask task = new IndexService.BaseAsyncTask(indexService, TimeValue.timeValueMillis(1)) { @Override protected void runInternal() { + final CountDownLatch l1 = latch.get(); + final CountDownLatch l2 = latch2.get(); count.incrementAndGet(); assertTrue("generic threadpool is configured", Thread.currentThread().getName().contains("[generic]")); - latch.get().countDown(); + l1.countDown(); try { - latch2.get().await(); + l2.await(); } catch (InterruptedException e) { fail("interrupted"); } diff --git a/core/src/test/java/org/elasticsearch/search/basic/SearchWithRandomIOExceptionsIT.java b/core/src/test/java/org/elasticsearch/search/basic/SearchWithRandomIOExceptionsIT.java index 95c1a807935..1708d10f96f 100644 --- a/core/src/test/java/org/elasticsearch/search/basic/SearchWithRandomIOExceptionsIT.java +++ b/core/src/test/java/org/elasticsearch/search/basic/SearchWithRandomIOExceptionsIT.java @@ -31,13 +31,13 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.common.xcontent.XContentFactory; import org.elasticsearch.index.query.QueryBuilders; +import org.elasticsearch.plugins.Plugin; import org.elasticsearch.search.sort.SortOrder; import org.elasticsearch.test.ESIntegTestCase; -import org.elasticsearch.test.junit.annotations.TestLogging; import org.elasticsearch.test.store.MockFSDirectoryService; import org.elasticsearch.test.store.MockFSIndexStore; - import java.io.IOException; +import java.util.Collection; import java.util.concurrent.ExecutionException; import static org.elasticsearch.common.settings.Settings.settingsBuilder; @@ -46,7 +46,11 @@ import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertNoFa public class SearchWithRandomIOExceptionsIT extends ESIntegTestCase { - @TestLogging("action.search.type:TRACE,index.shard:TRACE") + @Override + protected Collection> nodePlugins() { + return pluginList(MockFSIndexStore.TestPlugin.class); + } + public void testRandomDirectoryIOExceptions() throws IOException, InterruptedException, ExecutionException { String mapping = XContentFactory.jsonBuilder(). startObject().