From 68b2290177b1217e17de4ef8daa12908f14cd4b1 Mon Sep 17 00:00:00 2001 From: Surya Sashank Nistala Date: Sat, 7 Oct 2023 04:04:39 -0700 Subject: [PATCH] fix constructor Signed-off-by: Surya Sashank Nistala --- .../alerting/util/DocLevelMonitorQueries.kt | 2 +- .../alerting/AlertingRestTestCase.kt | 4 +- .../alerting/DocumentMonitorRunnerIT.kt | 46 ++-- .../alerting/MonitorDataSourcesIT.kt | 216 +++++++++--------- .../alerting/MonitorRunnerServiceIT.kt | 2 +- .../org/opensearch/alerting/TestHelpers.kt | 2 +- .../alerting/alerts/AlertIndicesIT.kt | 10 +- .../alerting/resthandler/FindingsRestApiIT.kt | 12 +- .../alerting/resthandler/MonitorRestApiIT.kt | 8 +- .../resthandler/SecureWorkflowRestApiIT.kt | 2 +- .../alerting/resthandler/WorkflowRestApiIT.kt | 34 +-- .../TriggerExpressionResolverTests.kt | 48 ++-- 12 files changed, 197 insertions(+), 189 deletions(-) diff --git a/alerting/src/main/kotlin/org/opensearch/alerting/util/DocLevelMonitorQueries.kt b/alerting/src/main/kotlin/org/opensearch/alerting/util/DocLevelMonitorQueries.kt index ef4b956b7..4d4f8088c 100644 --- a/alerting/src/main/kotlin/org/opensearch/alerting/util/DocLevelMonitorQueries.kt +++ b/alerting/src/main/kotlin/org/opensearch/alerting/util/DocLevelMonitorQueries.kt @@ -365,7 +365,7 @@ class DocLevelMonitorQueries(private val client: Client, private val clusterServ .id(it.id + "_$monitorId") .source( mapOf( - "query" to mapOf("query_string" to mapOf("query" to query)), + "query" to mapOf("query_string" to mapOf("query" to query, "fields" to it.fields)), "monitor_id" to monitorId, "index" to sourceIndex ) diff --git a/alerting/src/test/kotlin/org/opensearch/alerting/AlertingRestTestCase.kt b/alerting/src/test/kotlin/org/opensearch/alerting/AlertingRestTestCase.kt index 23ad5371e..cb1a449bd 100644 --- a/alerting/src/test/kotlin/org/opensearch/alerting/AlertingRestTestCase.kt +++ b/alerting/src/test/kotlin/org/opensearch/alerting/AlertingRestTestCase.kt @@ -655,7 +655,9 @@ abstract class AlertingRestTestCase : ODFERestTestCase() { monitorId: String = "NO_ID", monitorName: String = "NO_NAME", index: String = "testIndex", - docLevelQueries: List = listOf(DocLevelQuery(query = "test_field:\"us-west-2\"", name = "testQuery")), + docLevelQueries: List = listOf( + DocLevelQuery(query = "test_field:\"us-west-2\"", name = "testQuery", fields = listOf()) + ), matchingDocIds: List, ): String { val finding = Finding( diff --git a/alerting/src/test/kotlin/org/opensearch/alerting/DocumentMonitorRunnerIT.kt b/alerting/src/test/kotlin/org/opensearch/alerting/DocumentMonitorRunnerIT.kt index f0b4fd4fb..24293c11d 100644 --- a/alerting/src/test/kotlin/org/opensearch/alerting/DocumentMonitorRunnerIT.kt +++ b/alerting/src/test/kotlin/org/opensearch/alerting/DocumentMonitorRunnerIT.kt @@ -41,7 +41,7 @@ class DocumentMonitorRunnerIT : AlertingRestTestCase() { val index = createTestIndex() - val docQuery = DocLevelQuery(query = "test_field:\"us-west-2\"", name = "3") + val docQuery = DocLevelQuery(query = "test_field:\"us-west-2\"", name = "3", fields = listOf()) val docLevelInput = DocLevelMonitorInput("description", listOf(index), listOf(docQuery)) val action = randomAction(template = randomTemplateScript("Hello {{ctx.monitor.name}}"), destinationId = createDestination().id) @@ -84,7 +84,7 @@ class DocumentMonitorRunnerIT : AlertingRestTestCase() { "test_field" : "us-west-2" }""" - val docQuery = DocLevelQuery(query = "test_field:\"us-west-2\"", name = "3") + val docQuery = DocLevelQuery(query = "test_field:\"us-west-2\"", name = "3", fields = listOf()) val docLevelInput = DocLevelMonitorInput("description", listOf(testIndex), listOf(docQuery)) val trigger = randomDocumentLevelTrigger(condition = ALWAYS_RUN) @@ -116,7 +116,7 @@ class DocumentMonitorRunnerIT : AlertingRestTestCase() { "test_field" : "us-west-2" }""" - val docQuery = DocLevelQuery(query = "test_field:\"us-west-2\"", name = "3") + val docQuery = DocLevelQuery(query = "test_field:\"us-west-2\"", name = "3", fields = listOf()) val docLevelInput = DocLevelMonitorInput("description", listOf(testIndex), listOf(docQuery)) val trigger = randomDocumentLevelTrigger(condition = ALWAYS_RUN) @@ -156,7 +156,7 @@ class DocumentMonitorRunnerIT : AlertingRestTestCase() { "test_field" : "us-west-2" }""" - val docQuery = DocLevelQuery(query = "test_field:\"us-west-2\"", name = "3", tags = listOf("test_tag")) + val docQuery = DocLevelQuery(query = "test_field:\"us-west-2\"", name = "3", tags = listOf("test_tag"), fields = listOf()) val docLevelInput = DocLevelMonitorInput("description", listOf(testIndex), listOf(docQuery)) val trigger = randomDocumentLevelTrigger(condition = Script("query[tag=test_tag]")) @@ -196,7 +196,7 @@ class DocumentMonitorRunnerIT : AlertingRestTestCase() { "test_field" : "us-west-2" }""" - val docQuery = DocLevelQuery(query = "test_field:\"us-west-2\"", name = "3", tags = listOf("test_tag")) + val docQuery = DocLevelQuery(query = "test_field:\"us-west-2\"", name = "3", tags = listOf("test_tag"), fields = listOf()) val docLevelInput = DocLevelMonitorInput("description", listOf(testIndex), listOf(docQuery)) val trigger = randomDocumentLevelTrigger(condition = ALWAYS_RUN) @@ -227,7 +227,7 @@ class DocumentMonitorRunnerIT : AlertingRestTestCase() { "test_field" : "us-west-2" }""" - val docQuery = DocLevelQuery(query = "test_field:\"us-west-2\"", name = "3") + val docQuery = DocLevelQuery(query = "test_field:\"us-west-2\"", name = "3", fields = listOf()) val docLevelInput = DocLevelMonitorInput("description", listOf(testIndex), listOf(docQuery)) val alertCategories = AlertCategory.values() @@ -295,7 +295,7 @@ class DocumentMonitorRunnerIT : AlertingRestTestCase() { "test_field" : "us-west-2" }""" - val docQuery = DocLevelQuery(query = "test_field:\"us-west-2\"", name = "3") + val docQuery = DocLevelQuery(query = "test_field:\"us-west-2\"", name = "3", fields = listOf()) val docLevelInput = DocLevelMonitorInput("description", listOf(testIndex), listOf(docQuery)) val actionExecutionScope = PerExecutionActionScope() @@ -362,7 +362,7 @@ class DocumentMonitorRunnerIT : AlertingRestTestCase() { "test_field" : "us-west-2" }""" - val docQuery = DocLevelQuery(query = "test_field:\"us-west-2\"", name = testQueryName) + val docQuery = DocLevelQuery(query = "test_field:\"us-west-2\"", name = testQueryName, fields = listOf()) val docLevelInput = DocLevelMonitorInput("description", listOf("$testIndexPrefix*"), listOf(docQuery)) val trigger = randomDocumentLevelTrigger(condition = Script("query[name=$testQueryName]")) @@ -406,7 +406,7 @@ class DocumentMonitorRunnerIT : AlertingRestTestCase() { "test_field" : "us-west-2" }""" - val docQuery = DocLevelQuery(query = "NOT (test_field:\"us-west-1\")", name = testQueryName) + val docQuery = DocLevelQuery(query = "NOT (test_field:\"us-west-1\")", name = testQueryName, fields = listOf()) val docLevelInput = DocLevelMonitorInput("description", listOf("$testIndexPrefix*"), listOf(docQuery)) val trigger = randomDocumentLevelTrigger(condition = Script("query[name=$testQueryName]")) @@ -447,7 +447,7 @@ class DocumentMonitorRunnerIT : AlertingRestTestCase() { "test_field" : "us-west-2" }""" - val docQuery = DocLevelQuery(query = "test_field:\"us-west-2\"", name = "3") + val docQuery = DocLevelQuery(query = "test_field:\"us-west-2\"", name = "3", fields = listOf()) val docLevelInput = DocLevelMonitorInput("description", listOf("test*"), listOf(docQuery)) val trigger = randomDocumentLevelTrigger(condition = ALWAYS_RUN) @@ -532,11 +532,13 @@ class DocumentMonitorRunnerIT : AlertingRestTestCase() { val docQuery1 = DocLevelQuery( query = "(source.device.port:12345 AND test_field:12345) OR source.device.hwd.id:12345", - name = "4" + name = "4", + fields = listOf() ) val docQuery2 = DocLevelQuery( query = "(source.device.port:\"12345\" AND test_field:\"12345\") OR source.device.hwd.id:\"12345\"", - name = "5" + name = "5", + fields = listOf() ) val docLevelInput = DocLevelMonitorInput("description", listOf("test*"), listOf(docQuery1, docQuery2)) @@ -668,7 +670,8 @@ class DocumentMonitorRunnerIT : AlertingRestTestCase() { val docQuery = DocLevelQuery( query = "nested_field.test1:\"12345\"", - name = "5" + name = "5", + fields = listOf() ) val docLevelInput = DocLevelMonitorInput("description", listOf("test*"), listOf(docQuery)) @@ -754,7 +757,8 @@ class DocumentMonitorRunnerIT : AlertingRestTestCase() { val docQuery = DocLevelQuery( query = "test_field:\"12345\" AND source.id:\"12345\"", - name = "5" + name = "5", + fields = listOf() ) val docLevelInput = DocLevelMonitorInput("description", listOf("test*"), listOf(docQuery)) @@ -870,11 +874,13 @@ class DocumentMonitorRunnerIT : AlertingRestTestCase() { val docQuery1 = DocLevelQuery( query = "test_field:\"12345\"", - name = "4" + name = "4", + fields = listOf() ) val docQuery2 = DocLevelQuery( query = "source.device.hwd.id:\"12345\"", - name = "5" + name = "5", + fields = listOf() ) val docLevelInput = DocLevelMonitorInput("description", listOf("test*"), listOf(docQuery1, docQuery2)) @@ -921,7 +927,7 @@ class DocumentMonitorRunnerIT : AlertingRestTestCase() { "test_field" : "us-west-2" }""" - val docQuery = DocLevelQuery(query = "test_field:\"us-west-2\"", name = "3") + val docQuery = DocLevelQuery(query = "test_field:\"us-west-2\"", name = "3", fields = listOf()) val docLevelInput = DocLevelMonitorInput("description", listOf("test*"), listOf(docQuery)) val trigger = randomDocumentLevelTrigger(condition = ALWAYS_RUN) @@ -970,8 +976,8 @@ class DocumentMonitorRunnerIT : AlertingRestTestCase() { "test_field" : "us-west-2" }""" - val docQuery1 = DocLevelQuery(query = "test_field:\"us-west-2\"", name = "3") - val docQuery2 = DocLevelQuery(query = "test_field_new:\"us-west-2\"", name = "4") + val docQuery1 = DocLevelQuery(query = "test_field:\"us-west-2\"", name = "3", fields = listOf()) + val docQuery2 = DocLevelQuery(query = "test_field_new:\"us-west-2\"", name = "4", fields = listOf()) val docLevelInput = DocLevelMonitorInput("description", listOf("test*"), listOf(docQuery1, docQuery2)) val trigger = randomDocumentLevelTrigger(condition = ALWAYS_RUN) @@ -1233,7 +1239,7 @@ class DocumentMonitorRunnerIT : AlertingRestTestCase() { "test_field" : "us-west-2" }""" - val docQuery = DocLevelQuery(query = "test_field:\"us-west-2\"", name = "3") + val docQuery = DocLevelQuery(query = "test_field:\"us-west-2\"", name = "3", fields = listOf()) val docLevelInput = DocLevelMonitorInput("description", listOf(testIndex), listOf(docQuery)) val alertCategories = AlertCategory.values() diff --git a/alerting/src/test/kotlin/org/opensearch/alerting/MonitorDataSourcesIT.kt b/alerting/src/test/kotlin/org/opensearch/alerting/MonitorDataSourcesIT.kt index 2ae177b3c..f0ef6c9a8 100644 --- a/alerting/src/test/kotlin/org/opensearch/alerting/MonitorDataSourcesIT.kt +++ b/alerting/src/test/kotlin/org/opensearch/alerting/MonitorDataSourcesIT.kt @@ -92,7 +92,7 @@ import java.util.stream.Collectors class MonitorDataSourcesIT : AlertingSingleNodeTestCase() { fun `test execute monitor with dryrun`() { - val docQuery = DocLevelQuery(query = "test_field:\"us-west-2\"", name = "3") + val docQuery = DocLevelQuery(query = "test_field:\"us-west-2\"", name = "3", fields = listOf()) val docLevelInput = DocLevelMonitorInput("description", listOf(index), listOf(docQuery)) val trigger = randomDocumentLevelTrigger(condition = ALWAYS_RUN) var monitor = randomDocumentLevelMonitor( @@ -136,7 +136,7 @@ class MonitorDataSourcesIT : AlertingSingleNodeTestCase() { } fun `test execute monitor with custom alerts index`() { - val docQuery = DocLevelQuery(query = "test_field:\"us-west-2\"", name = "3") + val docQuery = DocLevelQuery(query = "test_field:\"us-west-2\"", name = "3", fields = listOf()) val docLevelInput = DocLevelMonitorInput("description", listOf(index), listOf(docQuery)) val trigger = randomDocumentLevelTrigger(condition = ALWAYS_RUN) val customAlertsIndex = "custom_alerts_index" @@ -186,10 +186,10 @@ class MonitorDataSourcesIT : AlertingSingleNodeTestCase() { val index2 = "index_456" val index3 = "index_789" val index4 = "index_012" - val q1 = DocLevelQuery(query = "properties:\"abcd\"", name = "1") - val q2 = DocLevelQuery(query = "type.properties:\"abcd\"", name = "2") - val q3 = DocLevelQuery(query = "type.something.properties:\"abcd\"", name = "3") - val q4 = DocLevelQuery(query = "type.something.properties.lastone:\"abcd\"", name = "4") + val q1 = DocLevelQuery(query = "properties:\"abcd\"", name = "1", fields = listOf()) + val q2 = DocLevelQuery(query = "type.properties:\"abcd\"", name = "2", fields = listOf()) + val q3 = DocLevelQuery(query = "type.something.properties:\"abcd\"", name = "3", fields = listOf()) + val q4 = DocLevelQuery(query = "type.something.properties.lastone:\"abcd\"", name = "4", fields = listOf()) createIndex(index1, Settings.EMPTY) createIndex(index2, Settings.EMPTY) @@ -309,7 +309,7 @@ class MonitorDataSourcesIT : AlertingSingleNodeTestCase() { } fun `test execute monitor without triggers`() { - val docQuery = DocLevelQuery(query = "eventType:\"login\"", name = "3") + val docQuery = DocLevelQuery(query = "eventType:\"login\"", name = "3", fields = listOf()) val docLevelInput = DocLevelMonitorInput( "description", listOf(index), listOf(docQuery) @@ -368,15 +368,15 @@ class MonitorDataSourcesIT : AlertingSingleNodeTestCase() { } fun `test execute monitor with custom query index`() { - val q1 = DocLevelQuery(query = "source.ip.v6.v1:12345", name = "3") - val q2 = DocLevelQuery(query = "source.ip.v6.v2:16645", name = "4") - val q3 = DocLevelQuery(query = "source.ip.v4.v0:120", name = "5") - val q4 = DocLevelQuery(query = "alias.some.fff:\"us-west-2\"", name = "6") - val q5 = DocLevelQuery(query = "message:\"This is an error from IAD region\"", name = "7") - val q6 = DocLevelQuery(query = "f1.type.f4:\"hello\"", name = "8") - val q7 = DocLevelQuery(query = "f1.type.f2.f3:\"world\"", name = "9") - val q8 = DocLevelQuery(query = "type:\"some type\"", name = "10") - val q9 = DocLevelQuery(query = "properties:123", name = "11") + val q1 = DocLevelQuery(query = "source.ip.v6.v1:12345", name = "3", fields = listOf()) + val q2 = DocLevelQuery(query = "source.ip.v6.v2:16645", name = "4", fields = listOf()) + val q3 = DocLevelQuery(query = "source.ip.v4.v0:120", name = "5", fields = listOf()) + val q4 = DocLevelQuery(query = "alias.some.fff:\"us-west-2\"", name = "6", fields = listOf()) + val q5 = DocLevelQuery(query = "message:\"This is an error from IAD region\"", name = "7", fields = listOf()) + val q6 = DocLevelQuery(query = "f1.type.f4:\"hello\"", name = "8", fields = listOf()) + val q7 = DocLevelQuery(query = "f1.type.f2.f3:\"world\"", name = "9", fields = listOf()) + val q8 = DocLevelQuery(query = "type:\"some type\"", name = "10", fields = listOf()) + val q9 = DocLevelQuery(query = "properties:123", name = "11", fields = listOf()) val docLevelInput = DocLevelMonitorInput( "description", @@ -441,7 +441,7 @@ class MonitorDataSourcesIT : AlertingSingleNodeTestCase() { } fun `test execute monitor with non-flattened json doc as source`() { - val docQuery1 = DocLevelQuery(query = "source.device.port:12345 OR source.device.hwd.id:12345", name = "3") + val docQuery1 = DocLevelQuery(query = "source.device.port:12345 OR source.device.hwd.id:12345", name = "3", fields = listOf()) val docLevelInput = DocLevelMonitorInput( "description", listOf(index), listOf(docQuery1) @@ -552,13 +552,13 @@ class MonitorDataSourcesIT : AlertingSingleNodeTestCase() { } fun `test execute monitor with custom query index old`() { - val docQuery1 = DocLevelQuery(query = "source.ip.v6.v1:12345", name = "3") - val docQuery2 = DocLevelQuery(query = "source.ip.v6.v2:16645", name = "4") - val docQuery3 = DocLevelQuery(query = "source.ip.v4.v0:120", name = "5") - val docQuery4 = DocLevelQuery(query = "alias.some.fff:\"us-west-2\"", name = "6") - val docQuery5 = DocLevelQuery(query = "message:\"This is an error from IAD region\"", name = "7") - val docQuery6 = DocLevelQuery(query = "type.subtype:\"some subtype\"", name = "8") - val docQuery7 = DocLevelQuery(query = "supertype.type:\"some type\"", name = "9") + val docQuery1 = DocLevelQuery(query = "source.ip.v6.v1:12345", name = "3", fields = listOf()) + val docQuery2 = DocLevelQuery(query = "source.ip.v6.v2:16645", name = "4", fields = listOf()) + val docQuery3 = DocLevelQuery(query = "source.ip.v4.v0:120", name = "5", fields = listOf()) + val docQuery4 = DocLevelQuery(query = "alias.some.fff:\"us-west-2\"", name = "6", fields = listOf()) + val docQuery5 = DocLevelQuery(query = "message:\"This is an error from IAD region\"", name = "7", fields = listOf()) + val docQuery6 = DocLevelQuery(query = "type.subtype:\"some subtype\"", name = "8", fields = listOf()) + val docQuery7 = DocLevelQuery(query = "supertype.type:\"some type\"", name = "9", fields = listOf()) val docLevelInput = DocLevelMonitorInput( "description", listOf(index), listOf(docQuery1, docQuery2, docQuery3, docQuery4, docQuery5, docQuery6, docQuery7) ) @@ -613,7 +613,7 @@ class MonitorDataSourcesIT : AlertingSingleNodeTestCase() { } fun `test monitor error alert created and updated with new error`() { - val docQuery = DocLevelQuery(query = "source:12345", name = "1") + val docQuery = DocLevelQuery(query = "source:12345", name = "1", fields = listOf()) val docLevelInput = DocLevelMonitorInput( "description", listOf(index), listOf(docQuery) ) @@ -670,7 +670,7 @@ class MonitorDataSourcesIT : AlertingSingleNodeTestCase() { } fun `test monitor error alert created trigger run errored 2 times same error`() { - val docQuery = DocLevelQuery(query = "source:12345", name = "1") + val docQuery = DocLevelQuery(query = "source:12345", name = "1", fields = listOf()) val docLevelInput = DocLevelMonitorInput( "description", listOf(index), listOf(docQuery) ) @@ -719,7 +719,7 @@ class MonitorDataSourcesIT : AlertingSingleNodeTestCase() { val customAlertIndex = "custom-alert-index" val customAlertHistoryIndex = "custom-alert-history-index" val customAlertHistoryIndexPattern = "" - val docQuery = DocLevelQuery(query = "source:12345", name = "1") + val docQuery = DocLevelQuery(query = "source:12345", name = "1", fields = listOf()) val docLevelInput = DocLevelMonitorInput( "description", listOf(index), listOf(docQuery) ) @@ -784,7 +784,7 @@ class MonitorDataSourcesIT : AlertingSingleNodeTestCase() { val customAlertIndex = "custom-alert-index" val customAlertHistoryIndex = "custom-alert-history-index" val customAlertHistoryIndexPattern = "" - val docQuery = DocLevelQuery(query = "source:12345", name = "1") + val docQuery = DocLevelQuery(query = "source:12345", name = "1", fields = listOf()) val docLevelInput = DocLevelMonitorInput( "description", listOf(index), listOf(docQuery) ) @@ -866,7 +866,7 @@ class MonitorDataSourcesIT : AlertingSingleNodeTestCase() { } fun `test execute monitor with custom query index and nested mappings`() { - val docQuery1 = DocLevelQuery(query = "message:\"msg 1 2 3 4\"", name = "3") + val docQuery1 = DocLevelQuery(query = "message:\"msg 1 2 3 4\"", name = "3", fields = listOf()) val docLevelInput = DocLevelMonitorInput("description", listOf(index), listOf(docQuery1)) val trigger = randomDocumentLevelTrigger(condition = ALWAYS_RUN) val customFindingsIndex = "custom_findings_index" @@ -941,7 +941,7 @@ class MonitorDataSourcesIT : AlertingSingleNodeTestCase() { } fun `test cleanup monitor on partial create monitor failure`() { - val docQuery = DocLevelQuery(query = "dnbkjndsfkjbnds:\"us-west-2\"", name = "3") + val docQuery = DocLevelQuery(query = "dnbkjndsfkjbnds:\"us-west-2\"", name = "3", fields = listOf()) val docLevelInput = DocLevelMonitorInput("description", listOf(index), listOf(docQuery)) val trigger = randomDocumentLevelTrigger(condition = ALWAYS_RUN) val customQueryIndex = "custom_alerts_index" @@ -994,7 +994,7 @@ class MonitorDataSourcesIT : AlertingSingleNodeTestCase() { } fun `test execute monitor without create when no monitors exists`() { - val docQuery = DocLevelQuery(query = "test_field:\"us-west-2\"", name = "3") + val docQuery = DocLevelQuery(query = "test_field:\"us-west-2\"", name = "3", fields = listOf()) val docLevelInput = DocLevelMonitorInput("description", listOf(index), listOf(docQuery)) val trigger = randomDocumentLevelTrigger(condition = ALWAYS_RUN) val customQueryIndex = "custom_alerts_index" @@ -1035,7 +1035,7 @@ class MonitorDataSourcesIT : AlertingSingleNodeTestCase() { } fun `test execute monitor with custom query index and custom field mappings`() { - val docQuery = DocLevelQuery(query = "test_field:\"us-west-2\"", name = "3") + val docQuery = DocLevelQuery(query = "test_field:\"us-west-2\"", name = "3", fields = listOf()) val docLevelInput = DocLevelMonitorInput("description", listOf(index), listOf(docQuery)) val trigger = randomDocumentLevelTrigger(condition = ALWAYS_RUN) val customQueryIndex = "custom_alerts_index" @@ -1068,7 +1068,7 @@ class MonitorDataSourcesIT : AlertingSingleNodeTestCase() { } fun `test delete monitor deletes all queries and metadata too`() { - val docQuery = DocLevelQuery(query = "test_field:\"us-west-2\"", name = "3") + val docQuery = DocLevelQuery(query = "test_field:\"us-west-2\"", name = "3", fields = listOf()) val docLevelInput = DocLevelMonitorInput("description", listOf(index), listOf(docQuery)) val trigger = randomDocumentLevelTrigger(condition = ALWAYS_RUN) val customQueryIndex = "custom_query_index" @@ -1111,7 +1111,7 @@ class MonitorDataSourcesIT : AlertingSingleNodeTestCase() { } fun `test execute monitor with custom findings index and pattern`() { - val docQuery = DocLevelQuery(query = "test_field:\"us-west-2\"", name = "3") + val docQuery = DocLevelQuery(query = "test_field:\"us-west-2\"", name = "3", fields = listOf()) val docLevelInput = DocLevelMonitorInput("description", listOf(index), listOf(docQuery)) val trigger = randomDocumentLevelTrigger(condition = ALWAYS_RUN) val customFindingsIndex = "custom_findings_index" @@ -1162,7 +1162,7 @@ class MonitorDataSourcesIT : AlertingSingleNodeTestCase() { createIndex(testSourceIndex1, Settings.EMPTY) createIndex(testSourceIndex2, Settings.EMPTY) - val docQuery = DocLevelQuery(query = "test_field:\"us-west-2\"", name = "3") + val docQuery = DocLevelQuery(query = "test_field:\"us-west-2\"", name = "3", fields = listOf()) val docLevelInput = DocLevelMonitorInput("description", listOf(testSourceIndex1, testSourceIndex2), listOf(docQuery)) val trigger = randomDocumentLevelTrigger(condition = ALWAYS_RUN) val customFindingsIndex = "custom_findings_index" @@ -1219,7 +1219,7 @@ class MonitorDataSourcesIT : AlertingSingleNodeTestCase() { createIndex(testSourceIndex1, Settings.EMPTY) createIndex(testSourceIndex2, Settings.EMPTY) - val docQuery = DocLevelQuery(query = "test_field:\"us-west-2\"", name = "3") + val docQuery = DocLevelQuery(query = "test_field:\"us-west-2\"", name = "3", fields = listOf()) val docLevelInput = DocLevelMonitorInput("description", listOf(testSourceIndex1, testSourceIndex2), listOf(docQuery)) val trigger = randomDocumentLevelTrigger(condition = ALWAYS_RUN) val customFindingsIndex = "custom_findings_index" @@ -1276,7 +1276,7 @@ class MonitorDataSourcesIT : AlertingSingleNodeTestCase() { createIndex(testSourceIndex1, Settings.EMPTY) createIndex(testSourceIndex2, Settings.EMPTY) - val docQuery = DocLevelQuery(query = "test_field:\"us-west-2\"", name = "3") + val docQuery = DocLevelQuery(query = "test_field:\"us-west-2\"", name = "3", fields = listOf()) val docLevelInput = DocLevelMonitorInput("description", listOf(testSourceIndex1, testSourceIndex2), listOf(docQuery)) val trigger = randomDocumentLevelTrigger(condition = ALWAYS_RUN) val customFindingsIndex = "custom_findings_index" @@ -1528,7 +1528,7 @@ class MonitorDataSourcesIT : AlertingSingleNodeTestCase() { } fun `test execute monitor with empty source index`() { - val docQuery = DocLevelQuery(query = "test_field:\"us-west-2\"", name = "3") + val docQuery = DocLevelQuery(query = "test_field:\"us-west-2\"", name = "3", fields = listOf()) val docLevelInput = DocLevelMonitorInput("description", listOf(index), listOf(docQuery)) val trigger = randomDocumentLevelTrigger(condition = ALWAYS_RUN) val customFindingsIndex = "custom_findings_index" @@ -1569,7 +1569,7 @@ class MonitorDataSourcesIT : AlertingSingleNodeTestCase() { } fun `test execute GetFindingsAction with monitorId param`() { - val docQuery = DocLevelQuery(query = "test_field:\"us-west-2\"", name = "3") + val docQuery = DocLevelQuery(query = "test_field:\"us-west-2\"", name = "3", fields = listOf()) val docLevelInput = DocLevelMonitorInput("description", listOf(index), listOf(docQuery)) val trigger = randomDocumentLevelTrigger(condition = ALWAYS_RUN) val customFindingsIndex = "custom_findings_index" @@ -1606,7 +1606,7 @@ class MonitorDataSourcesIT : AlertingSingleNodeTestCase() { } fun `test execute GetFindingsAction with unknown monitorId`() { - val docQuery = DocLevelQuery(query = "test_field:\"us-west-2\"", name = "3") + val docQuery = DocLevelQuery(query = "test_field:\"us-west-2\"", name = "3", fields = listOf()) val docLevelInput = DocLevelMonitorInput("description", listOf(index), listOf(docQuery)) val trigger = randomDocumentLevelTrigger(condition = ALWAYS_RUN) val customFindingsIndex = "custom_findings_index" @@ -1647,7 +1647,7 @@ class MonitorDataSourcesIT : AlertingSingleNodeTestCase() { } fun `test execute monitor with owner field`() { - val docQuery = DocLevelQuery(query = "test_field:\"us-west-2\"", name = "3") + val docQuery = DocLevelQuery(query = "test_field:\"us-west-2\"", name = "3", fields = listOf()) val docLevelInput = DocLevelMonitorInput("description", listOf(index), listOf(docQuery)) val trigger = randomDocumentLevelTrigger(condition = ALWAYS_RUN) val customAlertsIndex = "custom_alerts_index" @@ -1688,7 +1688,7 @@ class MonitorDataSourcesIT : AlertingSingleNodeTestCase() { } fun `test execute GetFindingsAction with unknown findingIndex param`() { - val docQuery = DocLevelQuery(query = "test_field:\"us-west-2\"", name = "3") + val docQuery = DocLevelQuery(query = "test_field:\"us-west-2\"", name = "3", fields = listOf()) val docLevelInput = DocLevelMonitorInput("description", listOf(index), listOf(docQuery)) val trigger = randomDocumentLevelTrigger(condition = ALWAYS_RUN) val customFindingsIndex = "custom_findings_index" @@ -1729,7 +1729,7 @@ class MonitorDataSourcesIT : AlertingSingleNodeTestCase() { } fun `test search custom alerts history index`() { - val docQuery = DocLevelQuery(query = "test_field:\"us-west-2\"", name = "3") + val docQuery = DocLevelQuery(query = "test_field:\"us-west-2\"", name = "3", fields = listOf()) val docLevelInput = DocLevelMonitorInput("description", listOf(index), listOf(docQuery)) val trigger1 = randomDocumentLevelTrigger(condition = ALWAYS_RUN) val trigger2 = randomDocumentLevelTrigger(condition = ALWAYS_RUN) @@ -1777,7 +1777,7 @@ class MonitorDataSourcesIT : AlertingSingleNodeTestCase() { } fun `test search custom alerts history index after alert ack`() { - val docQuery = DocLevelQuery(query = "test_field:\"us-west-2\"", name = "3") + val docQuery = DocLevelQuery(query = "test_field:\"us-west-2\"", name = "3", fields = listOf()) val docLevelInput = DocLevelMonitorInput("description", listOf(index), listOf(docQuery)) val trigger1 = randomDocumentLevelTrigger(condition = ALWAYS_RUN) val trigger2 = randomDocumentLevelTrigger(condition = ALWAYS_RUN) @@ -1847,7 +1847,7 @@ class MonitorDataSourcesIT : AlertingSingleNodeTestCase() { } fun `test get alerts by list of monitors containing both existent and non-existent ids`() { - val docQuery = DocLevelQuery(query = "test_field:\"us-west-2\"", name = "3") + val docQuery = DocLevelQuery(query = "test_field:\"us-west-2\"", name = "3", fields = listOf()) val docLevelInput = DocLevelMonitorInput("description", listOf(index), listOf(docQuery)) val trigger = randomDocumentLevelTrigger(condition = ALWAYS_RUN) var monitor = randomDocumentLevelMonitor( @@ -1925,7 +1925,7 @@ class MonitorDataSourcesIT : AlertingSingleNodeTestCase() { val testSourceIndex = "test_source_index" createIndex(testSourceIndex, Settings.builder().put("index.mapping.total_fields.limit", "10000").build()) - val docQuery = DocLevelQuery(query = "test_field:\"us-west-2\"", name = "3") + val docQuery = DocLevelQuery(query = "test_field:\"us-west-2\"", name = "3", fields = listOf()) val docLevelInput = DocLevelMonitorInput("description", listOf(testSourceIndex), listOf(docQuery)) val trigger = randomDocumentLevelTrigger(condition = ALWAYS_RUN) var monitor = randomDocumentLevelMonitor( @@ -2016,7 +2016,7 @@ class MonitorDataSourcesIT : AlertingSingleNodeTestCase() { val testSourceIndex = "test_source_index" createIndex(testSourceIndex, Settings.EMPTY) - val docQuery = DocLevelQuery(query = "test_field:\"us-west-2\"", name = "3") + val docQuery = DocLevelQuery(query = "test_field:\"us-west-2\"", name = "3", fields = listOf()) val docLevelInput = DocLevelMonitorInput("description", listOf(testSourceIndex), listOf(docQuery)) val trigger = randomDocumentLevelTrigger(condition = ALWAYS_RUN) var monitor = randomDocumentLevelMonitor( @@ -2044,7 +2044,7 @@ class MonitorDataSourcesIT : AlertingSingleNodeTestCase() { val testSourceIndex = "test_source_index" createIndex(testSourceIndex, Settings.EMPTY) - val docQuery = DocLevelQuery(query = "test_field:\"us-west-2\"", name = "3") + val docQuery = DocLevelQuery(query = "test_field:\"us-west-2\"", name = "3", fields = listOf()) val docLevelInput = DocLevelMonitorInput("description", listOf(testSourceIndex), listOf(docQuery)) val trigger = randomDocumentLevelTrigger(condition = ALWAYS_RUN) var monitor = randomDocumentLevelMonitor( @@ -2122,7 +2122,7 @@ class MonitorDataSourcesIT : AlertingSingleNodeTestCase() { val testSourceIndex2 = "test_source_index2" createIndex(testSourceIndex1, Settings.builder().put("index.mapping.total_fields.limit", "10000").build()) createIndex(testSourceIndex2, Settings.builder().put("index.mapping.total_fields.limit", "10000").build()) - val docQuery = DocLevelQuery(query = "test_field:\"us-west-2\"", name = "3") + val docQuery = DocLevelQuery(query = "test_field:\"us-west-2\"", name = "3", fields = listOf()) val docLevelInput = DocLevelMonitorInput("description", listOf(testSourceIndex1), listOf(docQuery)) val trigger = randomDocumentLevelTrigger(condition = ALWAYS_RUN) var monitor = randomDocumentLevelMonitor( @@ -2170,7 +2170,7 @@ class MonitorDataSourcesIT : AlertingSingleNodeTestCase() { fun `test queryIndex gets increased max fields in mappings`() { val testSourceIndex = "test_source_index" createIndex(testSourceIndex, Settings.builder().put("index.mapping.total_fields.limit", "10000").build()) - val docQuery = DocLevelQuery(query = "test_field:\"us-west-2\"", name = "3") + val docQuery = DocLevelQuery(query = "test_field:\"us-west-2\"", name = "3", fields = listOf()) val docLevelInput = DocLevelMonitorInput("description", listOf(testSourceIndex), listOf(docQuery)) val trigger = randomDocumentLevelTrigger(condition = ALWAYS_RUN) var monitor = randomDocumentLevelMonitor( @@ -2216,7 +2216,7 @@ class MonitorDataSourcesIT : AlertingSingleNodeTestCase() { val testSourceIndex = "test_source_index" createIndex(testSourceIndex, Settings.EMPTY) - val docQuery = DocLevelQuery(query = "test_field:\"us-west-2\"", name = "3") + val docQuery = DocLevelQuery(query = "test_field:\"us-west-2\"", name = "3", fields = listOf()) val docLevelInput = DocLevelMonitorInput("description", listOf(testSourceIndex), listOf(docQuery)) val trigger = randomDocumentLevelTrigger(condition = ALWAYS_RUN) var monitor = randomDocumentLevelMonitor( @@ -2291,9 +2291,9 @@ class MonitorDataSourcesIT : AlertingSingleNodeTestCase() { ) )!! - val docQuery1 = DocLevelQuery(query = "test_field_1:\"test_value_2\"", name = "1") - val docQuery2 = DocLevelQuery(query = "test_field_1:\"test_value_1\"", name = "2") - val docQuery3 = DocLevelQuery(query = "test_field_1:\"test_value_3\"", name = "3") + val docQuery1 = DocLevelQuery(query = "test_field_1:\"test_value_2\"", name = "1", fields = listOf()) + val docQuery2 = DocLevelQuery(query = "test_field_1:\"test_value_1\"", name = "2", fields = listOf()) + val docQuery3 = DocLevelQuery(query = "test_field_1:\"test_value_3\"", name = "3", fields = listOf()) val docLevelInput = DocLevelMonitorInput("description", listOf(index), listOf(docQuery1, docQuery2, docQuery3)) val docTrigger = randomDocumentLevelTrigger(condition = ALWAYS_RUN) val docCustomAlertsIndex = "custom_alerts_index" @@ -2368,8 +2368,8 @@ class MonitorDataSourcesIT : AlertingSingleNodeTestCase() { } fun `test execute workflow with custom alerts and finding index when doc level delegate is used in chained finding`() { - val docQuery1 = DocLevelQuery(query = "test_field_1:\"test_value_2\"", name = "1") - val docQuery2 = DocLevelQuery(query = "test_field_1:\"test_value_3\"", name = "2") + val docQuery1 = DocLevelQuery(query = "test_field_1:\"test_value_2\"", name = "1", fields = listOf()) + val docQuery2 = DocLevelQuery(query = "test_field_1:\"test_value_3\"", name = "2", fields = listOf()) var docLevelMonitor = randomDocumentLevelMonitor( inputs = listOf(DocLevelMonitorInput("description", listOf(index), listOf(docQuery1, docQuery2))), @@ -2608,7 +2608,7 @@ class MonitorDataSourcesIT : AlertingSingleNodeTestCase() { } fun `test execute workflow with custom alerts and finding index with doc level delegates`() { - val docQuery1 = DocLevelQuery(query = "test_field_1:\"us-west-2\"", name = "3") + val docQuery1 = DocLevelQuery(query = "test_field_1:\"us-west-2\"", name = "3", fields = listOf()) val docLevelInput1 = DocLevelMonitorInput("description", listOf(index), listOf(docQuery1)) val trigger1 = randomDocumentLevelTrigger(condition = ALWAYS_RUN) val customAlertsIndex1 = "custom_alerts_index" @@ -2625,7 +2625,7 @@ class MonitorDataSourcesIT : AlertingSingleNodeTestCase() { ) val monitorResponse = createMonitor(monitor1)!! - val docQuery2 = DocLevelQuery(query = "source.ip.v6.v2:16645", name = "4") + val docQuery2 = DocLevelQuery(query = "source.ip.v6.v2:16645", name = "4", fields = listOf()) val docLevelInput2 = DocLevelMonitorInput("description", listOf(index), listOf(docQuery2)) val trigger2 = randomDocumentLevelTrigger(condition = ALWAYS_RUN) val customAlertsIndex2 = "custom_alerts_index_2" @@ -2701,7 +2701,7 @@ class MonitorDataSourcesIT : AlertingSingleNodeTestCase() { } fun `test execute workflow with multiple monitors in chained monitor findings of single monitor`() { - val docQuery1 = DocLevelQuery(query = "test_field_1:\"us-west-2\"", name = "3") + val docQuery1 = DocLevelQuery(query = "test_field_1:\"us-west-2\"", name = "3", fields = listOf()) val docLevelInput1 = DocLevelMonitorInput("description", listOf(index), listOf(docQuery1)) val trigger1 = randomDocumentLevelTrigger(condition = ALWAYS_RUN) val customAlertsIndex1 = "custom_alerts_index" @@ -2719,7 +2719,7 @@ class MonitorDataSourcesIT : AlertingSingleNodeTestCase() { ) val monitorResponse = createMonitor(monitor1)!! - val docQuery2 = DocLevelQuery(query = "source.ip.v6.v2:16645", name = "4") + val docQuery2 = DocLevelQuery(query = "source.ip.v6.v2:16645", name = "4", fields = listOf()) val docLevelInput2 = DocLevelMonitorInput("description", listOf(index), listOf(docQuery2)) val trigger2 = randomDocumentLevelTrigger(condition = ALWAYS_RUN) var monitor2 = randomDocumentLevelMonitor( @@ -2734,7 +2734,7 @@ class MonitorDataSourcesIT : AlertingSingleNodeTestCase() { ) val monitorResponse2 = createMonitor(monitor2)!! - val docQuery3 = DocLevelQuery(query = "_id:*", name = "5") + val docQuery3 = DocLevelQuery(query = "_id:*", name = "5", fields = listOf()) val docLevelInput3 = DocLevelMonitorInput("description", listOf(index), listOf(docQuery3)) val trigger3 = randomDocumentLevelTrigger(condition = ALWAYS_RUN) @@ -2816,7 +2816,7 @@ class MonitorDataSourcesIT : AlertingSingleNodeTestCase() { } fun `test execute workflows with shared doc level monitor delegate`() { - val docQuery = DocLevelQuery(query = "test_field_1:\"us-west-2\"", name = "3") + val docQuery = DocLevelQuery(query = "test_field_1:\"us-west-2\"", name = "3", fields = listOf()) val docLevelInput = DocLevelMonitorInput("description", listOf(index), listOf(docQuery)) val trigger = randomDocumentLevelTrigger(condition = ALWAYS_RUN) val customAlertsIndex = "custom_alerts_index" @@ -2920,7 +2920,7 @@ class MonitorDataSourcesIT : AlertingSingleNodeTestCase() { } fun `test execute workflows with shared doc level monitor delegate updating delegate datasource`() { - val docQuery = DocLevelQuery(query = "test_field_1:\"us-west-2\"", name = "3") + val docQuery = DocLevelQuery(query = "test_field_1:\"us-west-2\"", name = "3", fields = listOf()) val docLevelInput = DocLevelMonitorInput("description", listOf(index), listOf(docQuery)) val trigger = randomDocumentLevelTrigger(condition = ALWAYS_RUN) @@ -3031,7 +3031,7 @@ class MonitorDataSourcesIT : AlertingSingleNodeTestCase() { } fun `test execute workflow verify workflow metadata`() { - val docQuery1 = DocLevelQuery(query = "test_field_1:\"us-west-2\"", name = "3") + val docQuery1 = DocLevelQuery(query = "test_field_1:\"us-west-2\"", name = "3", fields = listOf()) val docLevelInput1 = DocLevelMonitorInput("description", listOf(index), listOf(docQuery1)) val trigger1 = randomDocumentLevelTrigger(condition = ALWAYS_RUN) var monitor1 = randomDocumentLevelMonitor( @@ -3040,7 +3040,7 @@ class MonitorDataSourcesIT : AlertingSingleNodeTestCase() { ) val monitorResponse = createMonitor(monitor1)!! - val docQuery2 = DocLevelQuery(query = "source.ip.v6.v2:16645", name = "4") + val docQuery2 = DocLevelQuery(query = "source.ip.v6.v2:16645", name = "4", fields = listOf()) val docLevelInput2 = DocLevelMonitorInput("description", listOf(index), listOf(docQuery2)) val trigger2 = randomDocumentLevelTrigger(condition = ALWAYS_RUN) var monitor2 = randomDocumentLevelMonitor( @@ -3102,7 +3102,7 @@ class MonitorDataSourcesIT : AlertingSingleNodeTestCase() { } fun `test execute workflow dryrun verify workflow metadata not created`() { - val docQuery1 = DocLevelQuery(query = "test_field_1:\"us-west-2\"", name = "3") + val docQuery1 = DocLevelQuery(query = "test_field_1:\"us-west-2\"", name = "3", fields = listOf()) val docLevelInput1 = DocLevelMonitorInput("description", listOf(index), listOf(docQuery1)) val trigger1 = randomDocumentLevelTrigger(condition = ALWAYS_RUN) var monitor1 = randomDocumentLevelMonitor( @@ -3111,7 +3111,7 @@ class MonitorDataSourcesIT : AlertingSingleNodeTestCase() { ) val monitorResponse = createMonitor(monitor1)!! - val docQuery2 = DocLevelQuery(query = "source.ip.v6.v2:16645", name = "4") + val docQuery2 = DocLevelQuery(query = "source.ip.v6.v2:16645", name = "4", fields = listOf()) val docLevelInput2 = DocLevelMonitorInput("description", listOf(index), listOf(docQuery2)) val trigger2 = randomDocumentLevelTrigger(condition = ALWAYS_RUN) var monitor2 = randomDocumentLevelMonitor( @@ -3197,9 +3197,9 @@ class MonitorDataSourcesIT : AlertingSingleNodeTestCase() { ) )!! - val docQuery1 = DocLevelQuery(query = "test_field_1:\"test_value_2\"", name = "1") - val docQuery2 = DocLevelQuery(query = "test_field_1:\"test_value_1\"", name = "2") - val docQuery3 = DocLevelQuery(query = "test_field_1:\"test_value_3\"", name = "3") + val docQuery1 = DocLevelQuery(query = "test_field_1:\"test_value_2\"", name = "1", fields = listOf()) + val docQuery2 = DocLevelQuery(query = "test_field_1:\"test_value_1\"", name = "2", fields = listOf()) + val docQuery3 = DocLevelQuery(query = "test_field_1:\"test_value_3\"", name = "3", fields = listOf()) val docLevelInput = DocLevelMonitorInput("description", listOf(index), listOf(docQuery1, docQuery2, docQuery3)) val docTrigger = randomDocumentLevelTrigger(condition = ALWAYS_RUN) val docCustomAlertsIndex = "custom_alerts_index" @@ -3471,8 +3471,8 @@ class MonitorDataSourcesIT : AlertingSingleNodeTestCase() { } fun `test execute with custom alerts and finding index with bucket and doc monitor when doc monitor is used in chained finding`() { - val docQuery1 = DocLevelQuery(query = "test_field_1:\"test_value_2\"", name = "1") - val docQuery2 = DocLevelQuery(query = "test_field_1:\"test_value_3\"", name = "2") + val docQuery1 = DocLevelQuery(query = "test_field_1:\"test_value_2\"", name = "1", fields = listOf()) + val docQuery2 = DocLevelQuery(query = "test_field_1:\"test_value_3\"", name = "2", fields = listOf()) var docLevelMonitor = randomDocumentLevelMonitor( inputs = listOf(DocLevelMonitorInput("description", listOf(index), listOf(docQuery1, docQuery2))), @@ -3704,7 +3704,7 @@ class MonitorDataSourcesIT : AlertingSingleNodeTestCase() { fun `test execute workflow input error`() { val docLevelInput = DocLevelMonitorInput( - "description", listOf(index), listOf(DocLevelQuery(query = "source.ip.v6.v1:12345", name = "3")) + "description", listOf(index), listOf(DocLevelQuery(query = "source.ip.v6.v1:12345", name = "3", fields = listOf())) ) val trigger = randomDocumentLevelTrigger(condition = ALWAYS_RUN) @@ -3733,7 +3733,7 @@ class MonitorDataSourcesIT : AlertingSingleNodeTestCase() { fun `test execute workflow wrong workflow id`() { val docLevelInput = DocLevelMonitorInput( - "description", listOf(index), listOf(DocLevelQuery(query = "source.ip.v6.v1:12345", name = "3")) + "description", listOf(index), listOf(DocLevelQuery(query = "source.ip.v6.v1:12345", name = "3", fields = listOf())) ) val trigger = randomDocumentLevelTrigger(condition = ALWAYS_RUN) @@ -3925,7 +3925,7 @@ class MonitorDataSourcesIT : AlertingSingleNodeTestCase() { ) assertNotNull("The bucket monitor was not created", bucketMonitor) - val docQuery1 = DocLevelQuery(query = "test_field_1:\"a\"", name = "3") + val docQuery1 = DocLevelQuery(query = "test_field_1:\"a\"", name = "3", fields = listOf()) var monitor1 = randomDocumentLevelMonitor( inputs = listOf(DocLevelMonitorInput("description", listOf(TEST_HR_INDEX), listOf(docQuery1))), triggers = listOf(randomDocumentLevelTrigger(condition = ALWAYS_RUN)) @@ -3978,7 +3978,7 @@ class MonitorDataSourcesIT : AlertingSingleNodeTestCase() { } fun `test chained alerts for AND OR and NOT conditions with custom alerts indices`() { - val docQuery1 = DocLevelQuery(query = "test_field_1:\"us-west-2\"", name = "3") + val docQuery1 = DocLevelQuery(query = "test_field_1:\"us-west-2\"", name = "3", fields = listOf()) val docLevelInput1 = DocLevelMonitorInput("description", listOf(index), listOf(docQuery1)) val trigger1 = randomDocumentLevelTrigger(condition = ALWAYS_RUN) val customFindingsIndex1 = "custom_findings_index" @@ -3999,7 +3999,7 @@ class MonitorDataSourcesIT : AlertingSingleNodeTestCase() { ) val monitorResponse = createMonitor(monitor1)!! - val docQuery2 = DocLevelQuery(query = "source.ip.v6.v2:16645", name = "4") + val docQuery2 = DocLevelQuery(query = "source.ip.v6.v2:16645", name = "4", fields = listOf()) val docLevelInput2 = DocLevelMonitorInput("description", listOf(index), listOf(docQuery2)) val trigger2 = randomDocumentLevelTrigger(condition = ALWAYS_RUN) val customFindingsIndex2 = "custom_findings_index_2" @@ -4130,7 +4130,7 @@ class MonitorDataSourcesIT : AlertingSingleNodeTestCase() { } fun `test chained alerts for AND OR and NOT conditions`() { - val docQuery1 = DocLevelQuery(query = "test_field_1:\"us-west-2\"", name = "3") + val docQuery1 = DocLevelQuery(query = "test_field_1:\"us-west-2\"", name = "3", fields = listOf()) val docLevelInput1 = DocLevelMonitorInput("description", listOf(index), listOf(docQuery1)) val trigger1 = randomDocumentLevelTrigger(condition = ALWAYS_RUN) val customFindingsIndex1 = "custom_findings_index" @@ -4145,7 +4145,7 @@ class MonitorDataSourcesIT : AlertingSingleNodeTestCase() { ) val monitorResponse = createMonitor(monitor1)!! - val docQuery2 = DocLevelQuery(query = "source.ip.v6.v2:16645", name = "4") + val docQuery2 = DocLevelQuery(query = "source.ip.v6.v2:16645", name = "4", fields = listOf()) val docLevelInput2 = DocLevelMonitorInput("description", listOf(index), listOf(docQuery2)) val trigger2 = randomDocumentLevelTrigger(condition = ALWAYS_RUN) val customFindingsIndex2 = "custom_findings_index_2" @@ -4314,7 +4314,7 @@ class MonitorDataSourcesIT : AlertingSingleNodeTestCase() { ) = "${workflowMetadata!!.id}-${monitorResponse.id}-metadata" fun `test create workflow success`() { - val docQuery1 = DocLevelQuery(query = "source.ip.v6.v1:12345", name = "3") + val docQuery1 = DocLevelQuery(query = "source.ip.v6.v1:12345", name = "3", fields = listOf()) val docLevelInput = DocLevelMonitorInput( "description", listOf(index), listOf(docQuery1) ) @@ -4385,7 +4385,7 @@ class MonitorDataSourcesIT : AlertingSingleNodeTestCase() { } fun `test update workflow add monitor success`() { - val docQuery1 = DocLevelQuery(query = "source.ip.v6.v1:12345", name = "3") + val docQuery1 = DocLevelQuery(query = "source.ip.v6.v1:12345", name = "3", fields = listOf()) val docLevelInput = DocLevelMonitorInput( "description", listOf(index), listOf(docQuery1) ) @@ -4490,7 +4490,7 @@ class MonitorDataSourcesIT : AlertingSingleNodeTestCase() { } fun `test update workflow change order of delegate monitors`() { - val docQuery1 = DocLevelQuery(query = "source.ip.v6.v1:12345", name = "3") + val docQuery1 = DocLevelQuery(query = "source.ip.v6.v1:12345", name = "3", fields = listOf()) val docLevelInput = DocLevelMonitorInput( "description", listOf(index), listOf(docQuery1) ) @@ -4576,7 +4576,7 @@ class MonitorDataSourcesIT : AlertingSingleNodeTestCase() { } fun `test update workflow remove monitor success`() { - val docQuery1 = DocLevelQuery(query = "source.ip.v6.v1:12345", name = "3") + val docQuery1 = DocLevelQuery(query = "source.ip.v6.v1:12345", name = "3", fields = listOf()) val docLevelInput = DocLevelMonitorInput( "description", listOf(index), listOf(docQuery1) ) @@ -4654,7 +4654,7 @@ class MonitorDataSourcesIT : AlertingSingleNodeTestCase() { } fun `test update workflow doesn't exist failure`() { - val docQuery1 = DocLevelQuery(query = "source.ip.v6.v1:12345", name = "3") + val docQuery1 = DocLevelQuery(query = "source.ip.v6.v1:12345", name = "3", fields = listOf()) val docLevelInput = DocLevelMonitorInput( "description", listOf(index), listOf(docQuery1) ) @@ -4694,7 +4694,7 @@ class MonitorDataSourcesIT : AlertingSingleNodeTestCase() { fun `test get workflow`() { val docLevelInput = DocLevelMonitorInput( - "description", listOf(index), listOf(DocLevelQuery(query = "source.ip.v6.v1:12345", name = "3")) + "description", listOf(index), listOf(DocLevelQuery(query = "source.ip.v6.v1:12345", name = "3", fields = listOf())) ) val trigger = randomDocumentLevelTrigger(condition = ALWAYS_RUN) val monitor = randomDocumentLevelMonitor( @@ -4752,7 +4752,7 @@ class MonitorDataSourcesIT : AlertingSingleNodeTestCase() { fun `test get workflow for invalid id monitor index exists`() { val docLevelInput = DocLevelMonitorInput( - "description", listOf(index), listOf(DocLevelQuery(query = "source.ip.v6.v1:12345", name = "3")) + "description", listOf(index), listOf(DocLevelQuery(query = "source.ip.v6.v1:12345", name = "3", fields = listOf())) ) val trigger = randomDocumentLevelTrigger(condition = ALWAYS_RUN) val monitor = randomDocumentLevelMonitor( @@ -4775,7 +4775,7 @@ class MonitorDataSourcesIT : AlertingSingleNodeTestCase() { fun `test delete workflow keeping delegate monitor`() { val docLevelInput = DocLevelMonitorInput( - "description", listOf(index), listOf(DocLevelQuery(query = "source.ip.v6.v1:12345", name = "3")) + "description", listOf(index), listOf(DocLevelQuery(query = "source.ip.v6.v1:12345", name = "3", fields = listOf())) ) val trigger = randomDocumentLevelTrigger(condition = ALWAYS_RUN) @@ -4815,7 +4815,7 @@ class MonitorDataSourcesIT : AlertingSingleNodeTestCase() { fun `test delete workflow delegate monitor deleted`() { val docLevelInput = DocLevelMonitorInput( - "description", listOf(index), listOf(DocLevelQuery(query = "source.ip.v6.v1:12345", name = "3")) + "description", listOf(index), listOf(DocLevelQuery(query = "source.ip.v6.v1:12345", name = "3", fields = listOf())) ) val trigger = randomDocumentLevelTrigger(condition = ALWAYS_RUN) @@ -4862,7 +4862,7 @@ class MonitorDataSourcesIT : AlertingSingleNodeTestCase() { } fun `test delete executed workflow with metadata deleted`() { - val docQuery1 = DocLevelQuery(query = "test_field_1:\"us-west-2\"", name = "3") + val docQuery1 = DocLevelQuery(query = "test_field_1:\"us-west-2\"", name = "3", fields = listOf()) val docLevelInput1 = DocLevelMonitorInput("description", listOf(index), listOf(docQuery1)) val trigger1 = randomDocumentLevelTrigger(condition = ALWAYS_RUN) var monitor1 = randomDocumentLevelMonitor( @@ -4871,7 +4871,7 @@ class MonitorDataSourcesIT : AlertingSingleNodeTestCase() { ) val monitorResponse = createMonitor(monitor1)!! - val docQuery2 = DocLevelQuery(query = "source.ip.v6.v2:16645", name = "4") + val docQuery2 = DocLevelQuery(query = "source.ip.v6.v2:16645", name = "4", fields = listOf()) val docLevelInput2 = DocLevelMonitorInput("description", listOf(index), listOf(docQuery2)) val trigger2 = randomDocumentLevelTrigger(condition = ALWAYS_RUN) var monitor2 = randomDocumentLevelMonitor( @@ -4968,7 +4968,7 @@ class MonitorDataSourcesIT : AlertingSingleNodeTestCase() { fun `test delete workflow delegate monitor part of another workflow not deleted`() { val docLevelInput = DocLevelMonitorInput( - "description", listOf(index), listOf(DocLevelQuery(query = "source.ip.v6.v1:12345", name = "3")) + "description", listOf(index), listOf(DocLevelQuery(query = "source.ip.v6.v1:12345", name = "3", fields = listOf())) ) val trigger = randomDocumentLevelTrigger(condition = ALWAYS_RUN) @@ -5015,7 +5015,7 @@ class MonitorDataSourcesIT : AlertingSingleNodeTestCase() { fun `test trying to delete monitor that is part of workflow sequence`() { val docLevelInput = DocLevelMonitorInput( - "description", listOf(index), listOf(DocLevelQuery(query = "source.ip.v6.v1:12345", name = "3")) + "description", listOf(index), listOf(DocLevelQuery(query = "source.ip.v6.v1:12345", name = "3", fields = listOf())) ) val trigger = randomDocumentLevelTrigger(condition = ALWAYS_RUN) @@ -5066,7 +5066,7 @@ class MonitorDataSourcesIT : AlertingSingleNodeTestCase() { fun `test delete workflow for invalid id monitor index exists`() { val docLevelInput = DocLevelMonitorInput( - "description", listOf(index), listOf(DocLevelQuery(query = "source.ip.v6.v1:12345", name = "3")) + "description", listOf(index), listOf(DocLevelQuery(query = "source.ip.v6.v1:12345", name = "3", fields = listOf())) ) val trigger = randomDocumentLevelTrigger(condition = ALWAYS_RUN) @@ -5126,7 +5126,7 @@ class MonitorDataSourcesIT : AlertingSingleNodeTestCase() { fun `test update workflow without delegate failure`() { val docLevelInput = DocLevelMonitorInput( - "description", listOf(index), listOf(DocLevelQuery(query = "source.ip.v6.v1:12345", name = "3")) + "description", listOf(index), listOf(DocLevelQuery(query = "source.ip.v6.v1:12345", name = "3", fields = listOf())) ) val trigger = randomDocumentLevelTrigger(condition = ALWAYS_RUN) val monitor1 = randomDocumentLevelMonitor( @@ -5183,7 +5183,7 @@ class MonitorDataSourcesIT : AlertingSingleNodeTestCase() { fun `test update workflow duplicate delegate failure`() { val docLevelInput = DocLevelMonitorInput( - "description", listOf(index), listOf(DocLevelQuery(query = "source.ip.v6.v1:12345", name = "3")) + "description", listOf(index), listOf(DocLevelQuery(query = "source.ip.v6.v1:12345", name = "3", fields = listOf())) ) val trigger = randomDocumentLevelTrigger(condition = ALWAYS_RUN) val monitor = randomDocumentLevelMonitor( @@ -5218,7 +5218,7 @@ class MonitorDataSourcesIT : AlertingSingleNodeTestCase() { fun `test create workflow delegate monitor doesn't exist failure`() { val docLevelInput = DocLevelMonitorInput( - "description", listOf(index), listOf(DocLevelQuery(query = "source.ip.v6.v1:12345", name = "3")) + "description", listOf(index), listOf(DocLevelQuery(query = "source.ip.v6.v1:12345", name = "3", fields = listOf())) ) val trigger = randomDocumentLevelTrigger(condition = ALWAYS_RUN) @@ -5245,7 +5245,7 @@ class MonitorDataSourcesIT : AlertingSingleNodeTestCase() { fun `test update workflow delegate monitor doesn't exist failure`() { val docLevelInput = DocLevelMonitorInput( - "description", listOf(index), listOf(DocLevelQuery(query = "source.ip.v6.v1:12345", name = "3")) + "description", listOf(index), listOf(DocLevelQuery(query = "source.ip.v6.v1:12345", name = "3", fields = listOf())) ) val trigger = randomDocumentLevelTrigger(condition = ALWAYS_RUN) @@ -5301,7 +5301,7 @@ class MonitorDataSourcesIT : AlertingSingleNodeTestCase() { fun `test update workflow sequence order not correct failure`() { val docLevelInput = DocLevelMonitorInput( - "description", listOf(index), listOf(DocLevelQuery(query = "source.ip.v6.v1:12345", name = "3")) + "description", listOf(index), listOf(DocLevelQuery(query = "source.ip.v6.v1:12345", name = "3", fields = listOf())) ) val trigger = randomDocumentLevelTrigger(condition = ALWAYS_RUN) @@ -5362,7 +5362,7 @@ class MonitorDataSourcesIT : AlertingSingleNodeTestCase() { fun `test create workflow query monitor chained findings monitor failure`() { val docLevelInput = DocLevelMonitorInput( - "description", listOf(index), listOf(DocLevelQuery(query = "source.ip.v6.v1:12345", name = "3")) + "description", listOf(index), listOf(DocLevelQuery(query = "source.ip.v6.v1:12345", name = "3", fields = listOf())) ) val trigger = randomDocumentLevelTrigger(condition = ALWAYS_RUN) @@ -5392,7 +5392,7 @@ class MonitorDataSourcesIT : AlertingSingleNodeTestCase() { fun `test create workflow delegate and chained finding monitor different indices failure`() { val docLevelInput = DocLevelMonitorInput( - "description", listOf(index), listOf(DocLevelQuery(query = "source.ip.v6.v1:12345", name = "3")) + "description", listOf(index), listOf(DocLevelQuery(query = "source.ip.v6.v1:12345", name = "3", fields = listOf())) ) val trigger = randomDocumentLevelTrigger(condition = ALWAYS_RUN) @@ -5406,7 +5406,7 @@ class MonitorDataSourcesIT : AlertingSingleNodeTestCase() { createTestIndex(index1) val docLevelInput1 = DocLevelMonitorInput( - "description", listOf(index1), listOf(DocLevelQuery(query = "source.ip.v6.v1:12345", name = "3")) + "description", listOf(index1), listOf(DocLevelQuery(query = "source.ip.v6.v1:12345", name = "3", fields = listOf())) ) val docMonitor1 = randomDocumentLevelMonitor( @@ -5452,7 +5452,7 @@ class MonitorDataSourcesIT : AlertingSingleNodeTestCase() { fun `test update workflow chained findings monitor not in sequence failure`() { val docLevelInput = DocLevelMonitorInput( - "description", listOf(index), listOf(DocLevelQuery(query = "source.ip.v6.v1:12345", name = "3")) + "description", listOf(index), listOf(DocLevelQuery(query = "source.ip.v6.v1:12345", name = "3", fields = listOf())) ) val trigger = randomDocumentLevelTrigger(condition = ALWAYS_RUN) @@ -5514,7 +5514,7 @@ class MonitorDataSourcesIT : AlertingSingleNodeTestCase() { fun `test update workflow chained findings order not correct failure`() { val docLevelInput = DocLevelMonitorInput( - "description", listOf(index), listOf(DocLevelQuery(query = "source.ip.v6.v1:12345", name = "3")) + "description", listOf(index), listOf(DocLevelQuery(query = "source.ip.v6.v1:12345", name = "3", fields = listOf())) ) val trigger = randomDocumentLevelTrigger(condition = ALWAYS_RUN) @@ -5552,7 +5552,7 @@ class MonitorDataSourcesIT : AlertingSingleNodeTestCase() { } fun `test create workflow with chained alert triggers`() { - val docQuery1 = DocLevelQuery(query = "source.ip.v6.v1:12345", name = "3") + val docQuery1 = DocLevelQuery(query = "source.ip.v6.v1:12345", name = "3", fields = listOf()) val docLevelInput = DocLevelMonitorInput( "description", listOf(index), listOf(docQuery1) ) @@ -5617,7 +5617,7 @@ class MonitorDataSourcesIT : AlertingSingleNodeTestCase() { } fun `test postIndex on workflow update with trigger deletion`() { - val docQuery1 = DocLevelQuery(query = "test_field_1:\"us-west-2\"", name = "3") + val docQuery1 = DocLevelQuery(query = "test_field_1:\"us-west-2\"", name = "3", fields = listOf()) val docLevelInput1 = DocLevelMonitorInput("description", listOf(index), listOf(docQuery1)) val trigger1 = randomDocumentLevelTrigger(condition = ALWAYS_RUN) var monitor1 = randomDocumentLevelMonitor( @@ -5691,7 +5691,7 @@ class MonitorDataSourcesIT : AlertingSingleNodeTestCase() { } fun `test postDelete on workflow deletion`() { - val docQuery1 = DocLevelQuery(query = "test_field_1:\"us-west-2\"", name = "3") + val docQuery1 = DocLevelQuery(query = "test_field_1:\"us-west-2\"", name = "3", fields = listOf()) val docLevelInput1 = DocLevelMonitorInput("description", listOf(index), listOf(docQuery1)) val trigger1 = randomDocumentLevelTrigger(condition = ALWAYS_RUN) var monitor1 = randomDocumentLevelMonitor( @@ -5759,7 +5759,7 @@ class MonitorDataSourcesIT : AlertingSingleNodeTestCase() { } fun `test get chained alerts with alertId paginating for associated alerts`() { - val docQuery1 = DocLevelQuery(query = "test_field_1:\"us-west-2\"", name = "3") + val docQuery1 = DocLevelQuery(query = "test_field_1:\"us-west-2\"", name = "3", fields = listOf()) val docLevelInput1 = DocLevelMonitorInput("description", listOf(index), listOf(docQuery1)) val trigger1 = randomDocumentLevelTrigger(condition = ALWAYS_RUN) var monitor1 = randomDocumentLevelMonitor( @@ -5838,7 +5838,7 @@ class MonitorDataSourcesIT : AlertingSingleNodeTestCase() { } fun `test existing chained alert active alert is updated on consequtive trigger condition match`() { - val docQuery1 = DocLevelQuery(query = "test_field_1:\"us-west-2\"", name = "3") + val docQuery1 = DocLevelQuery(query = "test_field_1:\"us-west-2\"", name = "3", fields = listOf()) val docLevelInput1 = DocLevelMonitorInput("description", listOf(index), listOf(docQuery1)) val trigger1 = randomDocumentLevelTrigger(condition = ALWAYS_RUN) var monitor1 = randomDocumentLevelMonitor( diff --git a/alerting/src/test/kotlin/org/opensearch/alerting/MonitorRunnerServiceIT.kt b/alerting/src/test/kotlin/org/opensearch/alerting/MonitorRunnerServiceIT.kt index 63b4d8286..8d31aa227 100644 --- a/alerting/src/test/kotlin/org/opensearch/alerting/MonitorRunnerServiceIT.kt +++ b/alerting/src/test/kotlin/org/opensearch/alerting/MonitorRunnerServiceIT.kt @@ -200,7 +200,7 @@ class MonitorRunnerServiceIT : AlertingRestTestCase() { // use a non-existent monitoid to trigger a 404. val index = "foo" createIndex(index, Settings.EMPTY) - val docQuery = DocLevelQuery(query = "test_field:\"us-west-2\"", name = "1") + val docQuery = DocLevelQuery(query = "test_field:\"us-west-2\"", name = "1", fields = listOf()) val docLevelInput = DocLevelMonitorInput("description", listOf(index), listOf(docQuery)) val monitor = createMonitor( randomDocumentLevelMonitor( diff --git a/alerting/src/test/kotlin/org/opensearch/alerting/TestHelpers.kt b/alerting/src/test/kotlin/org/opensearch/alerting/TestHelpers.kt index 5ce746fda..143a77afd 100644 --- a/alerting/src/test/kotlin/org/opensearch/alerting/TestHelpers.kt +++ b/alerting/src/test/kotlin/org/opensearch/alerting/TestHelpers.kt @@ -475,7 +475,7 @@ fun randomDocLevelQuery( name: String = "${randomInt(5)}", tags: List = mutableListOf(0..randomInt(10)).map { OpenSearchRestTestCase.randomAlphaOfLength(10) } ): DocLevelQuery { - return DocLevelQuery(id = id, query = query, name = name, tags = tags) + return DocLevelQuery(id = id, query = query, name = name, tags = tags, fields = listOf()) } fun randomDocLevelMonitorInput( diff --git a/alerting/src/test/kotlin/org/opensearch/alerting/alerts/AlertIndicesIT.kt b/alerting/src/test/kotlin/org/opensearch/alerting/alerts/AlertIndicesIT.kt index 948801296..8d3a533c2 100644 --- a/alerting/src/test/kotlin/org/opensearch/alerting/alerts/AlertIndicesIT.kt +++ b/alerting/src/test/kotlin/org/opensearch/alerting/alerts/AlertIndicesIT.kt @@ -37,7 +37,7 @@ class AlertIndicesIT : AlertingRestTestCase() { fun `test create finding index`() { val testIndex = createTestIndex() - val docQuery = DocLevelQuery(query = "test_field:\"us-west-2\"", name = "3") + val docQuery = DocLevelQuery(query = "test_field:\"us-west-2\"", name = "3", fields = listOf()) val docLevelInput = DocLevelMonitorInput("description", listOf(testIndex), listOf(docQuery)) val trigger = randomDocumentLevelTrigger(condition = ALWAYS_RUN) val monitor = createMonitor(randomDocumentLevelMonitor(inputs = listOf(docLevelInput), triggers = listOf(trigger))) @@ -82,7 +82,7 @@ class AlertIndicesIT : AlertingRestTestCase() { wipeAllODFEIndices() val testIndex = createTestIndex() - val docQuery = DocLevelQuery(query = "test_field:\"us-west-2\"", name = "3") + val docQuery = DocLevelQuery(query = "test_field:\"us-west-2\"", name = "3", fields = listOf()) val docLevelInput = DocLevelMonitorInput("description", listOf(testIndex), listOf(docQuery)) val trigger = randomDocumentLevelTrigger(condition = ALWAYS_RUN) val trueMonitor = createMonitor(randomDocumentLevelMonitor(inputs = listOf(docLevelInput), triggers = listOf(trigger))) @@ -114,7 +114,7 @@ class AlertIndicesIT : AlertingRestTestCase() { wipeAllODFEIndices() assertIndexDoesNotExist(AlertIndices.FINDING_HISTORY_WRITE_INDEX) val testIndex = createTestIndex() - val docQuery = DocLevelQuery(query = "test_field:\"us-west-2\"", name = "3") + val docQuery = DocLevelQuery(query = "test_field:\"us-west-2\"", name = "3", fields = listOf()) val docLevelInput = DocLevelMonitorInput("description", listOf(testIndex), listOf(docQuery)) val trigger = randomDocumentLevelTrigger(condition = ALWAYS_RUN) val trueMonitor = createMonitor(randomDocumentLevelMonitor(inputs = listOf(docLevelInput), triggers = listOf(trigger))) @@ -150,7 +150,7 @@ class AlertIndicesIT : AlertingRestTestCase() { client().updateSettings(AlertingSettings.FINDING_HISTORY_INDEX_MAX_AGE.key, "1s") val testIndex = createTestIndex() - val docQuery = DocLevelQuery(query = "test_field:\"us-west-2\"", name = "3") + val docQuery = DocLevelQuery(query = "test_field:\"us-west-2\"", name = "3", fields = listOf()) val docLevelInput = DocLevelMonitorInput("description", listOf(testIndex), listOf(docQuery)) val trigger = randomDocumentLevelTrigger(condition = ALWAYS_RUN) val trueMonitor = createMonitor(randomDocumentLevelMonitor(inputs = listOf(docLevelInput), triggers = listOf(trigger))) @@ -260,7 +260,7 @@ class AlertIndicesIT : AlertingRestTestCase() { // Create monitor and execute val testIndex = createTestIndex() - val docQuery = DocLevelQuery(query = "test_field:\"us-west-2\"", name = "3") + val docQuery = DocLevelQuery(query = "test_field:\"us-west-2\"", name = "3", fields = listOf()) val docLevelInput = DocLevelMonitorInput("description", listOf(testIndex), listOf(docQuery)) val trigger = randomDocumentLevelTrigger(condition = ALWAYS_RUN) val monitor = createMonitor(randomDocumentLevelMonitor(inputs = listOf(docLevelInput), triggers = listOf(trigger))) diff --git a/alerting/src/test/kotlin/org/opensearch/alerting/resthandler/FindingsRestApiIT.kt b/alerting/src/test/kotlin/org/opensearch/alerting/resthandler/FindingsRestApiIT.kt index dc61468a8..1839bc807 100644 --- a/alerting/src/test/kotlin/org/opensearch/alerting/resthandler/FindingsRestApiIT.kt +++ b/alerting/src/test/kotlin/org/opensearch/alerting/resthandler/FindingsRestApiIT.kt @@ -19,7 +19,7 @@ class FindingsRestApiIT : AlertingRestTestCase() { fun `test find Finding where doc is not retrieved`() { val testIndex = createTestIndex() - val docQuery = DocLevelQuery(query = "test_field:\"us-west-2\"", name = "3") + val docQuery = DocLevelQuery(query = "test_field:\"us-west-2\"", name = "3", fields = listOf()) val docLevelInput = DocLevelMonitorInput("description", listOf(testIndex), listOf(docQuery)) val trigger = randomDocumentLevelTrigger(condition = ALWAYS_RUN) val trueMonitor = createMonitor(randomDocumentLevelMonitor(inputs = listOf(docLevelInput), triggers = listOf(trigger))) @@ -44,7 +44,7 @@ class FindingsRestApiIT : AlertingRestTestCase() { }""" indexDoc(testIndex, "someId2", testDoc2) - val docQuery = DocLevelQuery(query = "test_field:\"us-west-2\"", name = "3") + val docQuery = DocLevelQuery(query = "test_field:\"us-west-2\"", name = "3", fields = listOf()) val docLevelInput = DocLevelMonitorInput("description", listOf(testIndex), listOf(docQuery)) val trigger = randomDocumentLevelTrigger(condition = ALWAYS_RUN) val trueMonitor = createMonitor(randomDocumentLevelMonitor(inputs = listOf(docLevelInput), triggers = listOf(trigger))) @@ -84,7 +84,7 @@ class FindingsRestApiIT : AlertingRestTestCase() { }""" indexDoc(testIndex, "someId2", testDoc2) - val docQuery = DocLevelQuery(query = "test_field:\"us-west-2\"", name = "3") + val docQuery = DocLevelQuery(query = "test_field:\"us-west-2\"", name = "3", fields = listOf()) val docLevelInput = DocLevelMonitorInput("description", listOf(testIndex), listOf(docQuery)) val trigger = randomDocumentLevelTrigger(condition = ALWAYS_RUN) val trueMonitor = createMonitor(randomDocumentLevelMonitor(inputs = listOf(docLevelInput), triggers = listOf(trigger))) @@ -115,7 +115,7 @@ class FindingsRestApiIT : AlertingRestTestCase() { }""" indexDoc(testIndex, "someId2", testDoc2) - val docLevelQuery = DocLevelQuery(query = "test_field:\"us-west-2\"", name = "realQuery", tags = listOf("sigma")) + val docLevelQuery = DocLevelQuery(query = "test_field:\"us-west-2\"", name = "realQuery", fields = listOf(), tags = listOf("sigma")) val docLevelInput = DocLevelMonitorInput("description", listOf(testIndex), listOf(docLevelQuery)) val trigger = randomDocumentLevelTrigger(condition = ALWAYS_RUN) val trueMonitor = createMonitor(randomDocumentLevelMonitor(inputs = listOf(docLevelInput), triggers = listOf(trigger))) @@ -150,7 +150,7 @@ class FindingsRestApiIT : AlertingRestTestCase() { }""" indexDoc(testIndex, "someId2", testDoc2) - val docLevelQuery = DocLevelQuery(query = "test_field:\"us-west-2\"", name = "realQuery", tags = listOf("sigma")) + val docLevelQuery = DocLevelQuery(query = "test_field:\"us-west-2\"", name = "realQuery", fields = listOf(), tags = listOf("sigma")) val docLevelInput = DocLevelMonitorInput("description", listOf(testIndex), listOf(docLevelQuery)) val trigger = randomDocumentLevelTrigger(condition = ALWAYS_RUN) val trueMonitor = createMonitor(randomDocumentLevelMonitor(inputs = listOf(docLevelInput), triggers = listOf(trigger))) @@ -185,7 +185,7 @@ class FindingsRestApiIT : AlertingRestTestCase() { }""" indexDoc(testIndex, "someId2", testDoc2) - val docLevelQuery = DocLevelQuery(query = "test_field:\"us-west-2\"", name = "realQuery", tags = listOf("sigma")) + val docLevelQuery = DocLevelQuery(query = "test_field:\"us-west-2\"", name = "realQuery", fields = listOf(), tags = listOf("sigma")) val docLevelInput = DocLevelMonitorInput("description", listOf(testIndex), listOf(docLevelQuery)) val trigger = randomDocumentLevelTrigger(condition = ALWAYS_RUN) val trueMonitor = createMonitor(randomDocumentLevelMonitor(inputs = listOf(docLevelInput), triggers = listOf(trigger))) diff --git a/alerting/src/test/kotlin/org/opensearch/alerting/resthandler/MonitorRestApiIT.kt b/alerting/src/test/kotlin/org/opensearch/alerting/resthandler/MonitorRestApiIT.kt index 000364bf0..eccea22f5 100644 --- a/alerting/src/test/kotlin/org/opensearch/alerting/resthandler/MonitorRestApiIT.kt +++ b/alerting/src/test/kotlin/org/opensearch/alerting/resthandler/MonitorRestApiIT.kt @@ -1154,7 +1154,7 @@ class MonitorRestApiIT : AlertingRestTestCase() { @Throws(Exception::class) fun `test creating a document monitor`() { val testIndex = createTestIndex() - val docQuery = DocLevelQuery(query = "test_field:\"us-west-2\"", name = "3") + val docQuery = DocLevelQuery(query = "test_field:\"us-west-2\"", name = "3", fields = listOf()) val docLevelInput = DocLevelMonitorInput("description", listOf(testIndex), listOf(docQuery)) val trigger = randomDocumentLevelTrigger(condition = ALWAYS_RUN) @@ -1175,7 +1175,7 @@ class MonitorRestApiIT : AlertingRestTestCase() { @Throws(Exception::class) fun `test getting a document level monitor`() { val testIndex = createTestIndex() - val docQuery = DocLevelQuery(query = "test_field:\"us-west-2\"", name = "3") + val docQuery = DocLevelQuery(query = "test_field:\"us-west-2\"", name = "3", fields = listOf()) val docLevelInput = DocLevelMonitorInput("description", listOf(testIndex), listOf(docQuery)) val trigger = randomDocumentLevelTrigger(condition = ALWAYS_RUN) @@ -1191,7 +1191,7 @@ class MonitorRestApiIT : AlertingRestTestCase() { @Throws(Exception::class) fun `test updating conditions for a doc-level monitor`() { val testIndex = createTestIndex() - val docQuery = DocLevelQuery(query = "test_field:\"us-west-2\"", name = "3") + val docQuery = DocLevelQuery(query = "test_field:\"us-west-2\"", name = "3", fields = listOf()) val docLevelInput = DocLevelMonitorInput("description", listOf(testIndex), listOf(docQuery)) val trigger = randomDocumentLevelTrigger(condition = ALWAYS_RUN) @@ -1222,7 +1222,7 @@ class MonitorRestApiIT : AlertingRestTestCase() { @Throws(Exception::class) fun `test deleting a document level monitor`() { val testIndex = createTestIndex() - val docQuery = DocLevelQuery(query = "test_field:\"us-west-2\"", name = "3") + val docQuery = DocLevelQuery(query = "test_field:\"us-west-2\"", name = "3", fields = listOf()) val docLevelInput = DocLevelMonitorInput("description", listOf(testIndex), listOf(docQuery)) val trigger = randomDocumentLevelTrigger(condition = ALWAYS_RUN) diff --git a/alerting/src/test/kotlin/org/opensearch/alerting/resthandler/SecureWorkflowRestApiIT.kt b/alerting/src/test/kotlin/org/opensearch/alerting/resthandler/SecureWorkflowRestApiIT.kt index 606ff9bc5..bad2f913b 100644 --- a/alerting/src/test/kotlin/org/opensearch/alerting/resthandler/SecureWorkflowRestApiIT.kt +++ b/alerting/src/test/kotlin/org/opensearch/alerting/resthandler/SecureWorkflowRestApiIT.kt @@ -1395,7 +1395,7 @@ class SecureWorkflowRestApiIT : AlertingRestTestCase() { ) assertNotNull("The bucket monitor was not created", bucketMonitor) - val docQuery1 = DocLevelQuery(query = "test_field:\"a\"", name = "3") + val docQuery1 = DocLevelQuery(query = "test_field:\"a\"", name = "3", fields = listOf()) var monitor1 = randomDocumentLevelMonitor( inputs = listOf(DocLevelMonitorInput("description", listOf(TEST_HR_INDEX), listOf(docQuery1))), triggers = listOf(randomDocumentLevelTrigger(condition = ALWAYS_RUN)) diff --git a/alerting/src/test/kotlin/org/opensearch/alerting/resthandler/WorkflowRestApiIT.kt b/alerting/src/test/kotlin/org/opensearch/alerting/resthandler/WorkflowRestApiIT.kt index 9cd2c5e26..8c073c4b6 100644 --- a/alerting/src/test/kotlin/org/opensearch/alerting/resthandler/WorkflowRestApiIT.kt +++ b/alerting/src/test/kotlin/org/opensearch/alerting/resthandler/WorkflowRestApiIT.kt @@ -48,7 +48,7 @@ class WorkflowRestApiIT : AlertingRestTestCase() { fun `test create workflow success`() { val index = createTestIndex() - val docQuery1 = DocLevelQuery(query = "source.ip.v6.v1:12345", name = "3") + val docQuery1 = DocLevelQuery(query = "source.ip.v6.v1:12345", name = "3", fields = listOf()) val docLevelInput = DocLevelMonitorInput( "description", listOf(index), listOf(docQuery1) ) @@ -79,7 +79,7 @@ class WorkflowRestApiIT : AlertingRestTestCase() { fun `test create workflow with different monitor types success`() { val index = createTestIndex() - val docQuery = DocLevelQuery(query = "source.ip.v6.v1:12345", name = "3") + val docQuery = DocLevelQuery(query = "source.ip.v6.v1:12345", name = "3", fields = listOf()) val docLevelInput = DocLevelMonitorInput( "description", listOf(index), listOf(docQuery) ) @@ -193,7 +193,7 @@ class WorkflowRestApiIT : AlertingRestTestCase() { fun `test create workflow delegate monitor doesn't exist failure`() { val index = createTestIndex() - val docQuery = DocLevelQuery(query = "source.ip.v6.v1:12345", name = "3") + val docQuery = DocLevelQuery(query = "source.ip.v6.v1:12345", name = "3", fields = listOf()) val docLevelInput = DocLevelMonitorInput( "description", listOf(index), listOf(docQuery) ) @@ -315,7 +315,7 @@ class WorkflowRestApiIT : AlertingRestTestCase() { createTestIndex(index) val docLevelInput = DocLevelMonitorInput( - "description", listOf(index), listOf(DocLevelQuery(query = "source.ip.v6.v1:12345", name = "3")) + "description", listOf(index), listOf(DocLevelQuery(query = "source.ip.v6.v1:12345", name = "3", fields = listOf())) ) val trigger = randomDocumentLevelTrigger(condition = ALWAYS_RUN) @@ -329,7 +329,7 @@ class WorkflowRestApiIT : AlertingRestTestCase() { createTestIndex(index1) val docLevelInput1 = DocLevelMonitorInput( - "description", listOf(index1), listOf(DocLevelQuery(query = "source.ip.v6.v1:12345", name = "3")) + "description", listOf(index1), listOf(DocLevelQuery(query = "source.ip.v6.v1:12345", name = "3", fields = listOf())) ) val docMonitor1 = randomDocumentLevelMonitor( @@ -357,7 +357,7 @@ class WorkflowRestApiIT : AlertingRestTestCase() { fun `test create workflow query monitor chained findings monitor failure`() { val index = createTestIndex() val docLevelInput = DocLevelMonitorInput( - "description", listOf(index), listOf(DocLevelQuery(query = "source.ip.v6.v1:12345", name = "3")) + "description", listOf(index), listOf(DocLevelQuery(query = "source.ip.v6.v1:12345", name = "3", fields = listOf())) ) val trigger = randomDocumentLevelTrigger(condition = ALWAYS_RUN) @@ -409,7 +409,7 @@ class WorkflowRestApiIT : AlertingRestTestCase() { fun `test update workflow add monitor success`() { val index = createTestIndex() - val docQuery1 = DocLevelQuery(query = "source.ip.v6.v1:12345", name = "3") + val docQuery1 = DocLevelQuery(query = "source.ip.v6.v1:12345", name = "3", fields = listOf()) val docLevelInput = DocLevelMonitorInput( "description", listOf(index), listOf(docQuery1) ) @@ -483,7 +483,7 @@ class WorkflowRestApiIT : AlertingRestTestCase() { fun `test update workflow remove monitor success`() { val index = createTestIndex() - val docQuery1 = DocLevelQuery(query = "source.ip.v6.v1:12345", name = "3") + val docQuery1 = DocLevelQuery(query = "source.ip.v6.v1:12345", name = "3", fields = listOf()) val docLevelInput = DocLevelMonitorInput( "description", listOf(index), listOf(docQuery1) ) @@ -556,7 +556,7 @@ class WorkflowRestApiIT : AlertingRestTestCase() { fun `test update workflow change order of delegate monitors`() { val index = createTestIndex() - val docQuery1 = DocLevelQuery(query = "source.ip.v6.v1:12345", name = "3") + val docQuery1 = DocLevelQuery(query = "source.ip.v6.v1:12345", name = "3", fields = listOf()) val docLevelInput = DocLevelMonitorInput( "description", listOf(index), listOf(docQuery1) ) @@ -644,7 +644,7 @@ class WorkflowRestApiIT : AlertingRestTestCase() { fun `test update workflow doesn't exist failure`() { val index = createTestIndex() - val docQuery1 = DocLevelQuery(query = "source.ip.v6.v1:12345", name = "3") + val docQuery1 = DocLevelQuery(query = "source.ip.v6.v1:12345", name = "3", fields = listOf()) val docLevelInput = DocLevelMonitorInput( "description", listOf(index), listOf(docQuery1) ) @@ -681,7 +681,7 @@ class WorkflowRestApiIT : AlertingRestTestCase() { fun `test update workflow duplicate delegate failure`() { val index = createTestIndex() val docLevelInput = DocLevelMonitorInput( - "description", listOf(index), listOf(DocLevelQuery(query = "source.ip.v6.v1:12345", name = "3")) + "description", listOf(index), listOf(DocLevelQuery(query = "source.ip.v6.v1:12345", name = "3", fields = listOf())) ) val trigger = randomDocumentLevelTrigger(condition = ALWAYS_RUN) val monitor = randomDocumentLevelMonitor( @@ -718,7 +718,7 @@ class WorkflowRestApiIT : AlertingRestTestCase() { fun `test update workflow delegate monitor doesn't exist failure`() { val index = createTestIndex() val docLevelInput = DocLevelMonitorInput( - "description", listOf(index), listOf(DocLevelQuery(query = "source.ip.v6.v1:12345", name = "3")) + "description", listOf(index), listOf(DocLevelQuery(query = "source.ip.v6.v1:12345", name = "3", fields = listOf())) ) val trigger = randomDocumentLevelTrigger(condition = ALWAYS_RUN) @@ -755,7 +755,7 @@ class WorkflowRestApiIT : AlertingRestTestCase() { fun `test update workflow sequence order not correct failure`() { val index = createTestIndex() val docLevelInput = DocLevelMonitorInput( - "description", listOf(index), listOf(DocLevelQuery(query = "source.ip.v6.v1:12345", name = "3")) + "description", listOf(index), listOf(DocLevelQuery(query = "source.ip.v6.v1:12345", name = "3", fields = listOf())) ) val trigger = randomDocumentLevelTrigger(condition = ALWAYS_RUN) @@ -796,7 +796,7 @@ class WorkflowRestApiIT : AlertingRestTestCase() { fun `test update workflow chained findings monitor not in sequence failure`() { val index = createTestIndex() val docLevelInput = DocLevelMonitorInput( - "description", listOf(index), listOf(DocLevelQuery(query = "source.ip.v6.v1:12345", name = "3")) + "description", listOf(index), listOf(DocLevelQuery(query = "source.ip.v6.v1:12345", name = "3", fields = listOf())) ) val trigger = randomDocumentLevelTrigger(condition = ALWAYS_RUN) @@ -838,7 +838,7 @@ class WorkflowRestApiIT : AlertingRestTestCase() { fun `test update workflow chained findings order not correct failure`() { val index = createTestIndex() val docLevelInput = DocLevelMonitorInput( - "description", listOf(index), listOf(DocLevelQuery(query = "source.ip.v6.v1:12345", name = "3")) + "description", listOf(index), listOf(DocLevelQuery(query = "source.ip.v6.v1:12345", name = "3", fields = listOf())) ) val trigger = randomDocumentLevelTrigger(condition = ALWAYS_RUN) @@ -1025,7 +1025,7 @@ class WorkflowRestApiIT : AlertingRestTestCase() { fun `test chained alerts and audit alerts for workflows with query level monitor`() { val index = createTestIndex() - val docQuery1 = DocLevelQuery(query = "test_field:\"test_value_1\"", name = "3") + val docQuery1 = DocLevelQuery(query = "test_field:\"test_value_1\"", name = "3", fields = listOf()) val docLevelInput1 = DocLevelMonitorInput("description", listOf(index), listOf(docQuery1)) val trigger1 = randomDocumentLevelTrigger(condition = ALWAYS_RUN) var monitor1 = randomDocumentLevelMonitor( @@ -1143,7 +1143,7 @@ class WorkflowRestApiIT : AlertingRestTestCase() { fun `test run workflow as scheduled job success`() { val index = createTestIndex() - val docQuery1 = DocLevelQuery(query = "test_field:\"us-west-2\"", name = "3") + val docQuery1 = DocLevelQuery(query = "test_field:\"us-west-2\"", name = "3", fields = listOf()) val docLevelInput = DocLevelMonitorInput( "description", listOf(index), listOf(docQuery1) ) diff --git a/alerting/src/test/kotlin/org/opensearch/alerting/triggeraction/TriggerExpressionResolverTests.kt b/alerting/src/test/kotlin/org/opensearch/alerting/triggeraction/TriggerExpressionResolverTests.kt index 68f6ea33b..1dd19d9d1 100644 --- a/alerting/src/test/kotlin/org/opensearch/alerting/triggeraction/TriggerExpressionResolverTests.kt +++ b/alerting/src/test/kotlin/org/opensearch/alerting/triggeraction/TriggerExpressionResolverTests.kt @@ -16,8 +16,8 @@ class TriggerExpressionResolverTests : OpenSearchTestCase() { val eqString = "(query[name=sigma-123] && query[name=sigma-456])" val equation = TriggerExpressionParser(eqString).parse() val queryToDocIds = mutableMapOf>() - queryToDocIds[DocLevelQuery("", "sigma-123", "", emptyList())] = mutableSetOf("1", "2", "3") - queryToDocIds[DocLevelQuery("", "sigma-456", "", emptyList())] = mutableSetOf("1", "2", "3") + queryToDocIds[DocLevelQuery("", "sigma-123", listOf(), "", emptyList())] = mutableSetOf("1", "2", "3") + queryToDocIds[DocLevelQuery("", "sigma-456", listOf(), "", emptyList())] = mutableSetOf("1", "2", "3") Assert.assertEquals("query[name=sigma-123] query[name=sigma-456] && ", equation.toString()) Assert.assertEquals(mutableSetOf("1", "2", "3"), equation.evaluate(queryToDocIds)) } @@ -26,8 +26,8 @@ class TriggerExpressionResolverTests : OpenSearchTestCase() { val eqString = "(query[name=sigma-123] && query[id=id1456])" val equation = TriggerExpressionParser(eqString).parse() val queryToDocIds = mutableMapOf>() - queryToDocIds[DocLevelQuery("", "sigma-123", "", emptyList())] = mutableSetOf("6", "3", "7") - queryToDocIds[DocLevelQuery("id1456", "", "", emptyList())] = mutableSetOf("1", "2", "3") + queryToDocIds[DocLevelQuery("", "sigma-123", listOf(), "", emptyList())] = mutableSetOf("6", "3", "7") + queryToDocIds[DocLevelQuery("id1456", "", listOf(), "", emptyList())] = mutableSetOf("1", "2", "3") Assert.assertEquals("query[name=sigma-123] query[id=id1456] && ", equation.toString()) Assert.assertEquals(mutableSetOf("3"), equation.evaluate(queryToDocIds)) } @@ -36,8 +36,8 @@ class TriggerExpressionResolverTests : OpenSearchTestCase() { val eqString = "(query[name=sigma-123] && query[tag=sev2])" val equation = TriggerExpressionParser(eqString).parse() val queryToDocIds = mutableMapOf>() - queryToDocIds[DocLevelQuery("", "sigma-123", "", emptyList())] = mutableSetOf("6", "8", "7") - queryToDocIds[DocLevelQuery("", "", "", mutableListOf("tag=sev2"))] = mutableSetOf("1", "2", "3") + queryToDocIds[DocLevelQuery("", "sigma-123", listOf(), "", emptyList())] = mutableSetOf("6", "8", "7") + queryToDocIds[DocLevelQuery("", "", listOf(), "", mutableListOf("tag=sev2"))] = mutableSetOf("1", "2", "3") Assert.assertEquals("query[name=sigma-123] query[tag=sev2] && ", equation.toString()) Assert.assertEquals(emptySet(), equation.evaluate(queryToDocIds)) } @@ -46,8 +46,8 @@ class TriggerExpressionResolverTests : OpenSearchTestCase() { val eqString = "(query[name=sigma-123] || query[name=sigma-456])" val equation = TriggerExpressionParser(eqString).parse() val queryToDocIds = mutableMapOf>() - queryToDocIds[DocLevelQuery("", "sigma-123", "", emptyList())] = mutableSetOf("1", "2", "3") - queryToDocIds[DocLevelQuery("", "sigma-456", "", emptyList())] = mutableSetOf("1", "2", "3") + queryToDocIds[DocLevelQuery("", "sigma-123", listOf(), "", emptyList())] = mutableSetOf("1", "2", "3") + queryToDocIds[DocLevelQuery("", "sigma-456", listOf(), "", emptyList())] = mutableSetOf("1", "2", "3") Assert.assertEquals("query[name=sigma-123] query[name=sigma-456] || ", equation.toString()) Assert.assertEquals(mutableSetOf("1", "2", "3"), equation.evaluate(queryToDocIds)) } @@ -56,8 +56,8 @@ class TriggerExpressionResolverTests : OpenSearchTestCase() { val eqString = "(query[name=sigma-123] || query[id=id1456])" val equation = TriggerExpressionParser(eqString).parse() val queryToDocIds = mutableMapOf>() - queryToDocIds[DocLevelQuery("", "sigma-123", "", emptyList())] = mutableSetOf("6", "3", "7") - queryToDocIds[DocLevelQuery("id1456", "", "", emptyList())] = mutableSetOf("1", "2", "3") + queryToDocIds[DocLevelQuery("", "sigma-123", listOf(), "", emptyList())] = mutableSetOf("6", "3", "7") + queryToDocIds[DocLevelQuery("id1456", "", listOf(), "", emptyList())] = mutableSetOf("1", "2", "3") Assert.assertEquals("query[name=sigma-123] query[id=id1456] || ", equation.toString()) Assert.assertEquals(mutableSetOf("6", "3", "7", "1", "2", "3"), equation.evaluate(queryToDocIds)) } @@ -66,8 +66,8 @@ class TriggerExpressionResolverTests : OpenSearchTestCase() { val eqString = "(query[name=sigma-123] || query[tag=sev2])" val equation = TriggerExpressionParser(eqString).parse() val queryToDocIds = mutableMapOf>() - queryToDocIds[DocLevelQuery("", "sigma-123", "", emptyList())] = mutableSetOf("6", "8", "7") - queryToDocIds[DocLevelQuery("", "", "", mutableListOf("tag=sev2"))] = emptySet() + queryToDocIds[DocLevelQuery("", "sigma-123", listOf(), "", emptyList())] = mutableSetOf("6", "8", "7") + queryToDocIds[DocLevelQuery("", "", listOf(), "", mutableListOf("tag=sev2"))] = emptySet() Assert.assertEquals("query[name=sigma-123] query[tag=sev2] || ", equation.toString()) Assert.assertEquals(mutableSetOf("6", "8", "7"), equation.evaluate(queryToDocIds)) } @@ -76,8 +76,8 @@ class TriggerExpressionResolverTests : OpenSearchTestCase() { val eqString = "!(query[name=sigma-456])" val equation = TriggerExpressionParser(eqString).parse() val queryToDocIds = mutableMapOf>() - queryToDocIds[DocLevelQuery("", "sigma-123", "", emptyList())] = mutableSetOf("1", "2", "3") - queryToDocIds[DocLevelQuery("", "sigma-456", "", emptyList())] = mutableSetOf("4", "5", "6") + queryToDocIds[DocLevelQuery("", "sigma-123", listOf(), "", emptyList())] = mutableSetOf("1", "2", "3") + queryToDocIds[DocLevelQuery("", "sigma-456", listOf(), "", emptyList())] = mutableSetOf("4", "5", "6") Assert.assertEquals("query[name=sigma-456] ! ", equation.toString()) Assert.assertEquals(mutableSetOf("1", "2", "3"), equation.evaluate(queryToDocIds)) } @@ -86,9 +86,9 @@ class TriggerExpressionResolverTests : OpenSearchTestCase() { val eqString = "(query[name=sigma-123] && !query[name=sigma-456])" val equation = TriggerExpressionParser(eqString).parse() val queryToDocIds = mutableMapOf>() - queryToDocIds[DocLevelQuery("", "sigma-123", "", emptyList())] = mutableSetOf("1", "2", "3", "11") - queryToDocIds[DocLevelQuery("", "sigma-456", "", emptyList())] = mutableSetOf("3", "4", "5") - queryToDocIds[DocLevelQuery("id_new", "", "", emptyList())] = mutableSetOf("11", "12", "13") + queryToDocIds[DocLevelQuery("", "sigma-123", listOf(), "", emptyList())] = mutableSetOf("1", "2", "3", "11") + queryToDocIds[DocLevelQuery("", "sigma-456", listOf(), "", emptyList())] = mutableSetOf("3", "4", "5") + queryToDocIds[DocLevelQuery("id_new", "", listOf(), "", emptyList())] = mutableSetOf("11", "12", "13") Assert.assertEquals("query[name=sigma-123] query[name=sigma-456] ! && ", equation.toString()) Assert.assertEquals(mutableSetOf("1", "2", "11"), equation.evaluate(queryToDocIds)) } @@ -97,9 +97,9 @@ class TriggerExpressionResolverTests : OpenSearchTestCase() { val eqString = "(query[name=sigma-123] || !query[id=id1456])" val equation = TriggerExpressionParser(eqString).parse() val queryToDocIds = mutableMapOf>() - queryToDocIds[DocLevelQuery("", "sigma-123", "", emptyList())] = mutableSetOf("6", "3", "7") - queryToDocIds[DocLevelQuery("id1456", "", "", emptyList())] = mutableSetOf("11", "12", "15") - queryToDocIds[DocLevelQuery("id_new", "", "", emptyList())] = mutableSetOf("11", "12", "13") + queryToDocIds[DocLevelQuery("", "sigma-123", listOf(), "", emptyList())] = mutableSetOf("6", "3", "7") + queryToDocIds[DocLevelQuery("id1456", "", listOf(), "", emptyList())] = mutableSetOf("11", "12", "15") + queryToDocIds[DocLevelQuery("id_new", "", listOf(), "", emptyList())] = mutableSetOf("11", "12", "13") Assert.assertEquals("query[name=sigma-123] query[id=id1456] ! || ", equation.toString()) Assert.assertEquals(mutableSetOf("6", "3", "7", "13"), equation.evaluate(queryToDocIds)) } @@ -109,10 +109,10 @@ class TriggerExpressionResolverTests : OpenSearchTestCase() { val equation = TriggerExpressionParser(eqString).parse() val queryToDocIds = mutableMapOf>() - queryToDocIds[DocLevelQuery("", "sigma-123", "", emptyList())] = mutableSetOf("1", "2", "3") - queryToDocIds[DocLevelQuery("id_random1", "", "", mutableListOf("sev1"))] = mutableSetOf("2", "3", "4") - queryToDocIds[DocLevelQuery("", "sigma-789", "", emptyList())] = mutableSetOf("11", "12", "13") - queryToDocIds[DocLevelQuery("id-2aw34", "", "", emptyList())] = mutableSetOf("13", "14", "15") + queryToDocIds[DocLevelQuery("", "sigma-123", listOf(), "", emptyList())] = mutableSetOf("1", "2", "3") + queryToDocIds[DocLevelQuery("id_random1", "", listOf(), "", mutableListOf("sev1"))] = mutableSetOf("2", "3", "4") + queryToDocIds[DocLevelQuery("", "sigma-789", listOf(), "", emptyList())] = mutableSetOf("11", "12", "13") + queryToDocIds[DocLevelQuery("id-2aw34", "", listOf(), "", emptyList())] = mutableSetOf("13", "14", "15") Assert.assertEquals( "query[name=sigma-123] query[tag=sev1] && query[name=sigma-789] ! query[id=id-2aw34] || ! || ",