瀏覽代碼

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
Jim Ferenczi 6 年之前
父節點
當前提交
a056804831
共有 1 個文件被更改,包括 10 次插入4 次删除
  1. 10 4
      server/src/test/java/org/elasticsearch/recovery/RecoveryWhileUnderLoadIT.java

+ 10 - 4
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;
                                     }