Skip to content

Commit

Permalink
Fix search alert IT failure
Browse files Browse the repository at this point in the history
Signed-off-by: zane-neo <[email protected]>
  • Loading branch information
zane-neo committed Jun 14, 2024
1 parent bb32961 commit 1c95985
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/test/java/org/opensearch/integTest/BaseAgentToolsIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import java.io.IOException;
import java.util.Collections;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Optional;
import java.util.function.Predicate;
Expand Down Expand Up @@ -235,10 +236,13 @@ protected void deleteModel(String modelId) {
}

protected void createIndexWithConfiguration(String indexName, String indexConfiguration) throws Exception {
Response response = makeRequest(client(), "PUT", indexName, null, indexConfiguration, null);
Map<String, Object> responseInMap = parseResponseToMap(response);
assertEquals("true", responseInMap.get("acknowledged").toString());
assertEquals(indexName, responseInMap.get("index").toString());
boolean indexExists = indexExists(indexName);
if (!indexExists) {
Response response = makeRequest(client(), "PUT", indexName, null, indexConfiguration, null);
Map<String, Object> responseInMap = parseResponseToMap(response);
assertEquals("true", responseInMap.get("acknowledged").toString());
assertEquals(indexName, responseInMap.get("index").toString());
}
}

protected void createIngestPipelineWithConfiguration(String pipelineName, String body) throws Exception {
Expand Down Expand Up @@ -274,7 +278,10 @@ protected void deleteSystemIndices() throws IOException {
.collect(Collectors.toList());

for (final String indexName : externalIndices) {
adminClient().performRequest(new Request("DELETE", "/" + indexName));
Response deleteResponse = adminClient().performRequest(new Request("DELETE", "/" + indexName));
Map<String, Object> responseInMap = parseResponseToMap(deleteResponse);
assertEquals(String.format(Locale.ROOT, "delete index %s failed with response: %s", indexName, gson.toJson(responseInMap)),
"true", responseInMap.get("acknowledged").toString());
}
}
}
Expand Down

0 comments on commit 1c95985

Please sign in to comment.