-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add alerting tools IT; fix missing system index bug of SearchMonitors…
…Tool (#135) (#141) (cherry picked from commit 3e4d451) Signed-off-by: Tyler Ohlsen <[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
097d11c
commit b24a621
Showing
7 changed files
with
196 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
src/test/java/org/opensearch/integTest/SearchAlertsToolIT.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package org.opensearch.integTest; | ||
|
||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
|
||
import org.junit.After; | ||
import org.junit.Before; | ||
|
||
import lombok.SneakyThrows; | ||
|
||
public class SearchAlertsToolIT extends BaseAgentToolsIT { | ||
private String registerAgentRequestBody; | ||
private static final String monitorId = "foo-id"; | ||
private static final String monitorName = "foo-name"; | ||
|
||
@Before | ||
@SneakyThrows | ||
public void setUp() { | ||
super.setUp(); | ||
registerAgentRequestBody = Files | ||
.readString( | ||
Path | ||
.of( | ||
this | ||
.getClass() | ||
.getClassLoader() | ||
.getResource("org/opensearch/agent/tools/register_flow_agent_of_search_alerts_tool_request_body.json") | ||
.toURI() | ||
) | ||
); | ||
} | ||
|
||
@After | ||
@SneakyThrows | ||
public void tearDown() { | ||
super.tearDown(); | ||
deleteExternalIndices(); | ||
deleteSystemIndices(); | ||
} | ||
|
||
@SneakyThrows | ||
public void testSearchAlertsToolInFlowAgent_withNoSystemIndex() { | ||
deleteSystemIndices(); | ||
String agentId = createAgent(registerAgentRequestBody); | ||
String agentInput = "{\"parameters\":{\"monitorId\": \"" + monitorId + "\"}}"; | ||
String result = executeAgent(agentId, agentInput); | ||
assertEquals("Alerts=[]TotalAlerts=0", result); | ||
} | ||
|
||
// TODO: Add IT to test against sample alerts data | ||
// https://github.com/opensearch-project/skills/issues/136 | ||
} |
58 changes: 58 additions & 0 deletions
58
src/test/java/org/opensearch/integTest/SearchMonitorsToolIT.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package org.opensearch.integTest; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
|
||
import org.junit.After; | ||
import org.junit.Before; | ||
|
||
import lombok.SneakyThrows; | ||
|
||
public class SearchMonitorsToolIT extends BaseAgentToolsIT { | ||
private String registerAgentRequestBody; | ||
private static final String monitorId = "foo-id"; | ||
private static final String monitorName = "foo-name"; | ||
|
||
@Before | ||
@SneakyThrows | ||
public void setUp() { | ||
super.setUp(); | ||
registerAgentRequestBody = Files | ||
.readString( | ||
Path | ||
.of( | ||
this | ||
.getClass() | ||
.getClassLoader() | ||
.getResource("org/opensearch/agent/tools/register_flow_agent_of_search_monitors_tool_request_body.json") | ||
.toURI() | ||
) | ||
); | ||
} | ||
|
||
@After | ||
@SneakyThrows | ||
public void tearDown() { | ||
super.tearDown(); | ||
deleteExternalIndices(); | ||
deleteSystemIndices(); | ||
} | ||
|
||
@SneakyThrows | ||
public void testSearchMonitorsToolInFlowAgent_withNoSystemIndex() { | ||
deleteSystemIndices(); | ||
String agentId = createAgent(registerAgentRequestBody); | ||
String agentInput = "{\"parameters\":{\"monitorName\": \"" + monitorName + "\"}}"; | ||
String result = executeAgent(agentId, agentInput); | ||
assertEquals("Monitors=[]TotalMonitors=0", result); | ||
} | ||
|
||
// TODO: Add IT to test against sample monitor data | ||
} |
10 changes: 10 additions & 0 deletions
10
...es/org/opensearch/agent/tools/register_flow_agent_of_search_alerts_tool_request_body.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"name": "Test_Search_Alerts_Agent", | ||
"type": "flow", | ||
"tools": [ | ||
{ | ||
"type": "SearchAlertsTool", | ||
"description": "Use this tool to search alerts." | ||
} | ||
] | ||
} |
10 changes: 10 additions & 0 deletions
10
.../org/opensearch/agent/tools/register_flow_agent_of_search_monitors_tool_request_body.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"name": "Test_Search_Monitors_Agent", | ||
"type": "flow", | ||
"tools": [ | ||
{ | ||
"type": "SearchMonitorsTool", | ||
"description": "Use this tool to search alerting monitors." | ||
} | ||
] | ||
} |