test: add e2e tests for v1alpha Alert API#900
Open
nieomylnieja wants to merge 12 commits intomainfrom
Open
Conversation
Changes the GetAlerts method signature to accept a GetAlertsRequest parameter instead of separate header and query parameters. Moves the filter building logic from GetV1alphaAlerts to the deprecated GetAlerts method, consolidating parameter handling and removing the unused net/url import.
Replace name-only assertions with full object verification using expectedAlertProperties map and assertAlertObject helper that checks all deterministic fields: APIVersion, Kind, Metadata, Spec (severity, status, SLO, AlertPolicy, Service, Objective), timestamps, conditions, resolved state, silence info, and organization.
Rename objectPersistedDescription to ObjectPersistedDescription to follow Go naming conventions and make the constant publicly accessible.
Replaces string-based alert identification with alertMatchKey for grouping indistinguishable alerts by Project, Severity, Status, and AlertPolicy. Introduces expectedAlertGroup to pair properties with expected counts. New assertion helpers (assertAlertsMatchGroups, assertAlertsContainGroups, assertEachAlertMatchesGroup) validate alerts by group membership. Splits monolithic test into three focused functions: Listing, SingleFieldFilters, and CombinedFiltersAndEdgeCases.
The test data for `v1alpha/alert` is now loaded from an embedded YAML file. This simplifies test setup, improves readability, and makes it easier to manage and update test cases. The assertion logic has also been streamlined to work with the new data source.
Refactor alert test constants and structure for better readability and maintainability. Add new test cases for filtering alerts by multiple alert policy names, and by specific objective names and values. Update test data in `v1alpha_alerts.yaml` to support the new objective filtering tests. Introduce `ObjectPersistedDescription` constant in `e2etestutils` for common test object descriptions.
nobl9-adam-szymanski
approved these changes
Apr 8, 2026
Updates the `tests/testdata/v1alpha_alerts.yaml` and `tests/v1alpha_alert_test.go` to reflect changes in alert status handling. The `resolutionReason` is changed from `AlertResolved` to `AlertCanceledAlertPolicyHasChanged`, and the `status` is updated from `Resolved` to `Canceled` in the test data. The test logic in `tests/v1alpha_alert_test.go` is updated to use a new helper function `isResolvedOrCancelledAlertStatus` for more accurate status checks.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
GetV1alphaAlertsAPI endpoint