-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* add auditDelegateMonitorAlerts flag * add audit state check in error alert validation * add test to verify workflow with auditDelegateMonitor flag null --------- Signed-off-by: Surya Sashank Nistala <[email protected]> (cherry picked from commit 90bea0c)
- Loading branch information
1 parent
1800974
commit 437eba4
Showing
8 changed files
with
140 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
src/test/kotlin/org/opensearch/commons/alerting/action/GetWorkflowResponseTests.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
package org.opensearch.commons.alerting.action | ||
|
||
import org.junit.jupiter.api.Assertions | ||
import org.junit.jupiter.api.Test | ||
import org.opensearch.common.io.stream.BytesStreamOutput | ||
import org.opensearch.common.io.stream.StreamInput | ||
import org.opensearch.commons.alerting.model.CompositeInput | ||
import org.opensearch.commons.alerting.model.IntervalSchedule | ||
import org.opensearch.commons.alerting.model.Workflow | ||
import org.opensearch.commons.alerting.randomDelegate | ||
import org.opensearch.commons.alerting.randomUser | ||
import org.opensearch.commons.alerting.randomWorkflow | ||
import org.opensearch.rest.RestStatus | ||
import java.time.Instant | ||
import java.time.temporal.ChronoUnit | ||
|
||
class GetWorkflowResponseTests { | ||
|
||
@Test | ||
fun testGetWorkflowResponse() { | ||
val workflow = randomWorkflow(auditDelegateMonitorAlerts = false) | ||
val response = GetWorkflowResponse( | ||
id = "id", version = 1, seqNo = 1, primaryTerm = 1, status = RestStatus.OK, workflow = workflow | ||
) | ||
val out = BytesStreamOutput() | ||
response.writeTo(out) | ||
val sin = StreamInput.wrap(out.bytes().toBytesRef().bytes) | ||
val newRes = GetWorkflowResponse(sin) | ||
Assertions.assertEquals("id", newRes.id) | ||
Assertions.assertFalse(newRes.workflow!!.auditDelegateMonitorAlerts!!) | ||
Assertions.assertEquals(workflow.name, newRes.workflow!!.name) | ||
Assertions.assertEquals(workflow.owner, newRes.workflow!!.owner) | ||
} | ||
|
||
@Test | ||
fun testGetWorkflowResponseWhereAuditDelegateMonitorAlertsFlagIsNotSet() { | ||
val workflow = Workflow( | ||
id = "", | ||
version = Workflow.NO_VERSION, | ||
name = "test", | ||
enabled = true, | ||
schemaVersion = 2, | ||
schedule = IntervalSchedule(1, ChronoUnit.MINUTES), | ||
lastUpdateTime = Instant.now(), | ||
enabledTime = Instant.now(), | ||
workflowType = Workflow.WorkflowType.COMPOSITE, | ||
user = randomUser(), | ||
inputs = listOf(CompositeInput(org.opensearch.commons.alerting.model.Sequence(listOf(randomDelegate())))), | ||
owner = "", | ||
triggers = listOf() | ||
) | ||
val response = GetWorkflowResponse( | ||
id = "id", version = 1, seqNo = 1, primaryTerm = 1, status = RestStatus.OK, workflow = workflow | ||
) | ||
val out = BytesStreamOutput() | ||
response.writeTo(out) | ||
val sin = StreamInput.wrap(out.bytes().toBytesRef().bytes) | ||
val newRes = GetWorkflowResponse(sin) | ||
Assertions.assertEquals("id", newRes.id) | ||
Assertions.assertTrue(newRes.workflow!!.auditDelegateMonitorAlerts!!) | ||
Assertions.assertEquals(workflow.name, newRes.workflow!!.name) | ||
Assertions.assertEquals(workflow.owner, newRes.workflow!!.owner) | ||
Assertions.assertEquals(workflow.auditDelegateMonitorAlerts, newRes.workflow!!.auditDelegateMonitorAlerts) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters