From 8f7bef893600f48df6ff80386f6d6444134797e6 Mon Sep 17 00:00:00 2001 From: Michael Froh Date: Thu, 26 Jun 2025 14:55:57 -0700 Subject: [PATCH] Remove redundant step from IndexActionIT#testAutoGenerateIdNoDuplicates testAutoGenerateIdNoDuplicates was modified back in 2014 to search all docs in the index and to search all docs of a given type in the index. When types were removed in OpenSearch 2.0, that second check had the type removed, making it identical to the first check. This change essentially goes back to the pre-2014 version, when the test was just searching all docs in the index once. Also, I modified the test to change index names on every iteration in the hope that it becomes a bit less flaky. Generating a different index on every iteration does not appear to violate the spirit of the test. Signed-off-by: Michael Froh --- .../opensearch/indexing/IndexActionIT.java | 32 ++++--------------- 1 file changed, 7 insertions(+), 25 deletions(-) diff --git a/server/src/internalClusterTest/java/org/opensearch/indexing/IndexActionIT.java b/server/src/internalClusterTest/java/org/opensearch/indexing/IndexActionIT.java index c6718500f14fe..0ae4b5c61aedc 100644 --- a/server/src/internalClusterTest/java/org/opensearch/indexing/IndexActionIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/indexing/IndexActionIT.java @@ -80,21 +80,22 @@ public static Collection 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 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() @@ -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; } @@ -134,7 +116,7 @@ public void testAutoGenerateIdNoDuplicates() throws Exception { if (firstError != null) { fail(firstError.getMessage()); } - internalCluster().wipeIndices("test"); + internalCluster().wipeIndices(indexName); } }