Skip to content

Commit

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



* format code



---------


(cherry picked from commit 51e58c5)

Signed-off-by: zane-neo <[email protected]>
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
1 parent b6c9f58 commit 5366ef3
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 @@ -276,7 +280,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 5366ef3

Please sign in to comment.