Skip to content

Commit

Permalink
pass integ tests (#1082) (#1084)
Browse files Browse the repository at this point in the history
Signed-off-by: Subhobrata Dey <[email protected]>
  • Loading branch information
opensearch-trigger-bot[bot] authored Jun 19, 2024
1 parent 41bd0c0 commit c0de31a
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1579,8 +1579,8 @@ protected void createNetflowLogIndex(String indexName) throws IOException {
Response response = client().performRequest(indexRequest);
assertEquals(HttpStatus.SC_CREATED, response.getStatusLine().getStatusCode());
// Refresh everything
response = client().performRequest(new Request("POST", "_refresh"));
assertEquals(HttpStatus.SC_OK, response.getStatusLine().getStatusCode());
//response = client().performRequest(new Request("POST", "_refresh"));
//assertEquals(HttpStatus.SC_OK, response.getStatusLine().getStatusCode());
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ public void testAckAlerts_WithInvalidDetectorAlertsCombination() throws IOExcept

indexDoc(index, "1", randomDoc());

client().performRequest(new Request("POST", "_refresh"));
// client().performRequest(new Request("POST", "_refresh"));

Response executeResponse = null;

Expand Down Expand Up @@ -565,7 +565,7 @@ public void testGetAlerts_byDetectorType_success() throws IOException, Interrupt

indexDoc(index, "1", randomDoc());

client().performRequest(new Request("POST", "_refresh"));
// client().performRequest(new Request("POST", "_refresh"));

Response executeResponse = executeAlertingMonitor(monitorId, Collections.emptyMap());
Map<String, Object> executeResults = entityAsMap(executeResponse);
Expand Down Expand Up @@ -681,7 +681,7 @@ public void testGetAlerts_byDetectorType_multipleDetectors_success() throws IOEx
noOfSigmaRuleMatches = ((List<Map<String, Object>>) ((Map<String, Object>) executeResults.get("input_results")).get("results")).get(0).size();
Assert.assertEquals(1, noOfSigmaRuleMatches);

client().performRequest(new Request("POST", "_refresh"));
// client().performRequest(new Request("POST", "_refresh"));

request = "{\n" +
" \"query\" : {\n" +
Expand All @@ -699,7 +699,7 @@ public void testGetAlerts_byDetectorType_multipleDetectors_success() throws IOEx
hits = executeSearch(DetectorMonitorConfig.getAlertsIndex("network"), request);
}

client().performRequest(new Request("POST", "_refresh"));
// client().performRequest(new Request("POST", "_refresh"));

// Call GetAlerts API for WINDOWS detector
Map<String, String> params = new HashMap<>();
Expand Down Expand Up @@ -1080,7 +1080,7 @@ public void testAlertHistoryRollover_maxDocs() throws IOException, InterruptedEx

indexDoc(index, "1", randomDoc());

client().performRequest(new Request("POST", "_refresh"));
// client().performRequest(new Request("POST", "_refresh"));

Response executeResponse = executeAlertingMonitor(monitorId, Collections.emptyMap());
Map<String, Object> executeResults = entityAsMap(executeResponse);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ public void testGetAlerts_byDetectorType_success() throws IOException, Interrupt

indexDoc(index, "1", randomDoc());

client().performRequest(new Request("POST", "_refresh"));
// client().performRequest(new Request("POST", "_refresh"));

Response executeResponse = executeAlertingMonitor(monitorId, Collections.emptyMap());
Map<String, Object> executeResults = entityAsMap(executeResponse);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ public void testGetFindings_byDetectorType_success() throws IOException {
noOfSigmaRuleMatches = ((List<Map<String, Object>>) ((Map<String, Object>) executeResults.get("input_results")).get("results")).get(0).size();
Assert.assertEquals(1, noOfSigmaRuleMatches);

client().performRequest(new Request("POST", "_refresh"));
// client().performRequest(new Request("POST", "_refresh"));

// Call GetFindings API for first detector
Map<String, String> params = new HashMap<>();
Expand Down Expand Up @@ -375,7 +375,7 @@ public void testGetAllFindings_success() throws IOException {
noOfSigmaRuleMatches = ((List<Map<String, Object>>) ((Map<String, Object>) executeResults.get("input_results")).get("results")).get(0).size();
// Assert.assertEquals(1, noOfSigmaRuleMatches);

client().performRequest(new Request("POST", "_refresh"));
// client().performRequest(new Request("POST", "_refresh"));

// Call GetFindings API for all the detectors
Map<String, String> params = new HashMap<>();
Expand Down Expand Up @@ -594,7 +594,7 @@ public void testGetFindings_bySeverity_success() throws IOException {
noOfSigmaRuleMatches = ((List<Map<String, Object>>) ((Map<String, Object>) executeResults.get("input_results")).get("results")).get(0).size();
Assert.assertEquals(1, noOfSigmaRuleMatches);

client().performRequest(new Request("POST", "_refresh"));
// client().performRequest(new Request("POST", "_refresh"));

// Call GetFindings API for first detector by severity
Map<String, String> params = new HashMap<>();
Expand Down Expand Up @@ -715,7 +715,7 @@ public void testGetFindings_bySearchString_success() throws IOException {
noOfSigmaRuleMatches = ((List<Map<String, Object>>) ((Map<String, Object>) executeResults.get("input_results")).get("results")).get(0).size();
Assert.assertEquals(1, noOfSigmaRuleMatches);

client().performRequest(new Request("POST", "_refresh"));
// client().performRequest(new Request("POST", "_refresh"));

// Call GetFindings API for first detector by searchString 'high'
Map<String, String> params = new HashMap<>();
Expand Down Expand Up @@ -831,7 +831,7 @@ public void testGetFindings_byStartTimeAndEndTime_success() throws IOException {
int noOfSigmaRuleMatches = ((List<Map<String, Object>>) ((Map<String, Object>) executeResults.get("input_results")).get("results")).get(0).size();
Assert.assertEquals(1, noOfSigmaRuleMatches);

client().performRequest(new Request("POST", "_refresh"));
// client().performRequest(new Request("POST", "_refresh"));
// Call GetFindings API for first detector by startTime and endTime
Map<String, String> params = new HashMap<>();
params.put("startTime", String.valueOf(startTime1.toEpochMilli()));
Expand All @@ -842,7 +842,7 @@ public void testGetFindings_byStartTimeAndEndTime_success() throws IOException {
Map<String, Object> getFindingsBody = entityAsMap(getFindingsResponse);
Assert.assertEquals(1, getFindingsBody.get("total_findings"));

client().performRequest(new Request("POST", "_refresh"));
// client().performRequest(new Request("POST", "_refresh"));
Instant startTime2 = Instant.now();
// execute monitor 2
executeResponse = executeAlertingMonitor(monitorId2, Collections.emptyMap());
Expand Down Expand Up @@ -1343,7 +1343,7 @@ public void testGetFindings_rolloverByMaxDoc_short_retention_success() throws IO
// Call GetFindings API
Map<String, String> params = new HashMap<>();
params.put("detector_id", detectorId);
client().performRequest(new Request("POST", "_refresh"));
// client().performRequest(new Request("POST", "_refresh"));
Response getFindingsResponse = makeRequest(client(), "GET", SecurityAnalyticsPlugin.FINDINGS_BASE_URI + "/_search", params, null);
Map<String, Object> getFindingsBody = entityAsMap(getFindingsResponse);
Assert.assertEquals(1, getFindingsBody.get("total_findings"));
Expand Down Expand Up @@ -1372,7 +1372,7 @@ public void testGetFindings_rolloverByMaxDoc_short_retention_success() throws IO

noOfSigmaRuleMatches = ((List<Map<String, Object>>) ((Map<String, Object>) executeResults.get("input_results")).get("results")).get(0).size();
Assert.assertEquals(5, noOfSigmaRuleMatches);
client().performRequest(new Request("POST", "_refresh"));
// client().performRequest(new Request("POST", "_refresh"));
getFindingsResponse = makeRequest(client(), "GET", SecurityAnalyticsPlugin.FINDINGS_BASE_URI + "/_search", params, null);
getFindingsBody = entityAsMap(getFindingsResponse);
Assert.assertEquals(1, getFindingsBody.get("total_findings"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ public void testGetFindings_byDetectorType_success() throws IOException {
noOfSigmaRuleMatches = ((List<Map<String, Object>>) ((Map<String, Object>) executeResults.get("input_results")).get("results")).get(0).size();
Assert.assertEquals(5, noOfSigmaRuleMatches);

client().performRequest(new Request("POST", "_refresh"));
// client().performRequest(new Request("POST", "_refresh"));


// try to do get finding as a user with read access
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -722,7 +722,7 @@ public void testCreateMappings_withIndexPattern_differentMappings_indexTemplateC
createIndex(indexName1, Settings.EMPTY, null);
createIndex(indexName2, Settings.EMPTY, null);

client().performRequest(new Request("POST", "_refresh"));
// client().performRequest(new Request("POST", "_refresh"));

// Insert sample docs
String sampleDoc1 = "{" +
Expand All @@ -737,7 +737,7 @@ public void testCreateMappings_withIndexPattern_differentMappings_indexTemplateC
indexDoc(indexName1, "1", sampleDoc1);
indexDoc(indexName2, "1", sampleDoc2);

client().performRequest(new Request("POST", "_refresh"));
// client().performRequest(new Request("POST", "_refresh"));

// Execute CreateMappingsAction to add alias mapping for index
createMappingsAPI(indexPattern, "netflow");
Expand Down Expand Up @@ -800,7 +800,7 @@ public void testCreateMappings_withIndexPattern_indexTemplate_createAndUpdate_su
createIndex(indexName1, Settings.EMPTY, null);
createIndex(indexName2, Settings.EMPTY, null);

client().performRequest(new Request("POST", "_refresh"));
// client().performRequest(new Request("POST", "_refresh"));

// Insert sample doc
String sampleDoc1 = "{" +
Expand All @@ -811,7 +811,7 @@ public void testCreateMappings_withIndexPattern_indexTemplate_createAndUpdate_su
indexDoc(indexName1, "1", sampleDoc1);
indexDoc(indexName2, "1", sampleDoc1);

client().performRequest(new Request("POST", "_refresh"));
// client().performRequest(new Request("POST", "_refresh"));

// Execute CreateMappingsAction to add alias mapping for index
createMappingsAPI(indexPattern, "netflow");
Expand Down Expand Up @@ -887,7 +887,7 @@ public void testCreateMappings_withIndexPattern_oneNoMappings_failure() throws I
createIndex(indexName1, Settings.EMPTY, null);
createIndex(indexName2, Settings.EMPTY, null);

client().performRequest(new Request("POST", "_refresh"));
// client().performRequest(new Request("POST", "_refresh"));

// Insert sample docs
String sampleDoc1 = "{" +
Expand All @@ -897,7 +897,7 @@ public void testCreateMappings_withIndexPattern_oneNoMappings_failure() throws I
"}";
indexDoc(indexName1, "1", sampleDoc1);

client().performRequest(new Request("POST", "_refresh"));
// client().performRequest(new Request("POST", "_refresh"));

// Execute CreateMappingsAction to add alias mapping for index
try {
Expand Down Expand Up @@ -1111,7 +1111,7 @@ public void testCreateMappings_withIndexPattern_success() throws IOException {
createIndex(indexName1, Settings.EMPTY, null);
createIndex(indexName2, Settings.EMPTY, null);

client().performRequest(new Request("POST", "_refresh"));
// client().performRequest(new Request("POST", "_refresh"));

// Insert sample doc
String sampleDoc = "{" +
Expand All @@ -1124,7 +1124,7 @@ public void testCreateMappings_withIndexPattern_success() throws IOException {
indexDoc(indexName1, "1", sampleDoc);
indexDoc(indexName2, "1", sampleDoc);

client().performRequest(new Request("POST", "_refresh"));
// client().performRequest(new Request("POST", "_refresh"));

// Execute CreateMappingsAction to add alias mapping for index
Request request = new Request("POST", SecurityAnalyticsPlugin.MAPPER_BASE_URI);
Expand All @@ -1150,7 +1150,7 @@ public void testCreateMappings_withIndexPattern_conflictingTemplates_success() t
createIndex(indexName1, Settings.EMPTY, null);
createIndex(indexName2, Settings.EMPTY, null);

client().performRequest(new Request("POST", "_refresh"));
// client().performRequest(new Request("POST", "_refresh"));

// Insert sample doc
String sampleDoc = "{" +
Expand All @@ -1161,7 +1161,7 @@ public void testCreateMappings_withIndexPattern_conflictingTemplates_success() t
indexDoc(indexName1, "1", sampleDoc);
indexDoc(indexName2, "1", sampleDoc);

client().performRequest(new Request("POST", "_refresh"));
// client().performRequest(new Request("POST", "_refresh"));

// Execute CreateMappingsAction with first index pattern
createMappingsAPI(indexPattern1, "netflow");
Expand Down Expand Up @@ -1205,7 +1205,7 @@ public void testCreateMappings_withIndexPattern_conflictingTemplates_failure_1()
createIndex(indexName1, Settings.EMPTY, null);
createIndex(indexName2, Settings.EMPTY, null);

client().performRequest(new Request("POST", "_refresh"));
// client().performRequest(new Request("POST", "_refresh"));

// Insert sample doc
String sampleDoc = "{" +
Expand All @@ -1216,7 +1216,7 @@ public void testCreateMappings_withIndexPattern_conflictingTemplates_failure_1()
indexDoc(indexName1, "1", sampleDoc);
indexDoc(indexName2, "1", sampleDoc);

client().performRequest(new Request("POST", "_refresh"));
// client().performRequest(new Request("POST", "_refresh"));

// Execute CreateMappingsAction with first index pattern
createMappingsAPI(indexPattern1, "netflow");
Expand Down Expand Up @@ -1244,7 +1244,7 @@ public void testCreateMappings_withIndexPattern_conflictingTemplates_failure_2()
createIndex(indexName1, Settings.EMPTY, null);
createIndex(indexName2, Settings.EMPTY, null);

client().performRequest(new Request("POST", "_refresh"));
// client().performRequest(new Request("POST", "_refresh"));

// Insert sample doc
String sampleDoc = "{" +
Expand All @@ -1255,7 +1255,7 @@ public void testCreateMappings_withIndexPattern_conflictingTemplates_failure_2()
indexDoc(indexName1, "1", sampleDoc);
indexDoc(indexName2, "1", sampleDoc);

client().performRequest(new Request("POST", "_refresh"));
// client().performRequest(new Request("POST", "_refresh"));


// User-create template with conflicting pattern but higher priority
Expand All @@ -1279,7 +1279,7 @@ public void testCreateMappings_withIndexPattern_oneNoMatches_success() throws IO
createIndex(indexName1, Settings.EMPTY, null);
createIndex(indexName2, Settings.EMPTY, null);

client().performRequest(new Request("POST", "_refresh"));
// client().performRequest(new Request("POST", "_refresh"));

// Insert sample docs
String sampleDoc1 = "{" +
Expand All @@ -1294,7 +1294,7 @@ public void testCreateMappings_withIndexPattern_oneNoMatches_success() throws IO
indexDoc(indexName1, "1", sampleDoc1);
indexDoc(indexName2, "1", sampleDoc2);

client().performRequest(new Request("POST", "_refresh"));
// client().performRequest(new Request("POST", "_refresh"));

// Execute CreateMappingsAction to add alias mapping for index
Request request = new Request("POST", SecurityAnalyticsPlugin.MAPPER_BASE_URI);
Expand Down Expand Up @@ -1381,8 +1381,8 @@ private void createSampleIndex(String indexName, Settings settings, String alias
Response response = client().performRequest(indexRequest);
assertEquals(HttpStatus.SC_CREATED, response.getStatusLine().getStatusCode());
// Refresh everything
response = client().performRequest(new Request("POST", "_refresh"));
assertEquals(HttpStatus.SC_OK, response.getStatusLine().getStatusCode());
//response = client().performRequest(new Request("POST", "_refresh"));
//assertEquals(HttpStatus.SC_OK, response.getStatusLine().getStatusCode());
}

private void createSampleWindex(String indexName) throws IOException {
Expand Down Expand Up @@ -1444,8 +1444,8 @@ private void createSampleWindex(String indexName, Settings settings, String alia
Response response = client().performRequest(indexRequest);
assertEquals(HttpStatus.SC_CREATED, response.getStatusLine().getStatusCode());
// Refresh everything
response = client().performRequest(new Request("POST", "_refresh"));
assertEquals(HttpStatus.SC_OK, response.getStatusLine().getStatusCode());
//response = client().performRequest(new Request("POST", "_refresh"));
//assertEquals(HttpStatus.SC_OK, response.getStatusLine().getStatusCode());
}

private void createSampleDatastream(String datastreamName) throws IOException {
Expand Down Expand Up @@ -1533,8 +1533,8 @@ private void createSampleDatastream(String datastreamName) throws IOException {
response = client().performRequest(indexRequest);
assertEquals(HttpStatus.SC_CREATED, response.getStatusLine().getStatusCode());
// Refresh everything
response = client().performRequest(new Request("POST", "_refresh"));
assertEquals(HttpStatus.SC_OK, response.getStatusLine().getStatusCode());
//response = client().performRequest(new Request("POST", "_refresh"));
//assertEquals(HttpStatus.SC_OK, response.getStatusLine().getStatusCode());
}

private void deleteDatastream(String datastreamName) throws IOException {
Expand Down Expand Up @@ -1613,8 +1613,8 @@ public void testCreateDNSMapping() throws IOException{
});

// Refresh everything
response = client().performRequest(new Request("POST", "_refresh"));
assertEquals(HttpStatus.SC_OK, response.getStatusLine().getStatusCode());
//response = client().performRequest(new Request("POST", "_refresh"));
//assertEquals(HttpStatus.SC_OK, response.getStatusLine().getStatusCode());
}


Expand Down

0 comments on commit c0de31a

Please sign in to comment.