Skip to content

Commit

Permalink
Merge branch 'opensearch-project:2.x' into 2.x
Browse files Browse the repository at this point in the history
  • Loading branch information
kennyzhang0819 authored Nov 4, 2023
2 parents cc0b150 + 944abf2 commit 7a290fc
Show file tree
Hide file tree
Showing 15 changed files with 235 additions and 197 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/multi-node-test-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,5 @@ jobs:
uses: actions/checkout@v2
- name: Run integration tests with multi node config
run: |
chown -R opensearch.opensearch `pwd`
su opensearch -c "whoami && java -version && ./gradlew integTest -PnumNodes=3"
chown -R 1000:1000 `pwd`
su `id -un 1000` -c "whoami && java -version && ./gradlew integTest -PnumNodes=3"
4 changes: 2 additions & 2 deletions .github/workflows/test-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ jobs:
java-version: ${{ matrix.java }}
- name: Build and run with Gradle
run: |
chown -R opensearch.opensearch `pwd`
su opensearch -c "whoami && java -version && ./gradlew assemble integTest"
chown -R 1000:1000 `pwd`
su `id -un 1000` -c "whoami && java -version && ./gradlew assemble integTest"
- name: Create Artifact Path
run: |
mkdir -p alerting-artifacts
Expand Down
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
@@ -1,7 +1,7 @@
{
"dynamic": "strict",
"_meta" : {
"schema_version": 3
"schema_version": 4
},
"properties": {
"schema_version": {
Expand Down Expand Up @@ -46,6 +46,9 @@
"type" : "keyword"
}
}
},
"fields": {
"type": "text"
}
}
},
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 Expand Up @@ -1280,7 +1286,7 @@ class DocumentMonitorRunnerIT : AlertingRestTestCase() {
val index4 = createTestIndex()
val index5 = createTestIndex()

val docQuery = DocLevelQuery(query = "\"us-west-2\"", name = "3")
val docQuery = DocLevelQuery(query = "\"us-west-2\"", name = "3", fields = listOf())
var docLevelInput = DocLevelMonitorInput("description", listOf(index1, index2, index4, index5), listOf(docQuery))

val action = randomAction(template = randomTemplateScript("Hello {{ctx.monitor.name}}"), destinationId = createDestination().id)
Expand Down Expand Up @@ -1328,7 +1334,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 7a290fc

Please sign in to comment.