Skip to content

Commit

Permalink
Add bwc test for model id
Browse files Browse the repository at this point in the history
This is applicable for index created before 2.17

Signed-off-by: Vijayan Balasubramanian <[email protected]>
  • Loading branch information
VijayanB committed Dec 10, 2024
1 parent 5ede283 commit cdafd09
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
20 changes: 20 additions & 0 deletions qa/restart-upgrade/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ testClusters {
systemProperty 'tests.skip_delete_model_index', 'true'
systemProperty 'tests.plugin_bwc_version', knn_bwc_version

filter {
excludeTestsMatching "org.opensearch.knn.bwc.ModelIT.testNonKNNIndex_withModelId"
}
// Skip test if version is 1.0 or 1.1 as they are not supported in those versions
if (knn_bwc_version.startsWith("1.0") || knn_bwc_version.startsWith("1.1")) {
filter {
Expand Down Expand Up @@ -96,6 +99,12 @@ testClusters {
excludeTestsMatching "org.opensearch.knn.bwc.IndexingIT.testKNNIndexLuceneForceMerge"
}
}
if (knn_bwc_version.startsWith("2.15.") ||
knn_bwc_version.startsWith("2.16.")){
filter {
includeTestsMatching "org.opensearch.knn.bwc.ModelIT.testNonKNNIndex_withModelId"
}
}

nonInputProperties.systemProperty('tests.rest.cluster', "${-> testClusters."${baseName}".allHttpSocketURI.join(",")}")
nonInputProperties.systemProperty('tests.clustername', "${-> testClusters."${baseName}".getName()}")
Expand All @@ -118,6 +127,10 @@ testClusters {
systemProperty 'tests.is_old_cluster', 'false'
systemProperty 'tests.plugin_bwc_version', knn_bwc_version

filter {
excludeTestsMatching "org.opensearch.knn.bwc.ModelIT.testNonKNNIndex_withModelId"
}

// Skip test if version is 1.0 or 1.1 as they are not supported in those versions
if (knn_bwc_version.startsWith("1.0") || knn_bwc_version.startsWith("1.1")) {
filter {
Expand Down Expand Up @@ -170,6 +183,13 @@ testClusters {
}
}

if (knn_bwc_version.startsWith("2.15.") ||
knn_bwc_version.startsWith("2.16.")){
filter {
includeTestsMatching "org.opensearch.knn.bwc.ModelIT.testNonKNNIndex_withModelId"
}
}

nonInputProperties.systemProperty('tests.rest.cluster', "${-> testClusters."${baseName}".allHttpSocketURI.join(",")}")
nonInputProperties.systemProperty('tests.clustername', "${-> testClusters."${baseName}".getName()}")
systemProperty 'tests.security.manager', 'false'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,32 @@ public void testKNNModelDefault() throws Exception {
}
}

public void testNonKNNIndex_withModelId() throws Exception {
final String modelId = "random-model-id";
final String trainingIndex = "random-training-id";
if (isRunningAgainstOldCluster()) {
// Create a training index and randomly ingest data into it
createBasicKnnIndex(trainingIndex, TRAINING_FIELD, DIMENSIONS);
bulkIngestRandomVectors(trainingIndex, TRAINING_FIELD, NUM_DOCS, DIMENSIONS);

trainKNNModel(modelId, trainingIndex, TRAINING_FIELD, DIMENSIONS, MODEL_DESCRIPTION);
validateModelCreated(modelId);

createKnnIndex(testIndex, createKNNDefaultScriptScoreSettings(), createKnnIndexMapping(TEST_FIELD, modelId));
addKNNDocs(testIndex, TEST_FIELD, DIMENSIONS, DOC_ID, NUM_DOCS);
} else {
QUERY_COUNT = NUM_DOCS;
DOC_ID = NUM_DOCS;
validateKNNScriptScoreSearch(testIndex, TEST_FIELD, DIMENSIONS, QUERY_COUNT, K, SpaceType.L2);
addKNNDocs(testIndex, TEST_FIELD, DIMENSIONS, DOC_ID, NUM_DOCS);
QUERY_COUNT = QUERY_COUNT + NUM_DOCS;
validateKNNScriptScoreSearch(testIndex, TEST_FIELD, DIMENSIONS, QUERY_COUNT, K, SpaceType.L2);
deleteKNNIndex(testIndex);
deleteKNNModel(modelId);
deleteIndex(trainingIndex);
}
}

// Delete Models and ".opensearch-knn-models" index to clear cluster metadata
@AfterClass
public static void wipeAllModels() throws IOException {
Expand Down

0 comments on commit cdafd09

Please sign in to comment.