CLID-614: Test for Operator incremental mirroring - #1413
Conversation
|
@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. DetailsIn response to this:
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. |
|
Note Reviews pausedIt 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 Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
WalkthroughAdds a CLID-614 integration test for config-driven operator incremental mirroring. Two ImageSetConfiguration fixtures define initial and updated operator selections. Tar helpers inspect archives, and the test verifies archive contents and non-overlapping blob paths across two ChangesOperator incremental mirroring
Estimated code review effort: 2 (Simple) | ~10 minutes Sequence Diagram(s)sequenceDiagram
participant GinkgoTest
participant MirrorToDisk
participant InitialTar
participant IncrementalTar
GinkgoTest->>MirrorToDisk: Run with initial operator configuration
MirrorToDisk-->>InitialTar: Produce mirror archive
GinkgoTest->>MirrorToDisk: Run with updated operator configuration
MirrorToDisk-->>IncrementalTar: Produce incremental archive
GinkgoTest->>InitialTar: Inspect entries and collect blob paths
GinkgoTest->>IncrementalTar: Assert repositories and new blob paths
Suggested reviewers: 🚥 Pre-merge checks | ✅ 14 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (14 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 Checkov (3.3.8)tests/integration/testdata/imagesetconfigs/operators/isc-operator-incremental-initial.yamlTraceback (most recent call last): tests/integration/testdata/imagesetconfigs/operators/isc-operator-incremental-update.yamlTraceback (most recent call last): 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. Comment |
There was a problem hiding this comment.
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
📒 Files selected for processing (4)
tests/integration/helpers_test.gotests/integration/incremental_test.gotests/integration/testdata/imagesetconfigs/operators/isc-operator-incremental-initial.yamltests/integration/testdata/imagesetconfigs/operators/isc-operator-incremental-update.yaml
|
/retest |
aguidirh
left a comment
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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_mirroring_test.go`:
- Around line 147-150: The deferred cleanup call to os.RemoveAll(preserveDir)
does not capture or handle its error return value. Modify the defer statement to
use a closure that captures the error returned by os.RemoveAll and logs or
handles it appropriately, ensuring that any cleanup failures are not silently
ignored per the coding guidelines that require never ignoring error returns.
- Line 122: The test "should produce a second tar with only incremental blob
content" is a long-running integration test that lacks a timeout and needs to
pass SpecContext to its mirroring operations. Add a SpecTimeout parameter to the
It() function call to prevent test suite hangs, and update all MirrorToDisk
operation calls within this test (and the related calls at lines 134-135 and
155-156) to accept and use the SpecContext parameter instead of the outer ctx
variable to ensure proper test context handling within Ginkgo.
🪄 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: 5907f313-9121-42bd-a4c1-62b6c40967ac
📒 Files selected for processing (4)
tests/integration/helpers_test.gotests/integration/incremental_mirroring_test.gotests/integration/testdata/imagesetconfigs/operators/isc-operator-incremental-initial.yamltests/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
🚧 Files skipped from review as they are similar to previous changes (2)
- tests/integration/testdata/imagesetconfigs/operators/isc-operator-incremental-update.yaml
- tests/integration/helpers_test.go
| iscInitial := filepath.Join("operators", "isc-operator-incremental-initial.yaml") | ||
| iscUpdate := filepath.Join("operators", "isc-operator-incremental-update.yaml") | ||
|
|
||
| It("should produce a second tar with only incremental blob content", func() { |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Verify this spec currently lacks SpecTimeout and uses non-spec context in MirrorToDisk calls.
rg -nP --type=go -C2 'It\("should produce a second tar with only incremental blob content",\s*func\(' tests/integration/incremental_mirroring_test.go
rg -nP --type=go -C2 'runner\.MirrorToDisk\(' tests/integration/incremental_mirroring_test.goRepository: openshift/oc-mirror
Length of output: 1647
Add timeout to long-running incremental mirroring test and pass SpecContext to mirroring calls.
Line 122 defines a long-running integration test with two MirrorToDisk operations but no SpecTimeout, creating risk of suite hangs. Additionally, the test should pass Ginkgo's SpecContext to the mirroring operations instead of the outer ctx.
Suggested fix
- It("should produce a second tar with only incremental blob content", func() {
+ It("should produce a second tar with only incremental blob content", SpecTimeout(10*time.Minute), func(specCtx SpecContext) {
@@
- result, err := runner.MirrorToDisk(ctx, iscInitialPath, workDir, "--remove-signatures=true")
+ result, err := runner.MirrorToDisk(specCtx, iscInitialPath, workDir, "--remove-signatures=true")
@@
- result, err = runner.MirrorToDisk(ctx, iscUpdatePath, workDir, "--remove-signatures=true")
+ result, err = runner.MirrorToDisk(specCtx, iscUpdatePath, workDir, "--remove-signatures=true")Also applies to lines 134–135, 155–156.
🤖 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 `@tests/integration/incremental_mirroring_test.go` at line 122, The test
"should produce a second tar with only incremental blob content" is a
long-running integration test that lacks a timeout and needs to pass SpecContext
to its mirroring operations. Add a SpecTimeout parameter to the It() function
call to prevent test suite hangs, and update all MirrorToDisk operation calls
within this test (and the related calls at lines 134-135 and 155-156) to accept
and use the SpecContext parameter instead of the outer ctx variable to ensure
proper test context handling within Ginkgo.
Source: Coding guidelines
|
/verified by @nidangavali |
|
@nidangavali: This PR has been marked as verified by DetailsIn response to this:
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. |
|
/retest |
|
/hold Revision 2f5faab was retested 3 times: holding |
|
/retest |
1 similar comment
|
/retest |
| } | ||
|
|
||
| // logOcMirrorResult writes the oc-mirror command result to GinkgoWriter for diagnostics. | ||
| func logOcMirrorResult(label string, result *ocmirror.Result) { |
There was a problem hiding this comment.
The tests are failing with the error below:
# github.com/openshift/oc-mirror/tests/integration_test [github.com/openshift/oc-mirror/tests/integration.test]
./helpers_test.go:959:6: logOcMirrorResult redeclared in this block
./helpers_test.go:905:6: other declaration of logOcMirrorResult
It means that logOcMirrorResult is already declared so it fails because it is not possible to have the same func with the same name in the same pkg.
The same func was introduced on PR #1411 row 781. Since this is already in main, you need to rebase the current PR and solve the conflicts.
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: adolfo-ab, nidangavali The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
New changes are detected. LGTM label has been removed. |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
tests/integration/helpers_test.go (1)
912-915: 🔒 Security & Privacy | 🟠 Major | ⚡ Quick winRedact or remove untrusted diagnostic values from CI logs.
Raw command output, repository names, and tags can expose credentials, internal hostnames, or customer identifiers in retained test logs. Keep aggregate counts/exit status, and redact or gate detailed diagnostics behind an explicit sanitized opt-in.
tests/integration/helpers_test.go#L912-L915: do not print rawresult.Stdout/result.Stderr.tests/integration/helpers_test.go#L927-L933: redact or omit repository/tag values.tests/integration/helpers_test.go#L981-L982: redact or omit archive-derived repository names.As per coding guidelines,
**/*.{go,js,ts,python,py,java,cpp,c,rb,sh}: “Flag logging that may expose passwords, tokens, API keys, PII, session IDs, internal hostnames, or customer data.”🤖 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 `@tests/integration/helpers_test.go` around lines 912 - 915, Redact or remove untrusted diagnostic values from the logging paths in tests/integration/helpers_test.go:912-915, tests/integration/helpers_test.go:927-933, and tests/integration/helpers_test.go:981-982. Update the helper around result.Stdout/result.Stderr to retain only aggregate counts or exit status, and redact or omit repository, tag, and archive-derived repository values; detailed diagnostics may remain only behind an explicit sanitized opt-in.Source: Coding guidelines
🤖 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.
Outside diff comments:
In `@tests/integration/helpers_test.go`:
- Around line 912-915: Redact or remove untrusted diagnostic values from the
logging paths in tests/integration/helpers_test.go:912-915,
tests/integration/helpers_test.go:927-933, and
tests/integration/helpers_test.go:981-982. Update the helper around
result.Stdout/result.Stderr to retain only aggregate counts or exit status, and
redact or omit repository, tag, and archive-derived repository values; detailed
diagnostics may remain only behind an explicit sanitized opt-in.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository: openshift/coderabbit/.coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 5b566157-96ba-45e8-adb6-bb7c7a590618
📒 Files selected for processing (4)
tests/integration/helpers_test.gotests/integration/incremental_mirroring_test.gotests/integration/testdata/imagesetconfigs/operators/isc-operator-incremental-initial.yamltests/integration/testdata/imagesetconfigs/operators/isc-operator-incremental-update.yaml
🚧 Files skipped from review as they are similar to previous changes (2)
- tests/integration/testdata/imagesetconfigs/operators/isc-operator-incremental-initial.yaml
- tests/integration/testdata/imagesetconfigs/operators/isc-operator-incremental-update.yaml
|
@nidangavali: all tests passed! Full PR test history. Your PR dashboard. DetailsInstructions 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. |
|
@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. DetailsIn response to this:
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. |
Description
Add an integration test for operator incremental mirroring (mirrorToDisk). The test verifies that oc-mirror produces archives containing only new content on subsequent runs when the ImageSetConfig changes.
The test runs mirrorToDisk twice against the same workspace with different ISCs:
It then validates that the second archive contains only the incremental data,new blobs from the expanded version range and the newly added package with no overlap from the first archive.
Github / Jira issue: CLID-614
Type of change
Please delete options that are not relevant.
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
Summary by CodeRabbit
Summary by CodeRabbit