From 4849f368799e4518fe3335f93a06006032b0f5ff Mon Sep 17 00:00:00 2001 From: Vijayan Balasubramanian Date: Tue, 22 Oct 2024 14:19:18 -0700 Subject: [PATCH] Fix bwc test Signed-off-by: Vijayan Balasubramanian --- .../org/opensearch/knn/bwc/ClearCacheIT.java | 17 ++++------------- .../java/org/opensearch/knn/bwc/WarmupIT.java | 4 +++- 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/qa/restart-upgrade/src/test/java/org/opensearch/knn/bwc/ClearCacheIT.java b/qa/restart-upgrade/src/test/java/org/opensearch/knn/bwc/ClearCacheIT.java index 045821e09..f93f2f883 100644 --- a/qa/restart-upgrade/src/test/java/org/opensearch/knn/bwc/ClearCacheIT.java +++ b/qa/restart-upgrade/src/test/java/org/opensearch/knn/bwc/ClearCacheIT.java @@ -22,14 +22,11 @@ public void testClearCache() throws Exception { if (isRunningAgainstOldCluster()) { createKnnIndex(testIndex, getKNNDefaultIndexSettings(), createKnnIndexMapping(TEST_FIELD, DIMENSIONS)); addKNNDocs(testIndex, TEST_FIELD, DIMENSIONS, docId, NUM_DOCS); - } else { queryCnt = NUM_DOCS; - validateClearCacheOnUpgrade(queryCnt); - - docId = NUM_DOCS; - addKNNDocs(testIndex, TEST_FIELD, DIMENSIONS, docId, NUM_DOCS); - - queryCnt = queryCnt + NUM_DOCS; + int graphCount = getTotalGraphsInCache(); + knnWarmup(Collections.singletonList(testIndex)); + assertTrue(getTotalGraphsInCache() > graphCount); + } else { validateClearCacheOnUpgrade(queryCnt); deleteKNNIndex(testIndex); } @@ -37,13 +34,7 @@ public void testClearCache() throws Exception { // validation steps for Clear Cache API after upgrading node to new version private void validateClearCacheOnUpgrade(int queryCount) throws Exception { - int graphCount = getTotalGraphsInCache(); - knnWarmup(Collections.singletonList(testIndex)); - assertTrue(getTotalGraphsInCache() > graphCount); - validateKNNSearch(testIndex, TEST_FIELD, DIMENSIONS, queryCount, K); - clearCache(Collections.singletonList(testIndex)); assertEquals(0, getTotalGraphsInCache()); - validateKNNSearch(testIndex, TEST_FIELD, DIMENSIONS, queryCount, K); } } diff --git a/qa/restart-upgrade/src/test/java/org/opensearch/knn/bwc/WarmupIT.java b/qa/restart-upgrade/src/test/java/org/opensearch/knn/bwc/WarmupIT.java index 8a965d2fa..1f9460397 100644 --- a/qa/restart-upgrade/src/test/java/org/opensearch/knn/bwc/WarmupIT.java +++ b/qa/restart-upgrade/src/test/java/org/opensearch/knn/bwc/WarmupIT.java @@ -9,6 +9,7 @@ import org.opensearch.knn.index.SpaceType; import java.util.Collections; +import java.util.Locale; import static org.opensearch.knn.TestUtils.KNN_ALGO_PARAM_M_MIN_VALUE; import static org.opensearch.knn.TestUtils.KNN_ALGO_PARAM_EF_CONSTRUCTION_MIN_VALUE; @@ -87,7 +88,8 @@ public void testKNNWarmupCustomMethodFieldMapping() throws Exception { public void validateKNNWarmupOnUpgrade() throws Exception { int graphCount = getTotalGraphsInCache(); knnWarmup(Collections.singletonList(testIndex)); - assertTrue(getTotalGraphsInCache() > graphCount); + int totalGraph = getTotalGraphsInCache(); + assertTrue(String.format(Locale.ROOT, "[%d] is not greater than [%d]", totalGraph, graphCount), totalGraph > graphCount); QUERY_COUNT = NUM_DOCS; validateKNNSearch(testIndex, TEST_FIELD, DIMENSIONS, QUERY_COUNT, K);