From d6d7f9ba32e3465c9001910d0ad26194ec4e3224 Mon Sep 17 00:00:00 2001 From: Varun Jain Date: Wed, 27 Dec 2023 11:18:53 -0800 Subject: [PATCH] Remove KNN delete models Signed-off-by: Varun Jain --- .../OpenSearchSecureRestTestCase.java | 20 ++++++------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/src/testFixtures/java/org/opensearch/neuralsearch/OpenSearchSecureRestTestCase.java b/src/testFixtures/java/org/opensearch/neuralsearch/OpenSearchSecureRestTestCase.java index de217d828..d42ae62eb 100644 --- a/src/testFixtures/java/org/opensearch/neuralsearch/OpenSearchSecureRestTestCase.java +++ b/src/testFixtures/java/org/opensearch/neuralsearch/OpenSearchSecureRestTestCase.java @@ -50,7 +50,12 @@ import org.opensearch.common.util.concurrent.ThreadContext; import org.opensearch.common.xcontent.XContentFactory; import org.opensearch.core.rest.RestStatus; -import org.opensearch.core.xcontent.*; +import org.opensearch.core.xcontent.DeprecationHandler; +import org.opensearch.core.xcontent.MediaType; +import org.opensearch.core.xcontent.MediaTypeRegistry; +import org.opensearch.core.xcontent.NamedXContentRegistry; +import org.opensearch.core.xcontent.XContentBuilder; +import org.opensearch.core.xcontent.XContentParser; import org.opensearch.knn.plugin.KNNPlugin; import org.opensearch.search.SearchHit; import org.opensearch.test.rest.OpenSearchRestTestCase; @@ -209,7 +214,6 @@ private boolean isIndexCleanupRequired(final String index) { } private void wipeIndexContent(String indexName) throws IOException, ParseException { - deleteModels(getModelIds()); deleteAllDocs(indexName); } @@ -228,18 +232,6 @@ private List getModelIds() throws IOException, ParseException { return Arrays.stream(searchResponse.getHits().getHits()).map(SearchHit::getId).collect(Collectors.toList()); } - private void deleteModels(final List modelIds) throws IOException { - for (final String testModelID : modelIds) { - final String restURIGetModel = String.join("/", KNNPlugin.KNN_BASE_URI, MODELS, testModelID); - final Response getModelResponse = adminClient().performRequest(new Request("GET", restURIGetModel)); - if (RestStatus.OK != RestStatus.fromCode(getModelResponse.getStatusLine().getStatusCode())) { - continue; - } - final String restURIDeleteModel = String.join("/", KNNPlugin.KNN_BASE_URI, MODELS, testModelID); - adminClient().performRequest(new Request("DELETE", restURIDeleteModel)); - } - } - private void deleteAllDocs(final String indexName) throws IOException { final String restURIDeleteByQuery = String.join("/", indexName, "_delete_by_query"); final Request request = new Request("POST", restURIDeleteByQuery);