Skip to content

Commit 62ac87f

Browse files
authored
Fix build error due to upstream change (#316)
* fix build error due to upstream change Signed-off-by: Hailong Cui <[email protected]> * failed unit test Signed-off-by: Hailong Cui <[email protected]> * fix compile error Signed-off-by: Hailong Cui <[email protected]> * fix flaky test for locale mr Signed-off-by: Hailong Cui <[email protected]> * force to use x86_64 for macos Signed-off-by: Hailong Cui <[email protected]> --------- Signed-off-by: Hailong Cui <[email protected]>
1 parent 05def20 commit 62ac87f

File tree

7 files changed

+36
-27
lines changed

7 files changed

+36
-27
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ jobs:
8989
export FC=/usr/local/Cellar/gcc/12.2.0/bin/gfortran
9090
- name: Run build
9191
run: |
92-
./gradlew build
92+
./gradlew build -Dos.arch=x86_64
9393
9494
build-windows:
9595
strategy:

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ dependencies {
126126
// Plugin dependencies
127127
compileOnly group: 'org.opensearch', name:'opensearch-ml-client', version: "${opensearch_build}"
128128
implementation fileTree(dir: jsJarDirectory, include: ["opensearch-job-scheduler-${opensearch_build}.jar"])
129-
implementation fileTree(dir: adJarDirectory, include: ["opensearch-time-series-analytics-${opensearch_build}.jar"])
129+
implementation fileTree(dir: adJarDirectory, include: ["opensearch-anomaly-detection-${opensearch_build}.jar"])
130130
implementation fileTree(dir: sqlJarDirectory, include: ["opensearch-sql-${opensearch_build}.jar", "ppl-${opensearch_build}.jar", "protocol-${opensearch_build}.jar"])
131131
compileOnly "org.opensearch:common-utils:${opensearch_build}"
132132
compileOnly "org.jetbrains.kotlin:kotlin-stdlib:${kotlin_version}"

src/main/java/org/opensearch/agent/tools/SearchAlertsTool.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,8 @@ public <T> void run(Map<String, String> parameters, ActionListener<T> listener)
104104
alertIndex,
105105
monitorIds,
106106
workflowIds,
107-
alertIds
107+
alertIds,
108+
null
108109
);
109110

110111
// create response listener

src/main/java/org/opensearch/agent/tools/SearchAnomalyDetectorsTool.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
import org.opensearch.action.search.SearchResponse;
2121
import org.opensearch.ad.client.AnomalyDetectionNodeClient;
2222
import org.opensearch.ad.model.ADTask;
23-
import org.opensearch.ad.transport.GetAnomalyDetectorRequest;
2423
import org.opensearch.ad.transport.GetAnomalyDetectorResponse;
2524
import org.opensearch.agent.tools.utils.ToolConstants;
2625
import org.opensearch.agent.tools.utils.ToolConstants.DetectorStateString;
@@ -41,6 +40,7 @@
4140
import org.opensearch.search.SearchHit;
4241
import org.opensearch.search.builder.SearchSourceBuilder;
4342
import org.opensearch.search.sort.SortOrder;
43+
import org.opensearch.timeseries.transport.GetConfigRequest;
4444

4545
import lombok.Getter;
4646
import lombok.Setter;
@@ -164,7 +164,7 @@ public <T> void run(Map<String, String> parameters, ActionListener<T> listener)
164164
listener.onFailure(e);
165165
});
166166

167-
GetAnomalyDetectorRequest profileRequest = new GetAnomalyDetectorRequest(
167+
GetConfigRequest profileRequest = new GetConfigRequest(
168168
hit.getId(),
169169
Versions.MATCH_ANY,
170170
false,

src/test/java/org/opensearch/agent/tools/SearchAnomalyDetectorsToolTests.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,13 @@ public void setup() {
8686
Collections.emptyList(),
8787
null,
8888
null,
89+
null,
90+
null,
91+
null,
92+
null,
93+
null,
94+
null,
95+
null,
8996
null
9097
);
9198
}

src/test/java/org/opensearch/agent/tools/SearchMonitorsToolTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public void setup() {
8181
new CronSchedule("31 * * * *", ZoneId.of("Asia/Kolkata"), null),
8282
Instant.now(),
8383
Instant.now(),
84-
Monitor.MonitorType.QUERY_LEVEL_MONITOR,
84+
Monitor.MonitorType.QUERY_LEVEL_MONITOR.getValue(),
8585
new User("test-user", Collections.emptyList(), Collections.emptyList(), Collections.emptyList()),
8686
0,
8787
Collections.emptyList(),

src/test/java/org/opensearch/integTest/SearchAnomalyDetectorsToolIT.java

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import java.nio.file.Files;
99
import java.nio.file.Path;
1010
import java.util.List;
11+
import java.util.Locale;
1112

1213
import org.junit.After;
1314
import org.junit.Before;
@@ -71,9 +72,9 @@ public void testSearchAnomalyDetectorsToolInFlowAgent_detectorNameParam() {
7172

7273
String agentInput2 = "{\"parameters\":{\"detectorName\": \"" + detectorName + "\"}}";
7374
String result2 = executeAgent(agentId, agentInput2);
74-
assertTrue(result2.contains(String.format("id=%s", detectorId)));
75-
assertTrue(result2.contains(String.format("name=%s", detectorName)));
76-
assertTrue(result2.contains(String.format("TotalAnomalyDetectors=%d", 1)));
75+
assertTrue(result2.contains(String.format(Locale.ROOT, "id=%s", detectorId)));
76+
assertTrue(result2.contains(String.format(Locale.ROOT, "name=%s", detectorName)));
77+
assertTrue(result2.contains(String.format(Locale.ROOT, "TotalAnomalyDetectors=%d", 1)));
7778
} finally {
7879
if (detectorId != null) {
7980
deleteDetector(detectorId);
@@ -95,9 +96,9 @@ public void testSearchAnomalyDetectorsToolInFlowAgent_detectorNamePatternParam()
9596

9697
String agentInput2 = "{\"parameters\":{\"detectorNamePattern\": \"" + detectorName + "*" + "\"}}";
9798
String result2 = executeAgent(agentId, agentInput2);
98-
assertTrue(result2.contains(String.format("id=%s", detectorId)));
99-
assertTrue(result2.contains(String.format("name=%s", detectorName)));
100-
assertTrue(result2.contains(String.format("TotalAnomalyDetectors=%d", 1)));
99+
assertTrue(result2.contains(String.format(Locale.ROOT, "id=%s", detectorId)));
100+
assertTrue(result2.contains(String.format(Locale.ROOT, "name=%s", detectorName)));
101+
assertTrue(result2.contains(String.format(Locale.ROOT, "TotalAnomalyDetectors=%d", 1)));
101102
} finally {
102103
if (detectorId != null) {
103104
deleteDetector(detectorId);
@@ -120,7 +121,7 @@ public void testSearchAnomalyDetectorsToolInFlowAgent_indicesParam() {
120121

121122
String agentInput2 = "{\"parameters\":{\"indices\": \"test-index\"}}";
122123
String result2 = executeAgent(agentId, agentInput2);
123-
assertTrue(result2.contains(String.format("TotalAnomalyDetectors=%d", 1)));
124+
assertTrue(result2.contains(String.format(Locale.ROOT, "TotalAnomalyDetectors=%d", 1)));
124125
} finally {
125126
if (detectorId != null) {
126127
deleteDetector(detectorId);
@@ -143,9 +144,9 @@ public void testSearchAnomalyDetectorsToolInFlowAgent_highCardinalityParam() {
143144

144145
String agentInput2 = "{\"parameters\":{\"highCardinality\": \"false\"}}";
145146
String result2 = executeAgent(agentId, agentInput2);
146-
assertTrue(result2.contains(String.format("id=%s", detectorId)));
147-
assertTrue(result2.contains(String.format("name=%s", detectorName)));
148-
assertTrue(result2.contains(String.format("TotalAnomalyDetectors=%d", 1)));
147+
assertTrue(result2.contains(String.format(Locale.ROOT, "id=%s", detectorId)));
148+
assertTrue(result2.contains(String.format(Locale.ROOT, "name=%s", detectorName)));
149+
assertTrue(result2.contains(String.format(Locale.ROOT, "TotalAnomalyDetectors=%d", 1)));
149150
} finally {
150151
if (detectorId != null) {
151152
deleteDetector(detectorId);
@@ -172,45 +173,45 @@ public void testSearchAnomalyDetectorsToolInFlowAgent_detectorStateParams() {
172173
String agentId = createAgent(registerAgentRequestBody);
173174
String agentInput = "{\"parameters\":{\"running\": \"true\"}}";
174175
String result = executeAgent(agentId, agentInput);
175-
assertTrue(result.contains(String.format("TotalAnomalyDetectors=%d", 1)));
176+
assertTrue(result.contains(String.format(Locale.ROOT, "TotalAnomalyDetectors=%d", 1)));
176177
assertTrue(result.contains(detectorIdRunning));
177178

178179
String agentInput2 = "{\"parameters\":{\"running\": \"false\"}}";
179180
String result2 = executeAgent(agentId, agentInput2);
180-
assertTrue(result2.contains(String.format("TotalAnomalyDetectors=%d", 2)));
181+
assertTrue(result2.contains(String.format(Locale.ROOT, "TotalAnomalyDetectors=%d", 2)));
181182
assertTrue(result2.contains(detectorIdDisabled1));
182183
assertTrue(result2.contains(detectorIdDisabled2));
183184

184185
String agentInput3 = "{\"parameters\":{\"failed\": \"true\"}}";
185186
String result3 = executeAgent(agentId, agentInput3);
186-
assertTrue(result3.contains(String.format("TotalAnomalyDetectors=%d", 0)));
187+
assertTrue(result3.contains(String.format(Locale.ROOT, "TotalAnomalyDetectors=%d", 0)));
187188

188189
String agentInput4 = "{\"parameters\":{\"failed\": \"false\"}}";
189190
String result4 = executeAgent(agentId, agentInput4);
190-
assertTrue(result4.contains(String.format("TotalAnomalyDetectors=%d", 3)));
191+
assertTrue(result4.contains(String.format(Locale.ROOT, "TotalAnomalyDetectors=%d", 3)));
191192
assertTrue(result4.contains(detectorIdRunning));
192193
assertTrue(result4.contains(detectorIdDisabled1));
193194
assertTrue(result4.contains(detectorIdDisabled2));
194195

195196
String agentInput5 = "{\"parameters\":{\"running\": \"true\", \"failed\": \"true\"}}";
196197
String result5 = executeAgent(agentId, agentInput5);
197-
assertTrue(result5.contains(String.format("TotalAnomalyDetectors=%d", 1)));
198+
assertTrue(result5.contains(String.format(Locale.ROOT, "TotalAnomalyDetectors=%d", 1)));
198199
assertTrue(result5.contains(detectorIdRunning));
199200

200201
String agentInput6 = "{\"parameters\":{\"running\": \"true\", \"failed\": \"false\"}}";
201202
String result6 = executeAgent(agentId, agentInput6);
202-
assertTrue(result6.contains(String.format("TotalAnomalyDetectors=%d", 1)));
203+
assertTrue(result6.contains(String.format(Locale.ROOT, "TotalAnomalyDetectors=%d", 1)));
203204
assertTrue(result6.contains(detectorIdRunning));
204205

205206
String agentInput7 = "{\"parameters\":{\"running\": \"false\", \"failed\": \"true\"}}";
206207
String result7 = executeAgent(agentId, agentInput7);
207-
assertTrue(result7.contains(String.format("TotalAnomalyDetectors=%d", 2)));
208+
assertTrue(result7.contains(String.format(Locale.ROOT, "TotalAnomalyDetectors=%d", 2)));
208209
assertTrue(result7.contains(detectorIdDisabled1));
209210
assertTrue(result7.contains(detectorIdDisabled2));
210211

211212
String agentInput8 = "{\"parameters\":{\"running\": \"false\", \"failed\": \"false\"}}";
212213
String result8 = executeAgent(agentId, agentInput8);
213-
assertTrue(result8.contains(String.format("TotalAnomalyDetectors=%d", 2)));
214+
assertTrue(result8.contains(String.format(Locale.ROOT, "TotalAnomalyDetectors=%d", 2)));
214215
assertTrue(result8.contains(detectorIdDisabled1));
215216
assertTrue(result8.contains(detectorIdDisabled2));
216217
} finally {
@@ -243,9 +244,9 @@ public void testSearchAnomalyDetectorsToolInFlowAgent_complexParams() {
243244
+ detectorName
244245
+ "\", \"highCardinality\": false, \"sortOrder\": \"asc\", \"sortString\": \"name.keyword\", \"size\": 10, \"startIndex\": 0 }}";
245246
String result = executeAgent(agentId, agentInput);
246-
assertTrue(result.contains(String.format("id=%s", detectorId)));
247-
assertTrue(result.contains(String.format("name=%s", detectorName)));
248-
assertTrue(result.contains(String.format("TotalAnomalyDetectors=%d", 1)));
247+
assertTrue(result.contains(String.format(Locale.ROOT, "id=%s", detectorId)));
248+
assertTrue(result.contains(String.format(Locale.ROOT, "name=%s", detectorName)));
249+
assertTrue(result.contains(String.format(Locale.ROOT, "TotalAnomalyDetectors=%d", 1)));
249250
} finally {
250251
if (detectorId != null) {
251252
deleteDetector(detectorId);

0 commit comments

Comments
 (0)