From ec1470a3d684f41246c6c80f4113ff46ebf1a198 Mon Sep 17 00:00:00 2001 From: Subhobrata Dey Date: Wed, 1 May 2024 23:55:31 +0000 Subject: [PATCH] make security-analytics integTest stable --- .../securityanalytics/findings/FindingsService.java | 1 + .../securityanalytics/findings/FindingIT.java | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/src/main/java/org/opensearch/securityanalytics/findings/FindingsService.java b/src/main/java/org/opensearch/securityanalytics/findings/FindingsService.java index af2cae9c5..bbbd655ee 100644 --- a/src/main/java/org/opensearch/securityanalytics/findings/FindingsService.java +++ b/src/main/java/org/opensearch/securityanalytics/findings/FindingsService.java @@ -151,6 +151,7 @@ public void getFindingsByMonitorIds( ActionListener listener ) { BoolQueryBuilder queryBuilder = getBoolQueryBuilder(detectionType, severity, findingIds, startTime, endTime); + log.info("hit here-" + queryBuilder.toString()); org.opensearch.commons.alerting.action.GetFindingsRequest req = new org.opensearch.commons.alerting.action.GetFindingsRequest( null, diff --git a/src/test/java/org/opensearch/securityanalytics/findings/FindingIT.java b/src/test/java/org/opensearch/securityanalytics/findings/FindingIT.java index efc874cb8..2a1c2fc85 100644 --- a/src/test/java/org/opensearch/securityanalytics/findings/FindingIT.java +++ b/src/test/java/org/opensearch/securityanalytics/findings/FindingIT.java @@ -15,6 +15,7 @@ import java.util.HashSet; import java.util.ArrayList; import java.util.Arrays; +import java.util.function.Consumer; import java.util.stream.Collectors; import org.apache.hc.core5.http.HttpHost; @@ -840,6 +841,15 @@ public void testGetFindings_byStartTimeAndEndTime_success() throws IOException { noOfSigmaRuleMatches = ((List>) ((Map) executeResults.get("input_results")).get("results")).get(0).size(); Assert.assertEquals(1, noOfSigmaRuleMatches); + request = "{\n" + + " \"query\" : {\n" + + " \"match_all\":{\n" + + " }\n" + + " }\n" + + "}"; + SearchResponse response1 = executeSearchAndGetResponse(DetectorMonitorConfig.getFindingsIndex(randomDetectorType()), request, true); + + Arrays.stream(response1.getHits().getHits()).forEach(documentFields -> logger.info("hit here-" + documentFields.getSourceAsString())); // Call GetFindings API for second detector by startTime and endTime params.clear(); params.put("startTime", String.valueOf(startTime2.toEpochMilli()));