Skip to content

Commit df33e0f

Browse files
committed
test: Index more docs, so that it is less likely the search request
does not time out. Closes #29221
1 parent 02ca61c commit df33e0f

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

server/src/test/java/org/elasticsearch/search/SearchTimeoutIT.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,12 @@
2121

2222
import org.elasticsearch.ElasticsearchException;
2323
import org.elasticsearch.action.search.SearchResponse;
24-
import org.elasticsearch.action.search.SearchType;
2524
import org.elasticsearch.common.settings.Settings;
2625
import org.elasticsearch.common.unit.TimeValue;
2726
import org.elasticsearch.plugins.Plugin;
2827
import org.elasticsearch.script.MockScriptPlugin;
2928
import org.elasticsearch.script.Script;
3029
import org.elasticsearch.script.ScriptType;
31-
import org.elasticsearch.search.aggregations.AggregatorFactories;
32-
import org.elasticsearch.search.query.QueryPhaseExecutionException;
3330
import org.elasticsearch.test.ESIntegTestCase;
3431

3532
import java.util.Collection;
@@ -57,7 +54,10 @@ protected Settings nodeSettings(int nodeOrdinal) {
5754
}
5855

5956
public void testSimpleTimeout() throws Exception {
60-
client().prepareIndex("test", "type", "1").setSource("field", "value").setRefreshPolicy(IMMEDIATE).get();
57+
for (int i = 0; i < 32; i++) {
58+
client().prepareIndex("test", "type", Integer.toString(i)).setSource("field", "value").get();
59+
}
60+
refresh("test");
6161

6262
SearchResponse searchResponse = client().prepareSearch("test").setTimeout(new TimeValue(10, TimeUnit.MILLISECONDS))
6363
.setQuery(scriptQuery(
@@ -66,19 +66,19 @@ public void testSimpleTimeout() throws Exception {
6666
.execute().actionGet();
6767
assertThat(searchResponse.isTimedOut(), equalTo(true));
6868
}
69-
69+
7070
public void testPartialResultsIntolerantTimeout() throws Exception {
7171
client().prepareIndex("test", "type", "1").setSource("field", "value").setRefreshPolicy(IMMEDIATE).get();
72-
73-
ElasticsearchException ex = expectThrows(ElasticsearchException.class, () ->
72+
73+
ElasticsearchException ex = expectThrows(ElasticsearchException.class, () ->
7474
client().prepareSearch("test").setTimeout(new TimeValue(10, TimeUnit.MILLISECONDS))
7575
.setQuery(scriptQuery(
7676
new Script(ScriptType.INLINE, "mockscript", SCRIPT_NAME, Collections.emptyMap())))
7777
.setAllowPartialSearchResults(false) // this line causes timeouts to report failures
78-
.execute().actionGet()
78+
.execute().actionGet()
7979
);
8080
assertTrue(ex.toString().contains("Time exceeded"));
81-
}
81+
}
8282

8383
public static class ScriptedTimeoutPlugin extends MockScriptPlugin {
8484
static final String SCRIPT_NAME = "search_timeout";

0 commit comments

Comments
 (0)