Преглед изворни кода

[Test] Extended IndexActionTests.testAutoGenerateIdNoDuplicates to check both with and without a specific type

The test also captures the first error but continues to run searches in order to gather more information before failing.
Boaz Leskes пре 11 година
родитељ
комит
ef5d64c73b
1 измењених фајлова са 20 додато и 1 уклоњено
  1. 20 1
      src/test/java/org/elasticsearch/indexing/IndexActionTests.java

+ 20 - 1
src/test/java/org/elasticsearch/indexing/IndexActionTests.java

@@ -52,6 +52,7 @@ public class IndexActionTests extends ElasticsearchIntegrationTest {
     public void testAutoGenerateIdNoDuplicates() throws Exception {
         int numberOfIterations = randomIntBetween(10, 50);
         for (int i = 0; i < numberOfIterations; i++) {
+            Throwable firstError = null;
             createIndex("test");
             int numOfDocs = randomIntBetween(10, 100);
             List<IndexRequestBuilder> builders = new ArrayList<>(numOfDocs);
@@ -62,7 +63,25 @@ public class IndexActionTests extends ElasticsearchIntegrationTest {
             logger.info("verifying indexed content");
             int numOfChecks = randomIntBetween(5, 10);
             for (int j = 0; j < numOfChecks; j++) {
-                assertHitCount(client().prepareSearch("test").get(), numOfDocs);
+                try {
+                    assertHitCount(client().prepareSearch("test").get(), numOfDocs);
+                } catch (Throwable t) {
+                    logger.error("search for all docs types failed", t);
+                    if (firstError == null) {
+                        firstError = t;
+                    }
+                }
+                try {
+                    assertHitCount(client().prepareSearch("test").setTypes("type").get(), numOfDocs);
+                } catch (Throwable t) {
+                    logger.error("search for all docs of a specific type failed", t);
+                    if (firstError == null) {
+                        firstError = t;
+                    }
+                }
+            }
+            if (firstError != null) {
+                fail(firstError.getMessage());
             }
             cluster().wipeIndices("test");
         }