[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.
This commit is contained in:
Boaz Leskes 2014-06-03 21:55:10 +02:00
parent 963f627dca
commit ef5d64c73b
1 changed files with 20 additions and 1 deletions

View File

@ -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");
}