diff --git a/qa/restart-upgrade/build.gradle b/qa/restart-upgrade/build.gradle index 628b62352..3fc1e1be5 100644 --- a/qa/restart-upgrade/build.gradle +++ b/qa/restart-upgrade/build.gradle @@ -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 { @@ -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()}") @@ -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 { @@ -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' diff --git a/qa/restart-upgrade/src/test/java/org/opensearch/knn/bwc/ModelIT.java b/qa/restart-upgrade/src/test/java/org/opensearch/knn/bwc/ModelIT.java index c2bcdbf83..f72f9324c 100644 --- a/qa/restart-upgrade/src/test/java/org/opensearch/knn/bwc/ModelIT.java +++ b/qa/restart-upgrade/src/test/java/org/opensearch/knn/bwc/ModelIT.java @@ -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 {