Skip to content

Commit

Permalink
Fix search alert IT failure (#329)
Browse files Browse the repository at this point in the history
* Fix search alert IT failure

Signed-off-by: zane-neo <[email protected]>

* format code

Signed-off-by: zane-neo <[email protected]>

---------

Signed-off-by: zane-neo <[email protected]>
(cherry picked from commit 51e58c5)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
github-actions[bot] committed Jun 14, 2024
1 parent 6021976 commit f0c202b
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 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,13 @@ 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 f0c202b

Please sign in to comment.