From df33e0f1d9840511ce3a101b4e1b8d2d9dc46638 Mon Sep 17 00:00:00 2001 From: Martijn van Groningen Date: Thu, 12 Apr 2018 11:41:41 +0200 Subject: [PATCH] test: Index more docs, so that it is less likely the search request does not time out. Closes #29221 --- .../elasticsearch/search/SearchTimeoutIT.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/server/src/test/java/org/elasticsearch/search/SearchTimeoutIT.java b/server/src/test/java/org/elasticsearch/search/SearchTimeoutIT.java index 15bed6979fc85..762a22c823fba 100644 --- a/server/src/test/java/org/elasticsearch/search/SearchTimeoutIT.java +++ b/server/src/test/java/org/elasticsearch/search/SearchTimeoutIT.java @@ -21,15 +21,12 @@ import org.elasticsearch.ElasticsearchException; import org.elasticsearch.action.search.SearchResponse; -import org.elasticsearch.action.search.SearchType; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.plugins.Plugin; import org.elasticsearch.script.MockScriptPlugin; import org.elasticsearch.script.Script; import org.elasticsearch.script.ScriptType; -import org.elasticsearch.search.aggregations.AggregatorFactories; -import org.elasticsearch.search.query.QueryPhaseExecutionException; import org.elasticsearch.test.ESIntegTestCase; import java.util.Collection; @@ -57,7 +54,10 @@ protected Settings nodeSettings(int nodeOrdinal) { } public void testSimpleTimeout() throws Exception { - client().prepareIndex("test", "type", "1").setSource("field", "value").setRefreshPolicy(IMMEDIATE).get(); + for (int i = 0; i < 32; i++) { + client().prepareIndex("test", "type", Integer.toString(i)).setSource("field", "value").get(); + } + refresh("test"); SearchResponse searchResponse = client().prepareSearch("test").setTimeout(new TimeValue(10, TimeUnit.MILLISECONDS)) .setQuery(scriptQuery( @@ -66,19 +66,19 @@ public void testSimpleTimeout() throws Exception { .execute().actionGet(); assertThat(searchResponse.isTimedOut(), equalTo(true)); } - + public void testPartialResultsIntolerantTimeout() throws Exception { client().prepareIndex("test", "type", "1").setSource("field", "value").setRefreshPolicy(IMMEDIATE).get(); - - ElasticsearchException ex = expectThrows(ElasticsearchException.class, () -> + + ElasticsearchException ex = expectThrows(ElasticsearchException.class, () -> client().prepareSearch("test").setTimeout(new TimeValue(10, TimeUnit.MILLISECONDS)) .setQuery(scriptQuery( new Script(ScriptType.INLINE, "mockscript", SCRIPT_NAME, Collections.emptyMap()))) .setAllowPartialSearchResults(false) // this line causes timeouts to report failures - .execute().actionGet() + .execute().actionGet() ); assertTrue(ex.toString().contains("Time exceeded")); - } + } public static class ScriptedTimeoutPlugin extends MockScriptPlugin { static final String SCRIPT_NAME = "search_timeout";