From 24a7e51fc1b7a3982030ce17f494ab1da2f54fb4 Mon Sep 17 00:00:00 2001 From: Surya Sashank Nistala Date: Fri, 20 Oct 2023 17:26:37 -0700 Subject: [PATCH] fix timeout of tif job creation Signed-off-by: Surya Sashank Nistala --- .../ThreatIntelFeedDataService.java | 18 +++++++++++++++++- .../resthandler/DetectorMonitorRestApiIT.java | 2 +- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/opensearch/securityanalytics/threatIntel/ThreatIntelFeedDataService.java b/src/main/java/org/opensearch/securityanalytics/threatIntel/ThreatIntelFeedDataService.java index 25f9de69d..6e22a6b8a 100644 --- a/src/main/java/org/opensearch/securityanalytics/threatIntel/ThreatIntelFeedDataService.java +++ b/src/main/java/org/opensearch/securityanalytics/threatIntel/ThreatIntelFeedDataService.java @@ -255,7 +255,23 @@ public void deleteThreatIntelDataIndex(final List indices) { private void createThreatIntelFeedData() throws InterruptedException { CountDownLatch countDownLatch = new CountDownLatch(1); - client.execute(PutTIFJobAction.INSTANCE, new PutTIFJobRequest("feed_updater", clusterSettings.get(SecurityAnalyticsSettings.TIF_UPDATE_INTERVAL))).actionGet(); + client.execute( + PutTIFJobAction.INSTANCE, + new PutTIFJobRequest("feed_updater", clusterSettings.get(SecurityAnalyticsSettings.TIF_UPDATE_INTERVAL)), + new ActionListener() { + @Override + public void onResponse(AcknowledgedResponse acknowledgedResponse) { + log.debug("Acknowledged threat intel feed updater job created"); + countDownLatch.countDown(); + } + + @Override + public void onFailure(Exception e) { + log.debug("Failed to create threat intel feed updater job", e); + countDownLatch.countDown(); + } + } + ); countDownLatch.await(); } diff --git a/src/test/java/org/opensearch/securityanalytics/resthandler/DetectorMonitorRestApiIT.java b/src/test/java/org/opensearch/securityanalytics/resthandler/DetectorMonitorRestApiIT.java index 50f2bf889..61634ab46 100644 --- a/src/test/java/org/opensearch/securityanalytics/resthandler/DetectorMonitorRestApiIT.java +++ b/src/test/java/org/opensearch/securityanalytics/resthandler/DetectorMonitorRestApiIT.java @@ -1121,7 +1121,7 @@ public void testCreateDetectorWithThreatIntelEnabled_updateDetectorWithThreatInt List iocs = getThreatIntelFeedIocs(3); int i=1; for (String ioc : iocs) { - indexDoc(index, i+"", randomDocWithIpIoc(5, 3, i==1? "120.85.114.146" : "120.86.237.94")); + indexDoc(index, i + "", randomDocWithIpIoc(5, 3, ioc)); i++; } String workflowId = ((List) detectorMap.get("workflow_ids")).get(0);