Skip to content

Commit 7d87c52

Browse files
authored
update warmup rolling upgrade scenario (opensearch-project#2232)
Signed-off-by: Vijayan Balasubramanian <[email protected]>
1 parent eb0a3c7 commit 7d87c52

File tree

1 file changed

+11
-34
lines changed
  • qa/rolling-upgrade/src/test/java/org/opensearch/knn/bwc

1 file changed

+11
-34
lines changed

qa/rolling-upgrade/src/test/java/org/opensearch/knn/bwc/WarmupIT.java

+11-34
Original file line numberDiff line numberDiff line change
@@ -9,59 +9,36 @@
99
import org.opensearch.knn.index.KNNSettings;
1010

1111
import java.util.Collections;
12+
import java.util.List;
1213

1314
import static org.opensearch.knn.TestUtils.NODES_BWC_CLUSTER;
1415

1516
public class WarmupIT extends AbstractRollingUpgradeTestCase {
1617
private static final String TEST_FIELD = "test-field";
1718
private static final int DIMENSIONS = 5;
18-
private static final int K = 5;
1919
private static final int NUM_DOCS = 10;
2020

2121
public void testKNNWarmup() throws Exception {
2222
waitForClusterHealthGreen(NODES_BWC_CLUSTER);
2323
switch (getClusterType()) {
2424
case OLD:
2525
createKnnIndex(testIndex, getKNNDefaultIndexSettings(), createKnnIndexMapping(TEST_FIELD, DIMENSIONS));
26-
int docIdOld = 0;
27-
addKNNDocs(testIndex, TEST_FIELD, DIMENSIONS, docIdOld, NUM_DOCS);
26+
addKNNDocs(testIndex, TEST_FIELD, DIMENSIONS, 0, NUM_DOCS);
2827
break;
2928
case MIXED:
30-
int totalDocsCountMixed;
31-
int docIdMixed;
32-
if (isFirstMixedRound()) {
33-
docIdMixed = NUM_DOCS;
34-
totalDocsCountMixed = 2 * NUM_DOCS;
35-
} else {
36-
docIdMixed = 2 * NUM_DOCS;
37-
totalDocsCountMixed = 3 * NUM_DOCS;
38-
}
39-
updateIndexSettings(testIndex, Settings.builder().put(KNNSettings.INDEX_KNN_ADVANCED_APPROXIMATE_THRESHOLD, 0));
40-
validateKNNWarmupOnUpgrade(totalDocsCountMixed, docIdMixed);
29+
int graphCount = getTotalGraphsInCache();
30+
knnWarmup(Collections.singletonList(testIndex));
31+
assertTrue(getTotalGraphsInCache() > graphCount);
32+
clearCache(List.of(testIndex));
4133
break;
4234
case UPGRADED:
43-
int docIdUpgraded = 3 * NUM_DOCS;
44-
int totalDocsCountUpgraded = 4 * NUM_DOCS;
45-
validateKNNWarmupOnUpgrade(totalDocsCountUpgraded, docIdUpgraded);
46-
35+
updateIndexSettings(testIndex, Settings.builder().put(KNNSettings.INDEX_KNN_ADVANCED_APPROXIMATE_THRESHOLD, 0));
36+
addKNNDocs(testIndex, TEST_FIELD, DIMENSIONS, NUM_DOCS, NUM_DOCS);
37+
int updatedGraphCount = getTotalGraphsInCache();
38+
knnWarmup(Collections.singletonList(testIndex));
39+
assertTrue(getTotalGraphsInCache() > updatedGraphCount);
4740
deleteKNNIndex(testIndex);
4841
}
49-
50-
}
51-
52-
// validation steps for KNN Warmup after upgrading each node from old version to new version
53-
public void validateKNNWarmupOnUpgrade(int totalDocsCount, int docId) throws Exception {
54-
int graphCount = getTotalGraphsInCache();
55-
knnWarmup(Collections.singletonList(testIndex));
56-
assertTrue(getTotalGraphsInCache() > graphCount);
57-
58-
addKNNDocs(testIndex, TEST_FIELD, DIMENSIONS, docId, NUM_DOCS);
59-
60-
int updatedGraphCount = getTotalGraphsInCache();
61-
knnWarmup(Collections.singletonList(testIndex));
62-
assertTrue(getTotalGraphsInCache() > updatedGraphCount);
63-
64-
validateKNNSearch(testIndex, TEST_FIELD, DIMENSIONS, totalDocsCount, K);
6542
}
6643

6744
}

0 commit comments

Comments
 (0)