Skip to content
This repository was archived by the owner on Sep 9, 2026. It is now read-only.

MGMT-23404: fix flaky Tenant StorageClass test - #170

Merged
openshift-merge-bot[bot] merged 1 commit into
mainfrom
fix/flaky-tenant-storageclass-test
Mar 31, 2026
Merged

openshift-merge-bot[bot] merged 1 commit into
mainfrom
fix/flaky-tenant-storageclass-test

Conversation

@eranco74

@eranco74 eranco74 commented Mar 31, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Fix flaky test should transition through all Ready/Progressing phases with conditions in tenant_controller_test.go
  • The test was non-deterministic because it reconciled immediately after creating/deleting StorageClass objects without waiting for the controller's informer cache to sync
  • Replace separate doReconcile() + assertStatus() calls with a single reconcileAndAssertStatus() helper that retries both reconciliation and assertion inside an Eventually block, giving the cache time to observe the latest state

Test plan

  • All 258 controller tests pass (go test ./internal/controller/ -count=1)
  • Ran tests 3 consecutive times with no failures
  • gofmt -s -l . reports no formatting issues

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Tests
    • Improved test reliability and maintainability for tenant controller functionality.

The test was flaky because it reconciled immediately after creating or
deleting StorageClass objects without waiting for the controller's
informer cache to sync. Replace the separate doReconcile()+assertStatus()
calls with a single reconcileAndAssertStatus() helper that retries both
reconciliation and assertion inside an Eventually block, giving the cache
time to observe the latest state.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@openshift-ci-robot

openshift-ci-robot commented Mar 31, 2026

Copy link
Copy Markdown

@eranco74: This pull request references MGMT-23404 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "4.22.0" version, but no target version was set.

Details

In response to this:

Summary

  • Fix flaky test should transition through all Ready/Progressing phases with conditions in tenant_controller_test.go
  • The test was non-deterministic because it reconciled immediately after creating/deleting StorageClass objects without waiting for the controller's informer cache to sync
  • Replace separate doReconcile() + assertStatus() calls with a single reconcileAndAssertStatus() helper that retries both reconciliation and assertion inside an Eventually block, giving the cache time to observe the latest state

Test plan

  • All 258 controller tests pass (go test ./internal/controller/ -count=1)
  • Ran tests 3 consecutive times with no failures
  • gofmt -s -l . reports no formatting issues

🤖 Generated with Claude Code

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.

@coderabbitai

coderabbitai Bot commented Mar 31, 2026

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

Test code is refactored to introduce a combined reconcileAndAssertStatus helper that encapsulates reconciliation and status assertions within retry loops, replacing separate method calls. The event recorder buffer size is increased from 10 to 100.

Changes

Cohort / File(s) Summary
Test Helper Refactoring
internal/controller/tenant_controller_test.go
New reconcileAndAssertStatus helper consolidates doReconcile() and assertStatus() logic into a single Eventually retry loop. All test steps updated to use this helper. Event recorder buffer size increased from 10 to 100.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 A helper so neat, both test and refine,
Reconcile and assert in one clean design,
The buffer grows wide, from ten to a hundred,
No flaky tests now—the logic's not sundered!
EventRecorder applauds the new way.

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly describes the main change: fixing a flaky test in the Tenant StorageClass test suite by improving test synchronization.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/flaky-tenant-storageclass-test

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@openshift-ci-robot

openshift-ci-robot commented Mar 31, 2026

Copy link
Copy Markdown

@eranco74: This pull request references MGMT-23404 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "4.22.0" version, but no target version was set.

Details

In response to this:

Summary

  • Fix flaky test should transition through all Ready/Progressing phases with conditions in tenant_controller_test.go
  • The test was non-deterministic because it reconciled immediately after creating/deleting StorageClass objects without waiting for the controller's informer cache to sync
  • Replace separate doReconcile() + assertStatus() calls with a single reconcileAndAssertStatus() helper that retries both reconciliation and assertion inside an Eventually block, giving the cache time to observe the latest state

Test plan

  • All 258 controller tests pass (go test ./internal/controller/ -count=1)
  • Ran tests 3 consecutive times with no failures
  • gofmt -s -l . reports no formatting issues

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Tests
  • Improved test reliability and maintainability for tenant controller functionality.

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.

@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.

🧹 Nitpick comments (1)
internal/controller/tenant_controller_test.go (1)

90-105: Consider clarifying the comment about ignored errors.

The term "transient errors" typically implies temporary API/network failures. However, per handleUpdate() (lines 127-135 in tenant_controller.go), the namespace-not-found error is an expected state in certain test steps—not a temporary failure that will resolve on retry.

The approach itself is sound since status conditions are set before returning errors, but the comment could be more precise.

📝 Suggested wording
-			// The reconcile error is intentionally ignored because the
-			// reconciler may return transient errors (e.g. namespace not
-			// found) while still correctly setting status conditions.
+			// The reconcile error is intentionally ignored because the
+			// reconciler returns errors for missing prerequisites (e.g.,
+			// namespace not found) while still correctly setting status
+			// conditions. The test validates conditions, not error returns.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@internal/controller/tenant_controller_test.go` around lines 90 - 105, The
comment for reconcileAndAssertStatus should be clarified to avoid calling
namespace-not-found a generic "transient error"; update the comment to explain
that errors from doReconcile() are intentionally ignored because the reconciler
(see handleUpdate in tenant_controller.go) may return expected state errors such
as "namespace not found" as part of normal flow, and status conditions are set
before those errors are returned; mention reconcileAndAssertStatus and
doReconcile by name so future readers understand why the test ignores the
reconcile error and still asserts status conditions.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@internal/controller/tenant_controller_test.go`:
- Around line 90-105: The comment for reconcileAndAssertStatus should be
clarified to avoid calling namespace-not-found a generic "transient error";
update the comment to explain that errors from doReconcile() are intentionally
ignored because the reconciler (see handleUpdate in tenant_controller.go) may
return expected state errors such as "namespace not found" as part of normal
flow, and status conditions are set before those errors are returned; mention
reconcileAndAssertStatus and doReconcile by name so future readers understand
why the test ignores the reconcile error and still asserts status conditions.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: fe97db94-cea1-4f0d-829a-af8fb7ed307b

📥 Commits

Reviewing files that changed from the base of the PR and between f099afc and cff3d23.

📒 Files selected for processing (1)
  • internal/controller/tenant_controller_test.go

@openshift-ci

openshift-ci Bot commented Mar 31, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: adriengentil, eranco74

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:
  • OWNERS [adriengentil,eranco74]

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants