Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix flaky ITs #332

Merged
merged 2 commits into from
Jun 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,9 @@ public void testRunWithRunningDetectorTrue() throws Exception {
ArgumentCaptor<String> responseCaptor = ArgumentCaptor.forClass(String.class);
verify(listener, times(1)).onResponse(responseCaptor.capture());
String response = responseCaptor.getValue();
assertTrue(response.contains(String.format("id=%s", detectorId)));
assertTrue(response.contains(String.format("name=%s", detectorName)));
assertTrue(response.contains(String.format("TotalAnomalyDetectors=%d", hits.length)));
assertTrue(response.contains(String.format(Locale.ROOT, "id=%s", detectorId)));
assertTrue(response.contains(String.format(Locale.ROOT, "name=%s", detectorName)));
assertTrue(response.contains(String.format(Locale.ROOT, "TotalAnomalyDetectors=%d", hits.length)));
}

@Test
Expand Down Expand Up @@ -220,9 +220,9 @@ public void testRunWithRunningDetectorUndefined() throws Exception {
ArgumentCaptor<String> responseCaptor = ArgumentCaptor.forClass(String.class);
verify(listener, times(1)).onResponse(responseCaptor.capture());
String response = responseCaptor.getValue();
assertTrue(response.contains(String.format("id=%s", detectorId)));
assertTrue(response.contains(String.format("name=%s", detectorName)));
assertTrue(response.contains(String.format("TotalAnomalyDetectors=%d", hits.length)));
assertTrue(response.contains(String.format(Locale.ROOT, "id=%s", detectorId)));
assertTrue(response.contains(String.format(Locale.ROOT, "name=%s", detectorName)));
assertTrue(response.contains(String.format(Locale.ROOT, "TotalAnomalyDetectors=%d", hits.length)));
}

@Test
Expand All @@ -248,9 +248,9 @@ public void testRunWithNullRealtimeTask() throws Exception {
ArgumentCaptor<String> responseCaptor = ArgumentCaptor.forClass(String.class);
verify(listener, times(1)).onResponse(responseCaptor.capture());
String response = responseCaptor.getValue();
assertTrue(response.contains(String.format("id=%s", detectorId)));
assertTrue(response.contains(String.format("name=%s", detectorName)));
assertTrue(response.contains(String.format("TotalAnomalyDetectors=%d", hits.length)));
assertTrue(response.contains(String.format(Locale.ROOT, "id=%s", detectorId)));
assertTrue(response.contains(String.format(Locale.ROOT, "name=%s", detectorName)));
assertTrue(response.contains(String.format(Locale.ROOT, "TotalAnomalyDetectors=%d", hits.length)));
}

@Test
Expand All @@ -275,9 +275,9 @@ public void testRunWithTaskStateCreated() throws Exception {
ArgumentCaptor<String> responseCaptor = ArgumentCaptor.forClass(String.class);
verify(listener, times(1)).onResponse(responseCaptor.capture());
String response = responseCaptor.getValue();
assertTrue(response.contains(String.format("id=%s", detectorId)));
assertTrue(response.contains(String.format("name=%s", detectorName)));
assertTrue(response.contains(String.format("TotalAnomalyDetectors=%d", hits.length)));
assertTrue(response.contains(String.format(Locale.ROOT, "id=%s", detectorId)));
assertTrue(response.contains(String.format(Locale.ROOT, "name=%s", detectorName)));
assertTrue(response.contains(String.format(Locale.ROOT, "TotalAnomalyDetectors=%d", hits.length)));
}

@Test
Expand Down Expand Up @@ -309,13 +309,13 @@ public void testRunWithTaskStateVariousFailed() throws Exception {
ArgumentCaptor<String> responseCaptor = ArgumentCaptor.forClass(String.class);
verify(listener, times(1)).onResponse(responseCaptor.capture());
String response = responseCaptor.getValue();
assertTrue(response.contains(String.format("id=%s", detectorId1)));
assertTrue(response.contains(String.format("name=%s", detectorName1)));
assertTrue(response.contains(String.format("id=%s", detectorId2)));
assertTrue(response.contains(String.format("name=%s", detectorName2)));
assertTrue(response.contains(String.format("id=%s", detectorId3)));
assertTrue(response.contains(String.format("name=%s", detectorName3)));
assertTrue(response.contains(String.format("TotalAnomalyDetectors=%d", hits.length)));
assertTrue(response.contains(String.format(Locale.ROOT, "id=%s", detectorId1)));
assertTrue(response.contains(String.format(Locale.ROOT, "name=%s", detectorName1)));
assertTrue(response.contains(String.format(Locale.ROOT, "id=%s", detectorId2)));
assertTrue(response.contains(String.format(Locale.ROOT, "name=%s", detectorName2)));
assertTrue(response.contains(String.format(Locale.ROOT, "id=%s", detectorId3)));
assertTrue(response.contains(String.format(Locale.ROOT, "name=%s", detectorName3)));
assertTrue(response.contains(String.format(Locale.ROOT, "TotalAnomalyDetectors=%d", hits.length)));
}

@Test
Expand Down Expand Up @@ -347,11 +347,11 @@ public void testRunWithCombinedDetectorStatesTrue() throws Exception {
ArgumentCaptor<String> responseCaptor = ArgumentCaptor.forClass(String.class);
verify(listener, times(1)).onResponse(responseCaptor.capture());
String response = responseCaptor.getValue();
assertTrue(response.contains(String.format("id=%s", detectorId1)));
assertTrue(response.contains(String.format("name=%s", detectorName1)));
assertTrue(response.contains(String.format("id=%s", detectorId3)));
assertTrue(response.contains(String.format("name=%s", detectorName3)));
assertTrue(response.contains(String.format("TotalAnomalyDetectors=%d", 2)));
assertTrue(response.contains(String.format(Locale.ROOT, "id=%s", detectorId1)));
assertTrue(response.contains(String.format(Locale.ROOT, "name=%s", detectorName1)));
assertTrue(response.contains(String.format(Locale.ROOT, "id=%s", detectorId3)));
assertTrue(response.contains(String.format(Locale.ROOT, "name=%s", detectorName3)));
assertTrue(response.contains(String.format(Locale.ROOT, "TotalAnomalyDetectors=%d", 2)));
}

@Test
Expand Down Expand Up @@ -414,9 +414,9 @@ public void testRunWithCombinedDetectorStatesMixed() throws Exception {
ArgumentCaptor<String> responseCaptor = ArgumentCaptor.forClass(String.class);
verify(listener, times(1)).onResponse(responseCaptor.capture());
String response = responseCaptor.getValue();
assertTrue(response.contains(String.format("id=%s", detectorId1)));
assertTrue(response.contains(String.format("name=%s", detectorName1)));
assertTrue(response.contains(String.format("TotalAnomalyDetectors=%d", 1)));
assertTrue(response.contains(String.format(Locale.ROOT, "id=%s", detectorId1)));
assertTrue(response.contains(String.format(Locale.ROOT, "name=%s", detectorName1)));
assertTrue(response.contains(String.format(Locale.ROOT, "TotalAnomalyDetectors=%d", 1)));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,10 @@ public void testSearchAnomalyResultsToolInFlowAgent_complexParams() {
+ "\"realTime\": true, \"anomalyGradeThreshold\": 0, \"sortOrder\": \"asc\","
+ "\"sortString\": \"data_start_time\", \"size\": 10, \"startIndex\": 0 }}";
String result = executeAgent(agentId, agentInput);
assertTrue(result.contains(String.format("TotalAnomalyResults=%d", 1)));
assertTrue(
String.format(Locale.ROOT, "total anomaly results is not 1, result: %s", result),
result.contains(String.format(Locale.ROOT, "TotalAnomalyResults=%d", 1))
);
}

@SneakyThrows
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Locale;

import org.junit.After;
import org.junit.Before;
Expand Down Expand Up @@ -65,7 +66,7 @@ public void testSearchMonitorsToolInFlowAgent_searchById() {
String agentId = createAgent(registerAgentRequestBody);
String agentInput = "{\"parameters\":{\"monitorId\": \"" + monitorId + "\"}}";
String result = executeAgent(agentId, agentInput);
assertTrue(result.contains(String.format("name=%s", monitorName)));
assertTrue(result.contains(String.format(Locale.ROOT, "name=%s", monitorName)));
assertTrue(result.contains("TotalMonitors=1"));
deleteMonitor(monitorId);
}
Expand All @@ -78,7 +79,7 @@ public void testSearchMonitorsToolInFlowAgent_singleMonitor_noFilter() {
String agentId = createAgent(registerAgentRequestBody);
String agentInput = "{\"parameters\":{}}";
String result = executeAgent(agentId, agentInput);
assertTrue(result.contains(String.format("name=%s", monitorName)));
assertTrue(result.contains(String.format(Locale.ROOT, "name=%s", monitorName)));
assertTrue(result.contains("TotalMonitors=1"));
deleteMonitor(monitorId);
}
Expand All @@ -101,8 +102,8 @@ public void testSearchMonitorsToolInFlowAgent_multipleMonitors_noFilter() {
String agentId = createAgent(registerAgentRequestBody);
String agentInput = "{\"parameters\":{}}";
String result = executeAgent(agentId, agentInput);
assertTrue(result.contains(String.format("name=%s", monitorName)));
assertTrue(result.contains(String.format("name=%s", monitorName2)));
assertTrue(result.contains(String.format(Locale.ROOT, "name=%s", monitorName)));
assertTrue(result.contains(String.format(Locale.ROOT, "name=%s", monitorName2)));
assertTrue(result.contains("enabled=true"));
assertTrue(result.contains("enabled=false"));
assertTrue(result.contains("TotalMonitors=2"));
Expand All @@ -119,8 +120,8 @@ public void testSearchMonitorsToolInFlowAgent_multipleMonitors_filter() {
String agentId = createAgent(registerAgentRequestBody);
String agentInput = "{\"parameters\":{\"monitorName\": \"" + monitorName + "\"}}";
String result = executeAgent(agentId, agentInput);
assertTrue(result.contains(String.format("name=%s", monitorName)));
assertFalse(result.contains(String.format("name=%s", monitorName2)));
assertTrue(result.contains(String.format(Locale.ROOT, "name=%s", monitorName)));
assertFalse(result.contains(String.format(Locale.ROOT, "name=%s", monitorName2)));
assertTrue(result.contains("enabled=true"));
assertTrue(result.contains("TotalMonitors=1"));
deleteMonitor(monitorId1);
Expand Down
Loading