Skip to content

NO-JIRA: Add coverage for syncAvailableUpdates#1375

Open
hongkailiu wants to merge 2 commits into
openshift:mainfrom
hongkailiu:test-deepCopyReleases
Open

NO-JIRA: Add coverage for syncAvailableUpdates#1375
hongkailiu wants to merge 2 commits into
openshift: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 the cluster update acceptance feature is enabled, conditional updates with resolved risks are promptly re-evaluated and promoted to regular available updates for the targeted architecture, and that the system records retrieved-updates status without errors during synchronization.

@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: Enterprise

Run ID: 3697f12f-3530-45b4-9575-e016c0ccb4b9

📥 Commits

Reviewing files that changed from the base of the PR and between fbe0caf and 826c556.

📒 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

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

Changes

Test Addition

Layer / File(s) Summary
Test: re-evaluate conditional update
pkg/cvo/availableupdates_test.go
Adds github.com/openshift/api/features import and TestOperator_syncAvailableUpdates_noticeResolvedAlertsQuickly. The test enables 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 Update with a RetrievedUpdates condition.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 13 | ❌ 2

❌ Failed checks (2 warnings)

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.
Test Structure And Quality ⚠️ Warning Test error messages inconsistent with established patterns: uses "failed to sync..." instead of "syncAvailableUpdates() unexpected error" and "mismatch" instead of "differ from expected". Use consistent error messages: "syncAvailableUpdates() unexpected error: %v" for errors and "available updates differ from expected" for diffs.
✅ Passed checks (13 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'NO-JIRA: Add coverage for syncAvailableUpdates' directly summarizes the main change: adding test coverage for the syncAvailableUpdates function.
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 new test uses standard Go testing (not Ginkgo), with a static, descriptive name containing no dynamic values, timestamps, IDs, or other problematic patterns.
Microshift Test Compatibility ✅ Passed The check applies only to new Ginkgo e2e tests. The PR adds a standard Go unit test (TestOperator_syncAvailableUpdates_noticeResolvedAlertsQuickly) using the testing package, not a Ginkgo e2e test.
Single Node Openshift (Sno) Test Compatibility ✅ Passed The test is a Go unit test, not a Ginkgo e2e test. The SNO compatibility check applies only to Ginkgo e2e tests with constructs like It(), Describe(), Context().
Topology-Aware Scheduling Compatibility ✅ Passed PR only adds test code to verify alert resolution behavior in availableUpdates; no deployment manifests, pod scheduling constraints, or topology-sensitive code introduced.
Ote Binary Stdout Contract ✅ Passed PR adds only a standard Go test function with no process-level stdout writes, init(), TestMain(), suite setup, or klog misconfiguration that would violate the OTE Binary Stdout Contract.
Ipv6 And Disconnected Network Test Compatibility ✅ Passed The added test is a standard Go unit test, not a Ginkgo e2e test. The custom check specifically applies to Ginkgo e2e tests; this unit test is out of scope.
No-Weak-Crypto ✅ Passed No weak cryptography (MD5, SHA1, DES, RC4, 3DES, Blowfish, ECB), custom crypto implementations, or non-constant-time secret comparisons detected in the new test code.
Container-Privileges ✅ Passed PR adds a Go unit test to availableupdates_test.go only. No K8s/container manifests are modified, so no privileged settings can be present. Check not applicable.
No-Sensitive-Data-In-Logs ✅ Passed No sensitive data found. Test uses only safe test values and non-sensitive logging (timestamps, versions, condition metadata).

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

✨ 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

@hongkailiu hongkailiu force-pushed the test-deepCopyReleases branch from 8cbe798 to fbe0caf Compare April 15, 2026 18:47
@hongkailiu
Copy link
Copy Markdown
Member Author

/retest

@hongkailiu
Copy link
Copy Markdown
Member Author

/test e2e-hypershift-conformance

@hongkailiu
Copy link
Copy Markdown
Member Author

/test unit

To make sure it works with the main tip.

@hongkailiu hongkailiu changed the title Add coverage for syncAvailableUpdates NO-JIRA: Add coverage for syncAvailableUpdates May 27, 2026
@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label May 27, 2026
@openshift-ci-robot
Copy link
Copy Markdown
Contributor

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

Details

In response to this:

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.

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.

Comment thread pkg/cvo/availableupdates_test.go
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.
- Use mock risk source to trigger logic on risks [1].
- The setup such as `mock.InternalRisks=[]configv1.ConditionalUpdateRisk{}` and `availableUpdates.Condition=RetrievedUpdates` is added. They can avoid triggering warning messages.

None of the above is essential to pass, but they simulate closer to the production environment and provide more coverage of the code.

[1]. https://github.com/openshift/cluster-version-operator/blob/52cc8e3dce564aef0fe34659030ba48ceabce5b4/pkg/cvo/availableupdates.go#L569-L579
@hongkailiu hongkailiu force-pushed the test-deepCopyReleases branch from fbe0caf to 826c556 Compare May 29, 2026 22:35
@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci Bot commented May 30, 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-aws-ovn-techpreview 826c556 link true /test e2e-aws-ovn-techpreview
ci/prow/e2e-agnostic-ovn-techpreview-serial-2of3 826c556 link true /test e2e-agnostic-ovn-techpreview-serial-2of3

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. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants