Skip to content

NO-JIRA: retry operations in e2e tests - #1071

Merged
openshift-merge-bot[bot] merged 1 commit into
openshift:main-alerts-management-apifrom
simonpasquier:tests-with-retry
Jul 28, 2026
Merged

NO-JIRA: retry operations in e2e tests#1071
openshift-merge-bot[bot] merged 1 commit into
openshift:main-alerts-management-apifrom
simonpasquier:tests-with-retry

Conversation

@simonpasquier

@simonpasquier simonpasquier commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Requests to the backend may fail for a variety of reasons such as network connectivity, API blips, etc. Instead of failing a test, this commit implements retries for API requests.

Summary by CodeRabbit

  • Tests
    • Improved end-to-end alert rule creation and deletion flows using retry and time-bounded polling.
    • Enhanced verification of created rule details (expression, duration, severity, summary) and clearer failure messages when rules aren’t observed.
    • Updated bulk-delete checks to poll until expected API results are returned, then poll until the remaining alert matches the expected name.
  • Chores
    • Added a build-e2e target to compile the end-to-end test suite into a standalone binary.
  • Style
    • Ignored the generated e2e.test binary in version control.

@openshift-ci
openshift-ci Bot requested review from etmurasaki and zhuje July 21, 2026 09:25
@coderabbitai

coderabbitai Bot commented Jul 21, 2026

Copy link
Copy Markdown

Walkthrough

Alert rule E2E tests now use shared polling and retry helpers for creation, deletion, and PrometheusRule verification. A Makefile target builds the E2E test binary, and .gitignore excludes that binary.

Changes

Alert rule E2E reliability

Layer / File(s) Summary
Shared polling and creation retries
test/e2e/helpers_test.go
Adds reusable timeout polling and retrying alert-rule creation helpers.
Create and delete verification flows
test/e2e/create_alert_rule_test.go, test/e2e/delete_alert_rule_test.go
Retries API operations and PrometheusRule checks while validating created fields, deletion results, and the remaining alert.
E2E build support
Makefile, .gitignore
Adds an E2E binary build target and ignores the generated e2e.test binary.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Suggested reviewers: etmurasaki, zhuje, peteryurkovich

🚥 Pre-merge checks | ✅ 14 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Microshift Test Compatibility ⚠️ Warning The new alert-rule e2e tests use MonitoringV1 PrometheusRules and lack any MicroShift skip/tag/runtime guard. Add a MicroShift skip/tag or runtime IsMicroShiftCluster() guard, or avoid monitoring-stack APIs/resources in these tests.
✅ Passed checks (14 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Stable And Deterministic Test Names ✅ Passed The modified e2e tests use only static top-level Test names; no Ginkgo titles or dynamic subtest names were added.
Test Structure And Quality ✅ Passed The e2e tests use deferred namespace cleanup, bounded polling, and focused create/delete scenarios consistent with repo patterns.
Single Node Openshift (Sno) Test Compatibility ✅ Passed The added tests only create/delete alert rules via API and poll PrometheusRule resources; they make no node/HA assumptions or SNO-sensitive checks.
Topology-Aware Scheduling Compatibility ✅ Passed No deployment manifests, operator code, or controllers were changed; only e2e tests, helpers, .gitignore, and Makefile were modified, with no scheduling constraints introduced.
Ote Binary Stdout Contract ✅ Passed PR only adds retry helpers and test-case logic; no main/init/TestMain/BeforeSuite stdout writes or klog/log redirection changes were introduced.
Ipv6 And Disconnected Network Test Compatibility ✅ Passed No hardcoded IPv4, IPv4-only parsing, or public-internet dependencies found in the new e2e tests; they use cluster-internal API clients and the plugin URL.
No-Weak-Crypto ✅ Passed Searched the changed e2e files; found no MD5/SHA1/DES/RC4/3DES/Blowfish/ECB, no custom crypto, and no secret/token comparisons.
Container-Privileges ✅ Passed No container/K8s manifest changes in the PR; only e2e tests, Makefile, and .gitignore were modified, with no privileged settings added.
No-Sensitive-Data-In-Logs ✅ Passed No new logs expose passwords, tokens, PII, hostnames, or customer data; only test rule IDs/counts are logged.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: adding retry behavior to e2e tests.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (1)
test/e2e/helpers_test.go (1)

23-37: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick win

poll never honors a caller-supplied context; it hardcodes context.Background().

poll doesn't accept a context.Context, so it can't be cancelled by the outer test context (e.g. a test-level deadline). All three call sites pass their own ctx into the retried operation but the polling loop itself runs on an unrelated background context. As per path instructions, Go code should use context.Context for cancellation and timeouts.

♻️ Suggested fix: thread ctx through
-func poll(interval, timeout time.Duration, f func() error) error {
+func poll(ctx context.Context, interval, timeout time.Duration, f func() error) error {
 	var lastErr error
-	err := wait.PollUntilContextTimeout(context.Background(), interval, timeout, true, func(context.Context) (bool, error) {
+	err := wait.PollUntilContextTimeout(ctx, interval, timeout, true, func(context.Context) (bool, error) {
 		if lastErr = f(); lastErr != nil {
 			return false, nil
 		}

(call sites would then pass their existing ctx)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@test/e2e/helpers_test.go` around lines 23 - 37, Update poll to accept a
context.Context parameter and pass it to wait.PollUntilContextTimeout instead of
context.Background(). Update all three poll call sites to provide their existing
ctx values, preserving the current retry and error-handling behavior.

Source: Path instructions

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@test/e2e/delete_alert_rule_test.go`:
- Line 95: Handle the error returned by resp.Body.Close() in the defer near the
affected test, rather than discarding it. Update the deferred cleanup to check
the close result and propagate or report any error using the test’s existing
error-handling mechanism.

In `@test/e2e/helpers_test.go`:
- Around line 39-50: The retries around non-idempotent alert-rule operations are
unsafe. In test/e2e/helpers_test.go:39-50, update createRuleViaAPIWithRetry to
verify existing state or otherwise avoid creating a duplicate when the server
may have already processed the request; in
test/e2e/delete_alert_rule_test.go:80-121, make the bulk-delete retry treat
already-deleted/not-found rules as success and avoid repeatedly failing on IDs
removed by an earlier attempt.

---

Nitpick comments:
In `@test/e2e/helpers_test.go`:
- Around line 23-37: Update poll to accept a context.Context parameter and pass
it to wait.PollUntilContextTimeout instead of context.Background(). Update all
three poll call sites to provide their existing ctx values, preserving the
current retry and error-handling behavior.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Central YAML (inherited)

Review profile: CHILL

Plan: Enterprise

Run ID: db90c7b5-bec6-45bc-81a7-c48e7cf18598

📥 Commits

Reviewing files that changed from the base of the PR and between 6810f45 and 330236d.

📒 Files selected for processing (3)
  • test/e2e/create_alert_rule_test.go
  • test/e2e/delete_alert_rule_test.go
  • test/e2e/helpers_test.go

if err != nil {
return fmt.Errorf("failed to make delete request: %w", err)
}
defer resp.Body.Close()

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win

Unchecked resp.Body.Close() error return.

Flagged by errcheck; per path instructions, Go code should never ignore error returns.

🔧 Suggested fix
-		defer resp.Body.Close()
+		defer func() {
+			if cerr := resp.Body.Close(); cerr != nil {
+				t.Logf("failed to close response body: %v", cerr)
+			}
+		}()
🧰 Tools
🪛 golangci-lint (2.12.2)

[error] 95-95: Error return value of resp.Body.Close is not checked

(errcheck)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@test/e2e/delete_alert_rule_test.go` at line 95, Handle the error returned by
resp.Body.Close() in the defer near the affected test, rather than discarding
it. Update the deferred cleanup to check the close result and propagate or
report any error using the test’s existing error-handling mechanism.

Sources: Path instructions, Linters/SAST tools

Comment thread test/e2e/helpers_test.go
@openshift-ci openshift-ci Bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jul 22, 2026
@openshift-ci openshift-ci Bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jul 22, 2026
@simonpasquier

Copy link
Copy Markdown
Contributor Author

/cc @PeterYurkovich

@etmurasaki

Copy link
Copy Markdown
Contributor

/test e2e-monitoring

@PeterYurkovich

Copy link
Copy Markdown
Contributor

/override-sticky ci/prow/e2e-monitoring

@openshift-ci

openshift-ci Bot commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

@PeterYurkovich: Overrode contexts on behalf of PeterYurkovich: ci/prow/e2e-monitoring

These overrides will persist across retests on the current HEAD SHA. Pushing a new commit will clear them. Use /override-cancel to remove them.

Details

In response to this:

/override-sticky ci/prow/e2e-monitoring

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

Requests to the backend may fail for a variety of reasons such as
network connectivity, API blips, etc. Instead of failing a test, this
commit implements retries for API requests.

Signed-off-by: Simon Pasquier <[email protected]>
@simonpasquier

Copy link
Copy Markdown
Contributor Author

/test test-frontend-unit

@PeterYurkovich

Copy link
Copy Markdown
Contributor

/override-sticky ci/prow/test-frontend-unit
I'll rebase the base branch to main to get new test later today

@openshift-ci

openshift-ci Bot commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

@PeterYurkovich: Overrode contexts on behalf of PeterYurkovich: ci/prow/test-frontend-unit

These overrides will persist across retests on the current HEAD SHA. Pushing a new commit will clear them. Use /override-cancel to remove them.

Details

In response to this:

/override-sticky ci/prow/test-frontend-unit
I'll rebase the base branch to main to get new test later today

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@PeterYurkovich

Copy link
Copy Markdown
Contributor

/override-sticky ci/prow/e2e-monitoring

@openshift-ci

openshift-ci Bot commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

@PeterYurkovich: Overrode contexts on behalf of PeterYurkovich: ci/prow/e2e-monitoring

These overrides will persist across retests on the current HEAD SHA. Pushing a new commit will clear them. Use /override-cancel to remove them.

Details

In response to this:

/override-sticky ci/prow/e2e-monitoring

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@openshift-ci

openshift-ci Bot commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

@simonpasquier: all tests passed!

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

@PeterYurkovich

Copy link
Copy Markdown
Contributor

/retitle NO-JIRA: retry operations in e2e tests

@openshift-ci openshift-ci Bot changed the title test: retry operations in e2e tests NO-JIRA: retry operations in e2e tests Jul 28, 2026
@PeterYurkovich

Copy link
Copy Markdown
Contributor

/lgtm
/label qe-approved

@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Jul 28, 2026
@openshift-ci-robot

Copy link
Copy Markdown

@simonpasquier: This pull request explicitly references no jira issue.

Details

In response to this:

Requests to the backend may fail for a variety of reasons such as network connectivity, API blips, etc. Instead of failing a test, this commit implements retries for API requests.

Summary by CodeRabbit

  • Tests
  • Improved end-to-end alert rule creation and deletion flows using retry and time-bounded polling.
  • Enhanced verification of created rule details (expression, duration, severity, summary) and clearer failure messages when rules aren’t observed.
  • Updated bulk-delete checks to poll until expected API results are returned, then poll until the remaining alert matches the expected name.
  • Chores
  • Added a build-e2e target to compile the end-to-end test suite into a standalone binary.
  • Style
  • Ignored the generated e2e.test binary in version control.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@openshift-ci openshift-ci Bot added the qe-approved Signifies that QE has signed off on this PR label Jul 28, 2026
@openshift-ci openshift-ci Bot added the lgtm Indicates that a PR is ready to be merged. label Jul 28, 2026
@openshift-ci

openshift-ci Bot commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: PeterYurkovich, simonpasquier

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci Bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jul 28, 2026
@openshift-merge-bot
openshift-merge-bot Bot merged commit dda087c into openshift:main-alerts-management-api Jul 28, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. lgtm Indicates that a PR is ready to be merged. qe-approved Signifies that QE has signed off on this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants