Skip to content

clusterimageset-updater: replace integration test with unit test - #5340

Open
Prucek wants to merge 3 commits into
openshift:mainfrom
Prucek:fix-clusterimageset-updater-test
Open

clusterimageset-updater: replace integration test with unit test#5340
Prucek wants to merge 3 commits into
openshift:mainfrom
Prucek:fix-clusterimageset-updater-test

Conversation

@Prucek

@Prucek Prucek commented Jul 29, 2026

Copy link
Copy Markdown
Member

Summary

  • The clusterimageset-updater integration test hit the real release controller API, so it broke every time a new z-stream was published.
  • Extract core logic into a testable run(options, HTTPClient) function.
  • Add a --release-controller-url flag and EndpointWithBase helpers to support URL override.
  • Add a unit test using httptest.NewServer with testhelper.CompareWithFixture golden files — deterministic, no external dependencies.
  • Remove the shell-based integration test and its fixtures.

@openshift-merge-bot

Copy link
Copy Markdown
Contributor

Pipeline controller notification
This repo is configured to use the pipeline controller. Second-stage tests will be triggered either automatically or after lgtm label is added, depending on the repository configuration. The pipeline controller will automatically detect which contexts are required and will utilize /test Prow commands to trigger the second stage.

For optional jobs, comment /test ? to see a list of all defined jobs. To trigger manually all jobs from second stage use /pipeline required command.

This repository is configured in: automatic mode

@coderabbitai

coderabbitai Bot commented Jul 29, 2026

Copy link
Copy Markdown

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

The updater now accepts an optional release-controller URL, uses configurable endpoint helpers for pullspec resolution, and tests the override with a local mock server. Expected ClusterImageSet and ClusterPool manifests now reference release 4.21.99.

Changes

Release controller override

Layer / File(s) Summary
Configurable endpoint construction
pkg/release/candidate/client.go, pkg/release/prerelease/client.go
Endpoint helpers accept an optional base URL, trim trailing slashes, and preserve default host resolution.
Updater resolution routing
cmd/clusterimageset-updater/main.go
The updater adds --release-controller-url and selects candidate-based resolution when configured, while retaining prerelease resolution by default.
Mock integration and expected outputs
test/integration/clusterimageset-updater.sh, test/integration/clusterimageset-updater/mock-release-controller/main.go, test/integration/clusterimageset-updater/output/...
Integration coverage uses a local mock release controller, and expected image set and pool references are updated from 4.21.25 to 4.21.99.

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

Suggested reviewers: deepsm007, psalajova

🚥 Pre-merge checks | ✅ 13 | ❌ 4

❌ Failed checks (4 warnings)

Check name Status Explanation Resolution
Go Error Handling ⚠️ Warning New mock-release-controller ignores errors from json.Encoder.Encode and http.Serve, violating the no-ignored-errors rule. Check/log the Encode and Serve return values (and any shutdown/close errors) instead of discarding them, or document a clear justification.
Test Coverage For New Features ⚠️ Warning New pure helpers EndpointWithBase and the baseURL branch in clusterimageset-updater lack unit tests; only the integration script covers behavior. Add table-driven unit tests for EndpointWithBase and the resolvePullSpec override path, plus a regression test for the new CLI flag.
Ipv6 And Disconnected Network Test Compatibility ⚠️ Warning The integration test binds and calls the mock server on hardcoded 127.0.0.1, which is IPv4-only and can fail in IPv6-only CI. Use a dual-stack or IPv6 loopback address (e.g. ::1) and build the URL with net.JoinHostPort/IPv6 brackets instead of hardcoding 127.0.0.1.
Title check ⚠️ Warning The title is misleading: this PR adds a release-controller URL flag and updates integration test fixtures, not a replacement of integration tests with unit tests. Rename it to reflect the actual change, e.g. 'clusterimageset-updater: add configurable release-controller URL for tests and pullspec resolution'.
✅ Passed checks (13 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 No Ginkgo-style test titles were added; the changed integration script and mock server contain only static/non-Ginkgo names.
Test Structure And Quality ✅ Passed No Ginkgo tests were changed; the new integration script uses cleanup traps and a bounded wait loop, with no cluster resources or indefinite waits.
Microshift Test Compatibility ✅ Passed No new Ginkgo e2e tests were added; changes are only a shell integration harness, mock server, and fixtures, with no MicroShift-unsupported OpenShift APIs.
Single Node Openshift (Sno) Test Compatibility ✅ Passed No new Ginkgo e2e tests or SNO-sensitive multi-node assumptions were added; the changes are CLI/integration-script only.
Topology-Aware Scheduling Compatibility ✅ Passed Diff only changes release-resolution/test fixtures; no affinity, nodeSelector, topology spread, PDB, or control-plane scheduling logic was added.
Ote Binary Stdout Contract ✅ Passed No new OTE-facing process stdout writes were introduced; the mock controller’s port print is intentional auxiliary IPC, and main binary stdout behavior is unchanged.
No-Weak-Crypto ✅ Passed No MD5/SHA1/DES/RC4/3DES/Blowfish/ECB, custom crypto, or secret comparisons were added in the changed files.
Container-Privileges ✅ Passed No touched manifest adds privileged/hostPID/hostNetwork/hostIPC/SYS_ADMIN/allowPrivilegeEscalation or root settings; changes are CLI/test-only.
No-Sensitive-Data-In-Logs ✅ Passed No new logging of secrets/PII/internal data; added output is only a localhost port, and the existing release URL log carries no credentials.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

@openshift-ci
openshift-ci Bot requested review from deepsm007 and psalajova July 29, 2026 11:11
@openshift-ci

openshift-ci Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Prucek

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 29, 2026
@Prucek
Prucek force-pushed the fix-clusterimageset-updater-test branch 2 times, most recently from 45233e4 to 59f7642 Compare July 29, 2026 12:20
@Prucek Prucek changed the title fix: update clusterimageset-updater test fixtures for 4.21.26 fix: mock release controller in clusterimageset-updater integration test Jul 29, 2026

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

🧹 Nitpick comments (1)
pkg/release/candidate/client.go (1)

46-53: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Document both exported endpoint helpers consistently.

Both new EndpointWithBase functions describe their purpose but omit parameter and return-value documentation.

  • pkg/release/candidate/client.go#L46-L53: document d, version, stream, suffix, baseURL, and the returned endpoint string.
  • pkg/release/prerelease/client.go#L22-L31: document p, baseURL, and the returned endpoint string.

As per path instructions, “Comment important exported functions with their purpose, parameters, and return values.”

🤖 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 `@pkg/release/candidate/client.go` around lines 46 - 53, Expand the
documentation for the exported EndpointWithBase function in
pkg/release/candidate/client.go (lines 46-53) to describe d, version, stream,
suffix, baseURL, and the returned endpoint string. Apply the same documentation
improvement to EndpointWithBase in pkg/release/prerelease/client.go (lines
22-31), covering p, baseURL, and the returned endpoint string; no implementation
changes are needed.

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/integration/clusterimageset-updater.sh`:
- Around line 42-48: Update the mock-server readiness loop to use a checked curl
invocation that only succeeds for successful HTTP responses, and retain the loop
counter after retries. After the loop, explicitly fail the test unless the
counter confirms the server became ready; reference the existing readiness loop
and its i variable.

---

Nitpick comments:
In `@pkg/release/candidate/client.go`:
- Around line 46-53: Expand the documentation for the exported EndpointWithBase
function in pkg/release/candidate/client.go (lines 46-53) to describe d,
version, stream, suffix, baseURL, and the returned endpoint string. Apply the
same documentation improvement to EndpointWithBase in
pkg/release/prerelease/client.go (lines 22-31), covering p, baseURL, and the
returned endpoint string; no implementation changes are needed.
🪄 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: f1484d06-0138-4f69-9a86-b450b35f85d9

📥 Commits

Reviewing files that changed from the base of the PR and between 45233e4 and 59f7642.

📒 Files selected for processing (7)
  • cmd/clusterimageset-updater/main.go
  • pkg/release/candidate/client.go
  • pkg/release/prerelease/client.go
  • test/integration/clusterimageset-updater.sh
  • test/integration/clusterimageset-updater/output/imagesets/ocp-release-4.21.99-multi-for-4.21.0-0-to-4.22.0-0_clusterimageset.yaml
  • test/integration/clusterimageset-updater/output/pools/4-21-20_clusterpool.yaml
  • test/integration/clusterimageset-updater/output/pools/4-21-auto_clusterpool.yaml
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

  • openshift/release (manual)
  • openshift/ci-docs (manual)
  • openshift/release-controller (manual)
  • openshift/ci-chat-bot (manual)
🚧 Files skipped from review as they are similar to previous changes (2)
  • test/integration/clusterimageset-updater/output/pools/4-21-auto_clusterpool.yaml
  • test/integration/clusterimageset-updater/output/pools/4-21-20_clusterpool.yaml

Comment thread test/integration/clusterimageset-updater.sh Outdated
@Prucek
Prucek force-pushed the fix-clusterimageset-updater-test branch from 59f7642 to ff42fed Compare July 29, 2026 12:34

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

🤖 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/integration/clusterimageset-updater.sh`:
- Line 21: Update the mock-server setup around MOCK_PORT so the Python server
binds to port 0 itself, retains the bound socket while starting the server, and
communicates the assigned port back to the shell; remove the separate
socket-selection and early-close flow to prevent the port from being claimed
between selection and binding.
🪄 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: fbea1e7b-b9a3-49ad-9e35-878a238a0047

📥 Commits

Reviewing files that changed from the base of the PR and between 59f7642 and ff42fed.

📒 Files selected for processing (7)
  • cmd/clusterimageset-updater/main.go
  • pkg/release/candidate/client.go
  • pkg/release/prerelease/client.go
  • test/integration/clusterimageset-updater.sh
  • test/integration/clusterimageset-updater/output/imagesets/ocp-release-4.21.99-multi-for-4.21.0-0-to-4.22.0-0_clusterimageset.yaml
  • test/integration/clusterimageset-updater/output/pools/4-21-20_clusterpool.yaml
  • test/integration/clusterimageset-updater/output/pools/4-21-auto_clusterpool.yaml
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

  • openshift/release (manual)
  • openshift/ci-docs (manual)
  • openshift/release-controller (manual)
  • openshift/ci-chat-bot (manual)
🚧 Files skipped from review as they are similar to previous changes (6)
  • test/integration/clusterimageset-updater/output/pools/4-21-20_clusterpool.yaml
  • pkg/release/prerelease/client.go
  • test/integration/clusterimageset-updater/output/pools/4-21-auto_clusterpool.yaml
  • test/integration/clusterimageset-updater/output/imagesets/ocp-release-4.21.99-multi-for-4.21.0-0-to-4.22.0-0_clusterimageset.yaml
  • cmd/clusterimageset-updater/main.go
  • pkg/release/candidate/client.go

Comment thread test/integration/clusterimageset-updater.sh Outdated
expected="${workdir}/output"

# Start a mock release controller that returns a deterministic version.
MOCK_PORT=$(python3 -c 'import socket; s=socket.socket(); s.bind(("",0)); print(s.getsockname()[1]); s.close()')

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I don't think that you should do that.... I guess your AI is trying to hack the hell out of it.

@Prucek
Prucek force-pushed the fix-clusterimageset-updater-test branch from ff42fed to 98365a2 Compare July 29, 2026 13:30

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

🧹 Nitpick comments (1)
pkg/release/prerelease/client.go (1)

22-24: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Complete the GoDoc for the exported helper.

The comment explains the purpose and baseURL, but not what p supplies or what string is returned. Make the public contract explicit.

Suggested documentation
 // EndpointWithBase constructs the release controller endpoint for a prerelease
 // using the given base URL instead of the default service host.
+// p provides the prerelease release descriptor and version bounds.
+// baseURL overrides the default release-controller host.
+// It returns the release-controller endpoint URL.
 func EndpointWithBase(p api.Prerelease, baseURL string) string {

As per path instructions, “Comment important exported functions with their purpose, parameters, and return values.”

🤖 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 `@pkg/release/prerelease/client.go` around lines 22 - 24, Complete the GoDoc
for the exported EndpointWithBase function by documenting what the p parameter
represents and describing the endpoint string it returns, while retaining the
existing purpose and baseURL explanation.

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/integration/clusterimageset-updater/mock-release-controller/main.go`:
- Line 34: Handle the error returned by http.Serve in the mock controller’s main
serving flow instead of ignoring it. Report the failure with informative context
to stderr and exit with a nonzero status when serving stops unexpectedly, while
preserving the existing successful startup behavior.

---

Nitpick comments:
In `@pkg/release/prerelease/client.go`:
- Around line 22-24: Complete the GoDoc for the exported EndpointWithBase
function by documenting what the p parameter represents and describing the
endpoint string it returns, while retaining the existing purpose and baseURL
explanation.
🪄 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: 8a278ac3-9b2f-40f3-8777-4729d85e6059

📥 Commits

Reviewing files that changed from the base of the PR and between ff42fed and 98365a2.

📒 Files selected for processing (8)
  • cmd/clusterimageset-updater/main.go
  • pkg/release/candidate/client.go
  • pkg/release/prerelease/client.go
  • test/integration/clusterimageset-updater.sh
  • test/integration/clusterimageset-updater/mock-release-controller/main.go
  • test/integration/clusterimageset-updater/output/imagesets/ocp-release-4.21.99-multi-for-4.21.0-0-to-4.22.0-0_clusterimageset.yaml
  • test/integration/clusterimageset-updater/output/pools/4-21-20_clusterpool.yaml
  • test/integration/clusterimageset-updater/output/pools/4-21-auto_clusterpool.yaml
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

  • openshift/release (manual)
  • openshift/ci-docs (manual)
  • openshift/release-controller (manual)
  • openshift/ci-chat-bot (manual)
🚧 Files skipped from review as they are similar to previous changes (5)
  • test/integration/clusterimageset-updater/output/pools/4-21-auto_clusterpool.yaml
  • test/integration/clusterimageset-updater/output/imagesets/ocp-release-4.21.99-multi-for-4.21.0-0-to-4.22.0-0_clusterimageset.yaml
  • pkg/release/candidate/client.go
  • test/integration/clusterimageset-updater/output/pools/4-21-20_clusterpool.yaml
  • cmd/clusterimageset-updater/main.go

Comment thread test/integration/clusterimageset-updater/mock-release-controller/main.go Outdated
@Prucek
Prucek force-pushed the fix-clusterimageset-updater-test branch from 98365a2 to 41a89e1 Compare July 29, 2026 13:42
Prucek and others added 3 commits July 29, 2026 16:35
Extract the core logic into a run(options, HTTPClient) function so it
can be called from unit tests with a mock HTTP client. main() now only
parses flags, validates, and calls run().

Add EndpointWithBase to candidate and prerelease packages and a
--release-controller-url flag to support URL override for testing.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Use httptest.NewServer to serve a deterministic fake release (4.21.99)
so the test never breaks when a new z-stream is published. Input and
expected output are in testdata/run/. Covers imageset creation,
outdated imageset deletion, pool ref updates, and label propagation.

Also move the inline expected YAML in TestEnsureLabelsOnClusterPools to
a testdata file.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The integration test hit the real release controller API which made it
break on every z-stream release. The new unit test for run() with
httptest.NewServer covers the same functionality without external
dependencies.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@Prucek
Prucek force-pushed the fix-clusterimageset-updater-test branch from 41a89e1 to 80c8b2a Compare July 29, 2026 14:40
@Prucek Prucek changed the title fix: mock release controller in clusterimageset-updater integration test clusterimageset-updater: replace integration test with unit test Jul 29, 2026
@openshift-merge-bot

Copy link
Copy Markdown
Contributor

Scheduling tests matching the pipeline_run_if_changed or not excluded by pipeline_skip_if_only_changed parameters:
/test e2e

@openshift-ci

openshift-ci Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

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

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.

2 participants