Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update cron-utils #266

Merged
merged 2 commits into from
Jan 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,11 @@ interface SecureTransportAction {
val resourceBackendRoles = resourceUser?.backendRoles
val requesterBackendRoles = requesterUser?.backendRoles

if (resourceBackendRoles == null || requesterBackendRoles == null || resourceBackendRoles.intersect(requesterBackendRoles).isEmpty()) {
if (
resourceBackendRoles == null ||
requesterBackendRoles == null ||
resourceBackendRoles.intersect(requesterBackendRoles).isEmpty()
) {
actionListener.onFailure(
AlertingException.wrap(
OpenSearchStatusException(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -565,10 +565,16 @@ class MonitorRestApiIT : AlertingRestTestCase() {
val expectedAcknowledgedCount = alertsToAcknowledge.size

val acknowledgedAlerts = responseMap["success"] as List<String>
assertTrue("Expected $expectedAcknowledgedCount alerts to be acknowledged successfully.", acknowledgedAlerts.size == expectedAcknowledgedCount)
assertTrue(
"Expected $expectedAcknowledgedCount alerts to be acknowledged successfully.",
acknowledgedAlerts.size == expectedAcknowledgedCount
)

val acknowledgedAlertsList = acknowledgedAlerts.toString()
alertsToAcknowledge.forEach { alert -> assertTrue("Alert with ID ${alert.id} not found in failed list.", acknowledgedAlertsList.contains(alert.id)) }
alertsToAcknowledge.forEach {
alert ->
assertTrue("Alert with ID ${alert.id} not found in failed list.", acknowledgedAlertsList.contains(alert.id))
}

val failedResponse = responseMap["failed"] as List<String>
assertTrue("Expected 0 alerts to fail acknowledgment.", failedResponse.isEmpty())
Expand All @@ -583,7 +589,8 @@ class MonitorRestApiIT : AlertingRestTestCase() {

val alertsGroup2 = (1..15).map { createAlert(randomAlert(monitor).copy(state = Alert.State.ACTIVE)) }.toTypedArray()

val alertsToAcknowledge = arrayOf(*alertsGroup1, *alertsGroup2) // Creating an array of alerts that includes alerts that have been already acknowledged, and new alerts.
// Creating an array of alerts that includes alerts that have been already acknowledged, and new alerts.
val alertsToAcknowledge = arrayOf(*alertsGroup1, *alertsGroup2)

// WHEN
val response = acknowledgeAlerts(monitor, *alertsToAcknowledge)
Expand All @@ -593,18 +600,33 @@ class MonitorRestApiIT : AlertingRestTestCase() {
val expectedAcknowledgedCount = alertsToAcknowledge.size - alertsGroup1.size

val acknowledgedAlerts = responseMap["success"] as List<String>
assertTrue("Expected $expectedAcknowledgedCount alerts to be acknowledged successfully.", acknowledgedAlerts.size == expectedAcknowledgedCount)
assertTrue(
"Expected $expectedAcknowledgedCount alerts to be acknowledged successfully.",
acknowledgedAlerts.size == expectedAcknowledgedCount
)

val acknowledgedAlertsList = acknowledgedAlerts.toString()
alertsGroup2.forEach { alert -> assertTrue("Alert with ID ${alert.id} not found in failed list.", acknowledgedAlertsList.contains(alert.id)) }
alertsGroup1.forEach { alert -> assertFalse("Alert with ID ${alert.id} found in failed list.", acknowledgedAlertsList.contains(alert.id)) }
alertsGroup2.forEach {
alert ->
assertTrue("Alert with ID ${alert.id} not found in failed list.", acknowledgedAlertsList.contains(alert.id))
}
alertsGroup1.forEach {
alert ->
assertFalse("Alert with ID ${alert.id} found in failed list.", acknowledgedAlertsList.contains(alert.id))
}

val failedResponse = responseMap["failed"] as List<String>
assertTrue("Expected ${alertsGroup1.size} alerts to fail acknowledgment.", failedResponse.size == alertsGroup1.size)

val failedResponseList = failedResponse.toString()
alertsGroup1.forEach { alert -> assertTrue("Alert with ID ${alert.id} not found in failed list.", failedResponseList.contains(alert.id)) }
alertsGroup2.forEach { alert -> assertFalse("Alert with ID ${alert.id} found in failed list.", failedResponseList.contains(alert.id)) }
alertsGroup1.forEach {
alert ->
assertTrue("Alert with ID ${alert.id} not found in failed list.", failedResponseList.contains(alert.id))
}
alertsGroup2.forEach {
alert ->
assertFalse("Alert with ID ${alert.id} found in failed list.", failedResponseList.contains(alert.id))
}
}

@Throws(Exception::class)
Expand Down
1 change: 0 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ allprojects {
compileKotlin.kotlinOptions.jvmTarget = compileTestKotlin.kotlinOptions.jvmTarget = "1.8"
compileKotlin.dependsOn ktlint
}

}

evaluationDependsOnChildren()
Expand Down
2 changes: 1 addition & 1 deletion core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib:${kotlin_version}"
compile 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.1.1'
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:${kotlin_version}"
compile "com.cronutils:cron-utils:9.1.3"
compile "com.cronutils:cron-utils:9.1.6"
compile "org.opensearch.client:opensearch-rest-client:${opensearch_version}"
compile 'com.google.googlejavaformat:google-java-format:1.10.0'
compile "org.opensearch:common-utils:${common_utils_version}"
Expand Down