-
Notifications
You must be signed in to change notification settings - Fork 69
Add post-test alerts #5232
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
base: main
Are you sure you want to change the base?
Add post-test alerts #5232
Changes from all commits
484db23
fb472f5
106cf66
4046061
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,55 @@ | ||||||||||
| """ | ||||||||||
| Post-test alerts verification. | ||||||||||
|
|
||||||||||
| Verifies that critical CNV alerts were not triggered during test execution. | ||||||||||
|
|
||||||||||
| Jira: https://redhat.atlassian.net/browse/CNV-80353 | ||||||||||
| """ | ||||||||||
|
coderabbitai[bot] marked this conversation as resolved.
|
||||||||||
|
|
||||||||||
| import datetime | ||||||||||
| import logging | ||||||||||
|
|
||||||||||
| import pytest | ||||||||||
|
|
||||||||||
| LOGGER = logging.getLogger(__name__) | ||||||||||
|
|
||||||||||
| POST_TEST_CRITICAL_ALERTS = [ | ||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why those alerts specifically? did you investigate customer tickets?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes, i looked at customer tickets and worked with claude to identify which alerts could be potential issues in the future |
||||||||||
| "LowVirtControllersCount", | ||||||||||
| "LowVirtAPICount", | ||||||||||
| "KubeVirtCRModified", | ||||||||||
| "VirtControllerRESTErrorsHigh", | ||||||||||
| "VirtHandlerRESTErrorsHigh", | ||||||||||
| "HCOOperatorConditionsUnhealthy", | ||||||||||
| ] | ||||||||||
|
|
||||||||||
| ALERTS_REGEX = "|".join(POST_TEST_CRITICAL_ALERTS) | ||||||||||
|
|
||||||||||
|
|
||||||||||
| @pytest.mark.s390x | ||||||||||
| @pytest.mark.polarion("CNV-16276") | ||||||||||
| @pytest.mark.order("last") | ||||||||||
| def test_no_critical_alerts_after_tests(prometheus, request): | ||||||||||
| """ | ||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The test is not following the jira ticket description. more specifically:
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. got it, fixed the test |
||||||||||
| Test that critical CNV alerts were not triggered during test execution. | ||||||||||
|
|
||||||||||
| Preconditions: | ||||||||||
| - Prometheus is accessible on the cluster | ||||||||||
| - Test execution completed | ||||||||||
|
|
||||||||||
| Steps: | ||||||||||
| 1. Query Prometheus for alerts that fired at any point during test execution | ||||||||||
| 2. Check that none of the critical alerts were triggered | ||||||||||
|
|
||||||||||
| Expected: | ||||||||||
| - None of the critical alerts fired during test execution | ||||||||||
| """ | ||||||||||
| start_time = request.config._test_execution_start_time | ||||||||||
| duration_seconds = int((datetime.datetime.now(tz=datetime.UTC) - start_time).total_seconds()) | ||||||||||
|
Comment on lines
+46
to
+47
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. LOW: Clamp the lookback duration to at least 1 second. At Line [47], Suggested fix- duration_seconds = int((datetime.datetime.now(tz=datetime.UTC) - start_time).total_seconds())
+ duration_seconds = max(1, int((datetime.datetime.now(tz=datetime.UTC) - start_time).total_seconds()))📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||
| LOGGER.info( | ||||||||||
| f"Checking {len(POST_TEST_CRITICAL_ALERTS)} critical alerts" | ||||||||||
| f" were not triggered during test execution (last {duration_seconds}s)" | ||||||||||
| ) | ||||||||||
| query = f'ALERTS{{alertname=~"{ALERTS_REGEX}", alertstate="firing"}}[{duration_seconds}s]' | ||||||||||
| results = prometheus.query_sampler(query=query) | ||||||||||
| fired_alerts = {result["metric"]["alertname"]: result for result in results} | ||||||||||
| assert not fired_alerts, f"Critical alerts fired during test execution.\n{fired_alerts}" | ||||||||||
Uh oh!
There was an error while loading. Please reload this page.