Skip to content

Commit

Permalink
fix constructor (opensearch-project#1240)
Browse files Browse the repository at this point in the history
Signed-off-by: Surya Sashank Nistala <[email protected]>
(cherry picked from commit 6f29716)
  • Loading branch information
eirsep authored and jowg-amazon committed Oct 23, 2023
1 parent bbfd6dd commit bd2698c
Show file tree
Hide file tree
Showing 12 changed files with 224 additions and 188 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -672,7 +672,9 @@ abstract class AlertingRestTestCase : ODFERestTestCase() {
monitorId: String = "NO_ID",
monitorName: String = "NO_NAME",
index: String = "testIndex",
docLevelQueries: List<DocLevelQuery> = listOf(DocLevelQuery(query = "test_field:\"us-west-2\"", name = "testQuery")),
docLevelQueries: List<DocLevelQuery> = listOf(
DocLevelQuery(query = "test_field:\"us-west-2\"", name = "testQuery", fields = listOf())
),
matchingDocIds: List<String>,
): String {
val finding = Finding(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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]"))
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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]"))
Expand Down Expand Up @@ -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]"))
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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))

Expand Down Expand Up @@ -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))

Expand Down Expand Up @@ -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))

Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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()
Expand Down
Loading

0 comments on commit bd2698c

Please sign in to comment.