Skip to content

Commit

Permalink
add delays for flaky behavior
Browse files Browse the repository at this point in the history
Signed-off-by: Subhobrata Dey <[email protected]>
  • Loading branch information
sbcd90 committed Jul 11, 2023
1 parent b9f3a1e commit 48d43d9
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
public class CorrelationEngineRestApiIT extends SecurityAnalyticsRestTestCase {

@SuppressWarnings("unchecked")
public void testBasicCorrelationEngineWorkflow() throws IOException {
public void testBasicCorrelationEngineWorkflow() throws IOException, InterruptedException {
LogIndices indices = createIndices();

String vpcFlowMonitorId = createVpcFlowDetector(indices.vpcFlowsIndex);
Expand Down Expand Up @@ -71,6 +71,7 @@ public void testBasicCorrelationEngineWorkflow() throws IOException {
executeResults = entityAsMap(executeResponse);
noOfSigmaRuleMatches = ((List<Map<String, Object>>) ((Map<String, Object>) executeResults.get("input_results")).get("results")).get(0).size();
Assert.assertEquals(1, noOfSigmaRuleMatches);
Thread.sleep(5000);

// Call GetFindings API
Map<String, String> params = new HashMap<>();
Expand Down Expand Up @@ -100,23 +101,23 @@ public void testListCorrelationsWorkflow() throws IOException, InterruptedExcept
String testWindowsMonitorId = createTestWindowsDetector(indices.windowsIndex);

createNetworkToAdLdapToWindowsRule(indices);
Thread.sleep(30000);
Thread.sleep(5000);

indexDoc(indices.windowsIndex, "2", randomDoc());
Response executeResponse = executeAlertingMonitor(testWindowsMonitorId, Collections.emptyMap());
Map<String, Object> executeResults = entityAsMap(executeResponse);
int noOfSigmaRuleMatches = ((List<Map<String, Object>>) ((Map<String, Object>) executeResults.get("input_results")).get("results")).get(0).size();
Assert.assertEquals(5, noOfSigmaRuleMatches);

Thread.sleep(30000);
Thread.sleep(5000);

indexDoc(indices.vpcFlowsIndex, "1", randomVpcFlowDoc());
executeResponse = executeAlertingMonitor(vpcFlowMonitorId, Collections.emptyMap());
executeResults = entityAsMap(executeResponse);
noOfSigmaRuleMatches = ((List<Map<String, Object>>) ((Map<String, Object>) executeResults.get("input_results")).get("results")).get(0).size();
Assert.assertEquals(1, noOfSigmaRuleMatches);

Thread.sleep(30000);
Thread.sleep(5000);
Long endTime = System.currentTimeMillis();

Request request = new Request("GET", "/_plugins/_security_analytics/correlations?start_timestamp=" + startTime + "&end_timestamp=" + endTime);
Expand Down

0 comments on commit 48d43d9

Please sign in to comment.