Skip to content

CLID-614: Test for Operator incremental mirroring#1413

Open
nidangavali wants to merge 1 commit into
openshift:mainfrom
nidangavali:CLID-614
Open

CLID-614: Test for Operator incremental mirroring#1413
nidangavali wants to merge 1 commit into
openshift:mainfrom
nidangavali:CLID-614

Conversation

@nidangavali
Copy link
Copy Markdown
Contributor

@nidangavali nidangavali commented May 20, 2026

Description

Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change.

Github / Jira issue:

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Code Improvements (Refactoring, Performance, CI upgrades, etc)
  • Internal repo assets (diagrams / docs on github repo)
  • This change requires a documentation update on openshift docs

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration.

Expected Outcome

Please describe the outcome expected from the tests.

Summary by CodeRabbit

  • Tests
    • Added integration test coverage for operator incremental mirroring workflows, including end-to-end specs that verify incremental tar outputs and blob deduplication across runs, plus new helper utilities for structured diagnostics and tar archive assertions.
  • Test Data
    • Added image set configuration fixtures for initial and updated incremental mirror scenarios.

@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 20, 2026
@openshift-ci-robot
Copy link
Copy Markdown

openshift-ci-robot commented May 20, 2026

@nidangavali: This pull request references CLID-614 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 task to target the "5.0.0" version, but no target version was set.

Details

In response to this:

Description

Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change.

Github / Jira issue:

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Code Improvements (Refactoring, Performance, CI upgrades, etc)
  • Internal repo assets (diagrams / docs on github repo)
  • This change requires a documentation update on openshift docs

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration.

Expected Outcome

Please describe the outcome expected from the tests.

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 requested review from adolfo-ab and aguidirh May 20, 2026 11:12
@openshift-ci
Copy link
Copy Markdown

openshift-ci Bot commented May 20, 2026

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: nidangavali
Once this PR has been reviewed and has the lgtm label, please assign aguidirh for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found 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

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 20, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository: openshift/coderabbit/.coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 2017c379-7834-4d4a-b0e9-606488bd6347

📥 Commits

Reviewing files that changed from the base of the PR and between 94a346b and a84bd83.

📒 Files selected for processing (4)
  • tests/integration/helpers_test.go
  • tests/integration/incremental_test.go
  • tests/integration/testdata/imagesetconfigs/operators/isc-operator-incremental-initial.yaml
  • tests/integration/testdata/imagesetconfigs/operators/isc-operator-incremental-update.yaml
✅ Files skipped from review due to trivial changes (1)
  • tests/integration/testdata/imagesetconfigs/operators/isc-operator-incremental-initial.yaml

Walkthrough

Adds test helpers for logging oc-mirror results and inspecting tar archives, plus a Ginkgo integration spec that mirrors an initial operator ISC, preserves its tar, runs an updated ISC into the same workdir, and asserts the incremental tar contains only new blobs and expected contents.

Changes

Integration test for incremental operator mirroring

Layer / File(s) Summary
Integration test helper functions
tests/integration/helpers_test.go
Four helper functions: logOcMirrorResult formats oc-mirror execution diagnostics to GinkgoWriter; logTarSummary computes tar size, entry count, blob count under blobs/sha256/, and infers repo-like prefixes; collectTarBlobPaths returns normalized tar entries under a prefix; expectTarDoesNotContainPath asserts no tar entry contains a substring.
Integration spec and lifecycle
tests/integration/incremental_test.go
Ginkgo spec with per-test temporary workdir setup/teardown. Runs MirrorToDisk for an initial ISC, preserves the produced mirror_*.tar, runs MirrorToDisk again with an updated ISC into the same directory, and asserts the incremental tar's blob set excludes blobs already present in the initial tar and that content expectations (e.g., /bar absence/presence) hold.
Test fixtures: initial and update ISCs
tests/integration/testdata/imagesetconfigs/operators/isc-operator-incremental-initial.yaml, tests/integration/testdata/imagesetconfigs/operators/isc-operator-incremental-update.yaml
YAML fixtures: initial ISC mirrors operator foo pinned to beta 0.2.0; update ISC expands foo's version bounds and adds operator bar for the incremental scenario.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 10 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Test Structure And Quality ⚠️ Warning Three assertions lack messages: incremental_test.go lines 29,52 and helpers_test.go line 813 violate established codebase pattern of including diagnostic messages in Expect(err) calls. Add failure messages to three Expect(err).NotTo(HaveOccurred()) calls to match archive_test.go pattern.
Ipv6 And Disconnected Network Test Compatibility ⚠️ Warning Test requires external connectivity to pull operator catalog from quay.io, which fails in disconnected IPv6-only environments. Add "[Skipped:Disconnected]" to the It() test name, or configure test to use local/internal image registry accessible in disconnected networks.
✅ Passed checks (10 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically identifies the main change: adding an integration test for operator incremental mirroring, which is directly supported by all four file additions in the changeset.
Docstring Coverage ✅ Passed Docstring coverage is 80.00% which is sufficient. The required threshold is 80.00%.
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 All Ginkgo test names in incremental_test.go are stable and deterministic with no dynamic content; helper functions in helpers_test.go contain no test declarations.
Microshift Test Compatibility ✅ Passed The new test performs only file-based operations without interacting with Kubernetes or using any unavailable OpenShift APIs, making it fully compatible with MicroShift.
Single Node Openshift (Sno) Test Compatibility ✅ Passed The test is an oc-mirror tool integration test that operates on tar archives and files, with no Kubernetes cluster interaction or multi-node dependencies.
Topology-Aware Scheduling Compatibility ✅ Passed PR adds only integration tests and test fixtures (ImageSetConfiguration data). No deployment manifests, operator code, controllers, or scheduling constraints are introduced.
Ote Binary Stdout Contract ✅ Passed No stdout writes in process-level code detected. All logging uses GinkgoWriter, which is safe for Ginkgo tests. No fmt.Print*, klog, os.Stdout, or standard log package writes found.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

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 current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@tests/integration/incremental_test.go`:
- Around line 36-38: The test currently hardcodes "mirror_000001.tar" (assigned
to initialTar) which can break if sequence naming changes; replace the hardcoded
lookup by discovering produced mirror tar files in workDir with a glob like
"mirror_*.tar", assert the glob returns at least one match, sort the matches (by
filename or modtime) to pick the intended archive (first/earliest for initial,
next for subsequent), assign that path to initialTar (and the later tar variable
used around logTarSummary), and then call logTarSummary with the discovered
path; update any other hardcoded uses of "mirror_00000X.tar" similarly.
- Around line 68-70: The current assertion using
Expect(incrementalBlobs).NotTo(ConsistOf(initialBlobs)) only proves the sets
differ; change the test to assert the incremental tar contains none of the
previously mirrored blobs by verifying there is no intersection between
incrementalBlobs and initialBlobs. Replace the ConsistOf-based assertion with
one that checks incrementalBlobs does not contain any element from initialBlobs
(e.g., assert the intersection length is zero or use a Gomega matcher that
ensures no elements from initialBlobs appear in incrementalBlobs) referencing
the incrementalBlobs and initialBlobs variables and the Expect call.
🪄 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: openshift/coderabbit/.coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: d60a918f-b59b-49dd-aa3e-496c58791e63

📥 Commits

Reviewing files that changed from the base of the PR and between edb3e8c and 94a346b.

📒 Files selected for processing (4)
  • tests/integration/helpers_test.go
  • tests/integration/incremental_test.go
  • tests/integration/testdata/imagesetconfigs/operators/isc-operator-incremental-initial.yaml
  • tests/integration/testdata/imagesetconfigs/operators/isc-operator-incremental-update.yaml

Comment thread tests/integration/incremental_test.go Outdated
Comment thread tests/integration/incremental_test.go Outdated
@nidangavali
Copy link
Copy Markdown
Contributor Author

/retest

@openshift-ci
Copy link
Copy Markdown

openshift-ci Bot commented May 20, 2026

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

Copy link
Copy Markdown
Contributor

@aguidirh aguidirh left a comment

Choose a reason for hiding this comment

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

Thanks for the PR, I just added few comments to it.

Please add a PR description following the template on .github directory and if possible also a commit message with context about the changes for future reference.

Comment on lines +80 to +84
for _, b := range incrementalBlobs {
_, alreadyMirrored := initialBlobSet[b]
Expect(alreadyMirrored).To(BeFalse(),
"incremental tar re-included previously mirrored blob: %s", b)
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It would be good if we could check if the blobs of the incremental run were included correctly. Currently we are only checking if the initial blobs were not included.

Comment on lines +50 to +56
By("moving the initial tar outside the working directory to preserve it")
preserveDir, err := os.MkdirTemp("", "oc-mirror-preserved-tar-*")
Expect(err).NotTo(HaveOccurred())
defer os.RemoveAll(preserveDir)
preservedTar := filepath.Join(preserveDir, "mirror_initial.tar")
err = os.Rename(initialTar, preservedTar)
Expect(err).NotTo(HaveOccurred(), "failed to move initial tar")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It seems we're not using the initial tar later, so this is dead code that can be removed. Or am I missing anything?

logTarSummary("initial", initialTar)

By("verifying the initial tar contains expected content")
expectCorrectTarArchiveContents(iscInitialPath, workDir)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Are we also checking the blobs here? Only only the directory path?

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

Labels

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