From a056804831d8ea316213e8fb2ab723a532f4086c Mon Sep 17 00:00:00 2001 From: Jim Ferenczi Date: Mon, 28 Jan 2019 09:24:32 +0100 Subject: [PATCH] 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 --- .../recovery/RecoveryWhileUnderLoadIT.java | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/server/src/test/java/org/elasticsearch/recovery/RecoveryWhileUnderLoadIT.java b/server/src/test/java/org/elasticsearch/recovery/RecoveryWhileUnderLoadIT.java index d23239509f3..9220748f38c 100644 --- a/server/src/test/java/org/elasticsearch/recovery/RecoveryWhileUnderLoadIT.java +++ b/server/src/test/java/org/elasticsearch/recovery/RecoveryWhileUnderLoadIT.java @@ -115,7 +115,6 @@ public class RecoveryWhileUnderLoadIT extends ESIntegTestCase { } } - @AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/37895") public void testRecoverWhileUnderLoadAllocateReplicasRelocatePrimariesTest() throws Exception { logger.info("--> creating test index ..."); int numberOfShards = numberOfShards(); @@ -300,8 +299,11 @@ public class RecoveryWhileUnderLoadIT extends ESIntegTestCase { SearchResponse[] iterationResults = new SearchResponse[iterations]; boolean error = false; for (int i = 0; i < iterations; i++) { - SearchResponse searchResponse = client().prepareSearch().setSize((int) numberOfDocs).setQuery(matchAllQuery()) - .addSort("id", SortOrder.ASC).get(); + SearchResponse searchResponse = client().prepareSearch() + .setSize((int) numberOfDocs) + .setQuery(matchAllQuery()) + .setTrackTotalHits(true) + .addSort("id", SortOrder.ASC).get(); logSearchResponse(numberOfShards, numberOfDocs, i, searchResponse); iterationResults[i] = searchResponse; if (searchResponse.getHits().getTotalHits().value != numberOfDocs) { @@ -340,7 +342,11 @@ public class RecoveryWhileUnderLoadIT extends ESIntegTestCase { assertTrue(awaitBusy(() -> { boolean errorOccurred = false; 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) { errorOccurred = true; }