-
Notifications
You must be signed in to change notification settings - Fork 105
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
Add back opendistro prefixed sweeper enabled field to alerting stats response #283
Conversation
Signed-off-by: Mohammad Qureshi <[email protected]>
alerting/src/test/kotlin/org/opensearch/alerting/AlertingRestTestCase.kt
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM however you may want to consider the suggestion around Rest API ITs.
@@ -886,8 +886,7 @@ class MonitorRestApiIT : AlertingRestTestCase() { | |||
disableScheduledJob() | |||
|
|||
val responseMap = getAlertingStats() | |||
// assertEquals("Cluster name is incorrect", responseMap["cluster_name"], "alerting_integTestCluster") | |||
assertEquals("Scheduled job is not enabled", false, responseMap[ScheduledJobSettings.SWEEPER_ENABLED.key]) | |||
assertAlertingStatsSweeperEnabled(responseMap, false) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add a Resource File with the Rest API response, and assert on those values instead. You may want to check how it is achieved similarly in Rest ITs of the core. I feel it's more manageable that way and you will not have to define the explicit fields in the test here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Personally, I think way we're currently asserting here is cleaner since for some tests we just want to check specific values and not the entire response. If we had a resource file then we'd need to handcraft the entire responses for new cases that aren't covered by the old ones. That would be more appropriate for unit tests where we're mocking but would add overhead here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can also have resource file versioned since any new API changes would only happen with a change in the minor version. Also, the validation would be between the objects in resource file and the API response here, not necessarily requiring any mock. In order to check for any specific values, we can always filter the object in consideration, given it will be a json structure.
Just that having a resource file would defines one source of truth to compare the API responses against. However, it is just an open idea, and might not necessarily be included in the scope of this PR. Feel free to skip it for now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair point. Let's skip it for this PR but can you create an issue capturing this and we can continue discussions there and have others weigh in on the option.
Signed-off-by: Mohammad Qureshi <[email protected]>
Codecov Report
@@ Coverage Diff @@
## main #283 +/- ##
=========================================
Coverage 78.63% 78.64%
+ Complexity 218 217 -1
=========================================
Files 173 173
Lines 6968 6971 +3
Branches 915 916 +1
=========================================
+ Hits 5479 5482 +3
+ Misses 1002 1001 -1
- Partials 487 488 +1
Continue to review full report at Codecov.
|
…response (opensearch-project#283) * Add back opendistro prefixed sweeper enabled to alerting stats response Signed-off-by: Mohammad Qureshi <[email protected]> * Rename stats response field variables used in tests Signed-off-by: Mohammad Qureshi <[email protected]>
…response (opensearch-project#283) * Add back opendistro prefixed sweeper enabled to alerting stats response Signed-off-by: Mohammad Qureshi <[email protected]> * Rename stats response field variables used in tests Signed-off-by: Mohammad Qureshi <[email protected]>
…response (opensearch-project#283) * Add back opendistro prefixed sweeper enabled to alerting stats response Signed-off-by: Mohammad Qureshi <[email protected]> * Rename stats response field variables used in tests Signed-off-by: Mohammad Qureshi <[email protected]>
…response (opensearch-project#283) * Add back opendistro prefixed sweeper enabled to alerting stats response Signed-off-by: Mohammad Qureshi <[email protected]> * Rename stats response field variables used in tests Signed-off-by: Mohammad Qureshi <[email protected]>
…response (opensearch-project#283) * Add back opendistro prefixed sweeper enabled to alerting stats response Signed-off-by: Mohammad Qureshi <[email protected]> * Rename stats response field variables used in tests Signed-off-by: Mohammad Qureshi <[email protected]>
…response (opensearch-project#283) * Add back opendistro prefixed sweeper enabled to alerting stats response Signed-off-by: Mohammad Qureshi <[email protected]> * Rename stats response field variables used in tests Signed-off-by: Mohammad Qureshi <[email protected]>
…response (opensearch-project#283) * Add back opendistro prefixed sweeper enabled to alerting stats response Signed-off-by: Mohammad Qureshi <[email protected]> * Rename stats response field variables used in tests Signed-off-by: Mohammad Qureshi <[email protected]>
…response (opensearch-project#283) * Add back opendistro prefixed sweeper enabled to alerting stats response Signed-off-by: Mohammad Qureshi <[email protected]> * Rename stats response field variables used in tests Signed-off-by: Mohammad Qureshi <[email protected]>
* Remove runBlocking calls from MonitorRunner (#281) * Remove runBlocking calls from MonitorRunner Signed-off-by: Mohammad Qureshi <[email protected]> * Add security tests with partial user permissions to check user context being correctly applied Signed-off-by: Mohammad Qureshi <[email protected]> * Fix ktlint style issues Signed-off-by: Mohammad Qureshi <[email protected]> * Add back opendistro prefixed sweeper enabled field to alerting stats response (#283) * Add back opendistro prefixed sweeper enabled to alerting stats response Signed-off-by: Mohammad Qureshi <[email protected]> * Rename stats response field variables used in tests Signed-off-by: Mohammad Qureshi <[email protected]>
* Remove runBlocking calls from MonitorRunner (#281) * Remove runBlocking calls from MonitorRunner Signed-off-by: Mohammad Qureshi <[email protected]> * Add security tests with partial user permissions to check user context being correctly applied Signed-off-by: Mohammad Qureshi <[email protected]> * Fix ktlint style issues Signed-off-by: Mohammad Qureshi <[email protected]> * Add back opendistro prefixed sweeper enabled field to alerting stats response (#283) * Add back opendistro prefixed sweeper enabled to alerting stats response Signed-off-by: Mohammad Qureshi <[email protected]> * Rename stats response field variables used in tests Signed-off-by: Mohammad Qureshi <[email protected]>
* Remove runBlocking calls from MonitorRunner (#281) * Remove runBlocking calls from MonitorRunner Signed-off-by: Mohammad Qureshi <[email protected]> * Add security tests with partial user permissions to check user context being correctly applied Signed-off-by: Mohammad Qureshi <[email protected]> * Fix ktlint style issues Signed-off-by: Mohammad Qureshi <[email protected]> * Add back opendistro prefixed sweeper enabled field to alerting stats response (#283) * Add back opendistro prefixed sweeper enabled to alerting stats response Signed-off-by: Mohammad Qureshi <[email protected]> * Rename stats response field variables used in tests Signed-off-by: Mohammad Qureshi <[email protected]>
…response (#283) (#286) * Add back opendistro prefixed sweeper enabled to alerting stats response Signed-off-by: Mohammad Qureshi <[email protected]> * Rename stats response field variables used in tests Signed-off-by: Mohammad Qureshi <[email protected]>
…#287) * Remove runBlocking calls from MonitorRunner (opensearch-project#281) * Remove runBlocking calls from MonitorRunner Signed-off-by: Mohammad Qureshi <[email protected]> * Add security tests with partial user permissions to check user context being correctly applied Signed-off-by: Mohammad Qureshi <[email protected]> * Fix ktlint style issues Signed-off-by: Mohammad Qureshi <[email protected]> * Add back opendistro prefixed sweeper enabled field to alerting stats response (opensearch-project#283) * Add back opendistro prefixed sweeper enabled to alerting stats response Signed-off-by: Mohammad Qureshi <[email protected]> * Rename stats response field variables used in tests Signed-off-by: Mohammad Qureshi <[email protected]> Signed-off-by: AWSHurneyt <[email protected]>
Signed-off-by: Mohammad Qureshi [email protected]
Issue #, if available:
Description of changes:
The
opendistro
prefixed field response for sweeper/scheduled jobs enabled in the Alerting Stats API was inadvertently changed toplugins
during the migration to OpenSearch. This change reintroduces the legacy field back alongside the existingplugins
one to maintain backwards compatibility and to not break behavior for anyone using the current field.This PR also updates the existing tests asserting on the response of the stats API to use hardcoded values for the scheduled jobs enabled field instead of referring to the
Setting.key
so it can catch a change like this in the future. We should also see if any other tests are currently checking API responses this way. Fixing those, however, is out of scope for this particular PR.CheckList:
[x] Commits are signed per the DCO using --signoff
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.