Track total hits in tests that index more than 10,000 docs

This change sets track_total_hits to true on a test that requires
to check the total hits of a query that can return more than 10,000 docs.

Closes #37895
This commit is contained in:
Jim Ferenczi 2019-01-28 09:24:32 +01:00
parent 290c6637c2
commit a056804831
1 changed files with 10 additions and 4 deletions

View File

@ -115,7 +115,6 @@ public class RecoveryWhileUnderLoadIT extends ESIntegTestCase {
} }
} }
@AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/37895")
public void testRecoverWhileUnderLoadAllocateReplicasRelocatePrimariesTest() throws Exception { public void testRecoverWhileUnderLoadAllocateReplicasRelocatePrimariesTest() throws Exception {
logger.info("--> creating test index ..."); logger.info("--> creating test index ...");
int numberOfShards = numberOfShards(); int numberOfShards = numberOfShards();
@ -300,7 +299,10 @@ public class RecoveryWhileUnderLoadIT extends ESIntegTestCase {
SearchResponse[] iterationResults = new SearchResponse[iterations]; SearchResponse[] iterationResults = new SearchResponse[iterations];
boolean error = false; boolean error = false;
for (int i = 0; i < iterations; i++) { for (int i = 0; i < iterations; i++) {
SearchResponse searchResponse = client().prepareSearch().setSize((int) numberOfDocs).setQuery(matchAllQuery()) SearchResponse searchResponse = client().prepareSearch()
.setSize((int) numberOfDocs)
.setQuery(matchAllQuery())
.setTrackTotalHits(true)
.addSort("id", SortOrder.ASC).get(); .addSort("id", SortOrder.ASC).get();
logSearchResponse(numberOfShards, numberOfDocs, i, searchResponse); logSearchResponse(numberOfShards, numberOfDocs, i, searchResponse);
iterationResults[i] = searchResponse; iterationResults[i] = searchResponse;
@ -340,7 +342,11 @@ public class RecoveryWhileUnderLoadIT extends ESIntegTestCase {
assertTrue(awaitBusy(() -> { assertTrue(awaitBusy(() -> {
boolean errorOccurred = false; boolean errorOccurred = false;
for (int i = 0; i < iterations; i++) { for (int i = 0; i < iterations; i++) {
SearchResponse searchResponse = client().prepareSearch().setSize(0).setQuery(matchAllQuery()).get(); SearchResponse searchResponse = client().prepareSearch()
.setTrackTotalHits(true)
.setSize(0)
.setQuery(matchAllQuery())
.get();
if (searchResponse.getHits().getTotalHits().value != numberOfDocs) { if (searchResponse.getHits().getTotalHits().value != numberOfDocs) {
errorOccurred = true; errorOccurred = true;
} }