Skip to content

test: add e2e tests for v1alpha Alert API#900

Open
nieomylnieja wants to merge 12 commits intomainfrom
worktree-alert-tests-nobl9go
Open

test: add e2e tests for v1alpha Alert API#900
nieomylnieja wants to merge 12 commits intomainfrom
worktree-alert-tests-nobl9go

Conversation

@nieomylnieja
Copy link
Copy Markdown
Collaborator

@nieomylnieja nieomylnieja commented Mar 24, 2026

Summary

  • Add comprehensive e2e tests for the GetV1alphaAlerts API endpoint
  • Test all filter parameters: project, name, SLO name, alert policy name, service name, triggered/resolved status, time range (from/to), objective name, objective value
  • Test combined filters and negative cases (non-matching filters return empty)
  • Verify alert field contents for triggered, resolved, and silenced alerts
  • Verify TruncatedMax header handling

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.
@n9-machine-user n9-machine-user added go patch test Improvements or additions to the tests labels Mar 24, 2026
nieomylnieja and others added 9 commits March 24, 2026 14:17
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.
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

go patch test Improvements or additions to the tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants