Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -80,21 +80,22 @@ public static Collection<Object[]> parameters() {
public void testAutoGenerateIdNoDuplicates() throws Exception {
int numberOfIterations = scaledRandomIntBetween(10, 50);
for (int i = 0; i < numberOfIterations; i++) {
String indexName = "test-" + i;
Exception firstError = null;
createIndex("test");
createIndex(indexName);
int numOfDocs = randomIntBetween(10, 100);
logger.info("indexing [{}] docs", numOfDocs);
List<IndexRequestBuilder> builders = new ArrayList<>(numOfDocs);
for (int j = 0; j < numOfDocs; j++) {
builders.add(client().prepareIndex("test").setSource("field", "value_" + j));
builders.add(client().prepareIndex(indexName).setSource("field", "value_" + j));
}
indexRandom(true, builders);
logger.info("verifying indexed content");
int numOfChecks = randomIntBetween(8, 12);
for (int j = 0; j < numOfChecks; j++) {
try {
logger.debug("running search with all types");
SearchResponse response = client().prepareSearch("test").get();
logger.debug("running search");
SearchResponse response = client().prepareSearch(indexName).get();
if (response.getHits().getTotalHits().value() != numOfDocs) {
final String message = "Count is "
+ response.getHits().getTotalHits().value()
Expand All @@ -106,26 +107,7 @@ public void testAutoGenerateIdNoDuplicates() throws Exception {
fail(message);
}
} catch (Exception e) {
logger.error("search for all docs types failed", e);
if (firstError == null) {
firstError = e;
}
}
try {
logger.debug("running search with a specific type");
SearchResponse response = client().prepareSearch("test").get();
if (response.getHits().getTotalHits().value() != numOfDocs) {
final String message = "Count is "
+ response.getHits().getTotalHits().value()
+ " but "
+ numOfDocs
+ " was expected. "
+ OpenSearchAssertions.formatShardStatus(response);
logger.error("{}. search response: \n{}", message, response);
fail(message);
}
} catch (Exception e) {
logger.error("search for all docs of a specific type failed", e);
logger.error("search for all docs failed", e);
if (firstError == null) {
firstError = e;
}
Expand All @@ -134,7 +116,7 @@ public void testAutoGenerateIdNoDuplicates() throws Exception {
if (firstError != null) {
fail(firstError.getMessage());
}
internalCluster().wipeIndices("test");
internalCluster().wipeIndices(indexName);
}
}

Expand Down
Loading