Skip to content

Add coverage for syncAvailableUpdates#1375

Open
hongkailiu wants to merge 1 commit intoopenshift:mainfrom
hongkailiu:test-deepCopyReleases
Open

Add coverage for syncAvailableUpdates#1375
hongkailiu wants to merge 1 commit intoopenshift:mainfrom
hongkailiu:test-deepCopyReleases

Conversation

@hongkailiu
Copy link
Copy Markdown
Member

@hongkailiu hongkailiu commented Apr 13, 2026

Follow up #1367 (comment)

The commit 913e324 from #1367 adds the two upstream* properties and use them to calculate availableUpdates even without fetching the updates from upstream, i.e., when needFreshFetch==false. It enables noticing the resolved alerts quickly. Before that change, any evaluated conditional update will stay there until needFreshFetch==true.

This pull extends the coverage for the above behavior.

Summary by CodeRabbit

  • Tests
    • Added test coverage verifying that when a cluster update acceptance feature is enabled, conditional updates are promptly re-evaluated and promoted to regular available updates for the targeted architecture, ensuring no errors during sync.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 13, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

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

Review profile: CHILL

Plan: Pro Plus

Run ID: fce8b74d-f98e-4026-b181-82a14efe62c8

📥 Commits

Reviewing files that changed from the base of the PR and between 8cbe798 and fbe0caf.

📒 Files selected for processing (1)
  • pkg/cvo/availableupdates_test.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • pkg/cvo/availableupdates_test.go

Walkthrough

Added a new unit test that enables the FeatureGateClusterUpdateAcceptRisks feature and verifies that a previously conditional update (4.21.2) is re-evaluated into the operator’s plain available updates after calling syncAvailableUpdates.

Changes

Cohort / File(s) Summary
Test Addition
pkg/cvo/availableupdates_test.go
Added TestOperator_syncAvailableUpdates_noticeResolvedAlertsQuickly. Imports github.com/openshift/api/features, configures feature gates to enable FeatureGateClusterUpdateAcceptRisks, sets optr.minimumUpdateCheckInterval = 10 * time.Minute, seeds availableUpdates with a conditional update for 4.21.2, calls optr.syncAvailableUpdates(...) for amd64, and asserts the conditional update becomes a plain available Update with no error.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes


Important

Pre-merge checks failed

Please resolve all errors before merging. Addressing warnings is optional.

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Stable And Deterministic Test Names ❓ Inconclusive Unable to verify test for dynamic information due to missing file access. The test file pkg/cvo/availableupdates_test.go could not be examined. Please provide the file contents or verify it exists in the repository.
✅ Passed checks (8 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately reflects the main change: adding a new test for syncAvailableUpdates to extend coverage of the function's behavior with feature gates and alert resolution.
Test Structure And Quality ✅ Passed The custom check is designed for Ginkgo test code patterns; this PR adds a standard Go testing package test using *testing.T, which is not subject to the check. The test follows good practices with clear responsibility and meaningful assertions.
Microshift Test Compatibility ✅ Passed The custom check for MicroShift test compatibility applies only to Ginkgo e2e tests. This pull request adds a standard Go unit test using the testing package, not a Ginkgo e2e test.
Single Node Openshift (Sno) Test Compatibility ✅ Passed The test added is a standard Go unit test, not a Ginkgo e2e test, so this check is not applicable.
Topology-Aware Scheduling Compatibility ✅ Passed This pull request adds only a test function to availableupdates_test.go and does not introduce, modify, or affect any deployment manifests, pod specifications, or scheduling constraints.
Ote Binary Stdout Contract ✅ Passed The new test function contains no direct stdout writes and uses only standard testing framework methods (cmp.Diff, t.Fatalf, t.Errorf) that do not violate the OTE stdout contract.
Ipv6 And Disconnected Network Test Compatibility ✅ Passed This PR adds a standard Go unit test, not a Ginkgo e2e test. The custom check applies only to new Ginkgo e2e tests with patterns like It(), Describe(), Context(), and When().
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci bot commented Apr 13, 2026

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: hongkailiu

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 Apr 13, 2026
Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@pkg/cvo/availableupdates_test.go`:
- Around line 1193-1217: The test is seeding conditional promotion data in
ConditionalUpdates and also including the same release in upstreamUpdates, which
bypasses the upstream-based re-evaluation path exercised by
syncAvailableUpdates; update the test to put the conditional entry under
upstreamConditionalUpdates (not ConditionalUpdates) and remove the duplicate
"4.21.2" from upstreamUpdates so that syncAvailableUpdates must rebuild from
upstream* fields and actually promotes the conditional update back into Updates;
refer to upstreamConditionalUpdates, upstreamUpdates, ConditionalUpdates and
syncAvailableUpdates when making the change.
- Around line 1249-1250: The comment above the test is inaccurate relative to
the fixture: update the comment to reflect that upstreamUpdates is pre-populated
with 4.21.2 (or alternatively remove the 4.21.2 element from upstreamUpdates if
the intent was "no available updates before sync"); locate the test fixture
using the upstreamUpdates variable in pkg/cvo/availableupdates_test.go and
either correct the comment to state that an upstream update (4.21.2) exists
before sync or adjust the upstreamUpdates setup to match the original comment
intent.
🪄 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: Pro Plus

Run ID: f96955d5-03a0-47eb-a24c-a818453e78f6

📥 Commits

Reviewing files that changed from the base of the PR and between e9c1c39 and 8cbe798.

📒 Files selected for processing (1)
  • pkg/cvo/availableupdates_test.go

Comment thread pkg/cvo/availableupdates_test.go
Comment thread pkg/cvo/availableupdates_test.go
@hongkailiu
Copy link
Copy Markdown
Member Author

/retest

2 similar comments
@hongkailiu
Copy link
Copy Markdown
Member Author

/retest

@hongkailiu
Copy link
Copy Markdown
Member Author

/retest

Follow up openshift#1367 (comment)

The commit 913e324 from openshift#1367 adds the two `upstream*` properties and use them to calculate `availableUpdates` even without fetching the updates from upstream, i.e., when `needFreshFetch==false`. It enables noticing the resolved alerts quickly. Before that change, any evaluated conditional update will stay there until `needFreshFetch==true`.

This pull extends the coverage for the above behavior.
@hongkailiu hongkailiu force-pushed the test-deepCopyReleases branch from 8cbe798 to fbe0caf Compare April 15, 2026 18:47
@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci bot commented Apr 15, 2026

@hongkailiu: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/e2e-hypershift fbe0caf link true /test e2e-hypershift
ci/prow/e2e-hypershift-conformance fbe0caf link true /test e2e-hypershift-conformance

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.

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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant