From ffe6966ccd0bd2846f5f78a73ce9c32545219921 Mon Sep 17 00:00:00 2001 From: markharwood Date: Wed, 19 Jul 2017 12:36:18 +0100 Subject: [PATCH] Test fix - ensure forceMerged to single segment to avoid scoring variations in tests. Removed test muting. Original commit: elastic/x-pack-elasticsearch@3a584aaddad6441f8143b727a8d4d3e9bc0cc8b3 --- .../xpack/graph/test/GraphTests.java | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/plugin/src/test/java/org/elasticsearch/xpack/graph/test/GraphTests.java b/plugin/src/test/java/org/elasticsearch/xpack/graph/test/GraphTests.java index 92bbc2b3059..07c8d7f7e49 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/graph/test/GraphTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/graph/test/GraphTests.java @@ -7,6 +7,9 @@ package org.elasticsearch.xpack.graph.test; import org.apache.lucene.search.BooleanQuery; import org.elasticsearch.action.ActionRequestValidationException; +import org.elasticsearch.action.admin.indices.forcemerge.ForceMergeResponse; +import org.elasticsearch.action.admin.indices.segments.IndexShardSegments; +import org.elasticsearch.action.admin.indices.segments.ShardSegments; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.settings.Settings.Builder; import org.elasticsearch.common.unit.TimeValue; @@ -36,6 +39,7 @@ import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF_SHARDS; import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery; import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked; +import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAllSuccessful; import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertHitCount; import static org.hamcrest.Matchers.greaterThan; @@ -93,6 +97,18 @@ public class GraphTests extends XPackSingleNodeTestCase { } } client().admin().indices().prepareRefresh("test").get(); + // Ensure single segment with no deletes. Hopefully solves test instability in + // issue https://github.com/elastic/x-pack-elasticsearch/issues/918 + ForceMergeResponse actionGet = client().admin().indices().prepareForceMerge("test").setFlush(true).setMaxNumSegments(1) + .execute().actionGet(); + assertAllSuccessful(actionGet); + for (IndexShardSegments seg : client().admin().indices().prepareSegments().get().getIndices().get("test")) { + ShardSegments[] shards = seg.getShards(); + for (ShardSegments shardSegments : shards) { + assertEquals(1, shardSegments.getSegments().size()); + } + } + assertHitCount(client().prepareSearch().setQuery(matchAllQuery()).get(), numDocs); } @@ -101,7 +117,6 @@ public class GraphTests extends XPackSingleNodeTestCase { return pluginList(ScriptedTimeoutPlugin.class, XPackPlugin.class); } - @AwaitsFix(bugUrl = "https://github.com/elastic/x-pack-elasticsearch/issues/918") public void testSignificanceQueryCrawl() { GraphExploreRequestBuilder grb = new GraphExploreRequestBuilder(client(), GraphExploreAction.INSTANCE).setIndices("test"); Hop hop1 = grb.createNextHop(QueryBuilders.termQuery("description", "beatles"));