Skip to content

STOR-3065: Add storage CSI tests for cloning PVC to a larger volume - #31443

Open
radeore wants to merge 1 commit into
openshift:mainfrom
radeore:pvc-clone-tests
Open

STOR-3065: Add storage CSI tests for cloning PVC to a larger volume#31443
radeore wants to merge 1 commit into
openshift:mainfrom
radeore:pvc-clone-tests

Conversation

@radeore

@radeore radeore commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Add External Storage test coverage for CSI volume cloning to a larger PVC in filesystem and block volume modes
  • Migration of openshift-tests-private OCP-47224 / OCP-47225 test coverage
  • Registers via always-on CSI suites when TEST_CSI_DRIVER_FILES is set

Test plan

  • ./openshift-tests run openshift/csi --dry-run | grep 'CSI Clone'
  • Run clone-larger tests against a cluster with a CapPVCDataSource driver
Ran 1 of 1 Specs in 74.498 seconds
  SUCCESS! -- 1 Passed | 0 Failed | 0 Pending | 0 Skipped
[
  {
    "name": "External Storage [Driver: pd.csi.storage.gke.io] [Testpattern: Dynamic PV (default fs)] OpenShift CSI extended - CSI Clone should provision volume with pvc data source larger than original volume",
    "lifecycle": "blocking",
    "duration": 74498,
    "startTime": "2026-07-28 19:14:04.101340 UTC",
    "endTime": "2026-07-28 19:15:18.599517 UTC",
    "result": "passed", 

 Ran 1 of 1 Specs in 78.288 seconds
  SUCCESS! -- 1 Passed | 0 Failed | 0 Pending | 0 Skipped
[
  {
    "name": "External Storage [Driver: pd.csi.storage.gke.io] [Testpattern: Dynamic PV (block volmode)] OpenShift CSI extended - CSI Clone should provision volume with pvc data source larger than original volume",
    "lifecycle": "blocking",
    "duration": 78287,
    "startTime": "2026-07-28 19:16:18.629749 UTC",
    "endTime": "2026-07-28 19:17:36.917712 UTC",
    "result": "passed",

Summary by CodeRabbit

  • New Features

    • Added extended CSI coverage for cloning persistent volumes into larger destinations.
    • Supports both filesystem and raw block volume modes, with validation of cloned content.
    • Added topology-aware scheduling to help ensure source and clone volumes remain within compatible topology segments.
  • Bug Fixes

    • Improved CSI test initialization so always-on suites are registered consistently when CSI manifests are configured.

@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

@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Jul 28, 2026
@openshift-ci-robot

openshift-ci-robot commented Jul 28, 2026

Copy link
Copy Markdown

@radeore: This pull request references STOR-3065 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 sub-task to target the "5.0.0" version, but no target version was set.

Details

In response to this:

Summary

  • Add External Storage test coverage for CSI volume cloning to a larger PVC in filesystem and block volume modes
  • Migration of openshift-tests-private OCP-47224 / OCP-47225 test coverage
  • Registers via always-on CSI suites when TEST_CSI_DRIVER_FILES is set

Test plan

  • ./openshift-tests run openshift/csi --dry-run | grep 'CSI Clone'
  • Run clone-larger tests against a cluster with a CapPVCDataSource driver

Test run logs:

Ran 1 of 1 Specs in 74.498 seconds
 SUCCESS! -- 1 Passed | 0 Failed | 0 Pending | 0 Skipped
[
 {
   "name": "External Storage [Driver: pd.csi.storage.gke.io] [Testpattern: Dynamic PV (default fs)] OpenShift CSI extended - CSI Clone should provision volume with pvc data source larger than original volume",
   "lifecycle": "blocking",
   "duration": 74498,
   "startTime": "2026-07-28 19:14:04.101340 UTC",
   "endTime": "2026-07-28 19:15:18.599517 UTC",
   "result": "passed", 

Ran 1 of 1 Specs in 78.288 seconds
 SUCCESS! -- 1 Passed | 0 Failed | 0 Pending | 0 Skipped
[
 {
   "name": "External Storage [Driver: pd.csi.storage.gke.io] [Testpattern: Dynamic PV (block volmode)] OpenShift CSI extended - CSI Clone should provision volume with pvc data source larger than original volume",
   "lifecycle": "blocking",
   "duration": 78287,
   "startTime": "2026-07-28 19:16:18.629749 UTC",
   "endTime": "2026-07-28 19:17:36.917712 UTC",
   "result": "passed",

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.

@coderabbitai

coderabbitai Bot commented Jul 28, 2026

Copy link
Copy Markdown

Walkthrough

A new CSI extended suite tests cloning a source PVC into a larger filesystem or raw block PVC. Registration is guarded with sync.Once and invoked during CSI initialization when an upstream CSI manifest is configured.

Changes

CSI larger PVC clone

Layer / File(s) Summary
Larger PVC clone suite
test/extended/storage/csi/pvc_clone_larger.go
Adds capability-gated filesystem and raw block clone tests, larger DataSourceRef PVC creation, attachment waiting, content validation, and topology pinning.
One-time CSI suite registration
test/extended/storage/csi/csi.go
Registers the new suite initializer once per process using sync.Once.
CSI initialization wiring
pkg/clioptions/clusterdiscovery/csi.go
Registers always-on CSI suites before OCP manifest handling and driver definition registration when the upstream manifest is configured.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant InitCSITests
  participant testsuites.CSISuites
  participant pvcCloneLargerCSISuite
  participant KubernetesAPI
  participant StorageClassTest

  InitCSITests->>testsuites.CSISuites: RegisterAlwaysOnCSISuites
  testsuites.CSISuites->>pvcCloneLargerCSISuite: append initializer once
  pvcCloneLargerCSISuite->>KubernetesAPI: create source PVC and larger clone
  KubernetesAPI-->>pvcCloneLargerCSISuite: report clone availability
  pvcCloneLargerCSISuite->>StorageClassTest: validate cloned content with PvCheck
Loading

Suggested labels: approved, lgtm, verified


Caution

Pre-merge checks failed

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

  • Ignore

❌ Failed checks (1 error)

Check name Status Explanation Resolution
Ote Binary Stdout Contract ❌ Error InitCSITests runs in binary startup and still calls fmt.Printf, writing to stdout before test listing and risking JSON corruption. Replace the fmt.Printf in process-level setup with stderr logging (or remove it), e.g. fmt.Fprintf(os.Stderr, ...) or klog to stderr.
✅ Passed checks (14 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: new CSI tests for cloning a PVC to a larger volume.
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 PASS: The new Ginkgo title is a static string; suite names are static too, and dynamic values stay in test bodies, not titles.
Test Structure And Quality ✅ Passed The new CSI test has one focused It block, uses DeferCleanup for PVC/SC cleanup, and all cluster waits use bounded timeouts consistent with nearby tests.
Microshift Test Compatibility ✅ Passed The new CSI clone-larger test uses only core Kubernetes storage APIs and has no MicroShift-incompatible OpenShift API or feature assumptions.
Single Node Openshift (Sno) Test Compatibility ✅ Passed The new CSI clone-larger test uses a single node selection/topology pinning and has no multi-node, HA, or SNO-skip assumptions.
Topology-Aware Scheduling Compatibility ✅ Passed The new CSI test only pins pods to a driver-advertised topology segment; it doesn’t target master/worker labels, replicas, or HA-only node counts.
Ipv6 And Disconnected Network Test Compatibility ✅ Passed The new Ginkgo CSI test uses only cluster-internal storage APIs and topology labels; no IPv4 literals, IPv4-only parsing, host URL building, or public internet connectivity were found.
No-Weak-Crypto ✅ Passed Touched files add CSI test registration and clone coverage only; no weak crypto, custom crypto, or secret comparisons found.
Container-Privileges ✅ Passed No changed manifest or pod spec sets privileged/hostPID/hostNetwork/hostIPC/SYS_ADMIN/root/allowPrivilegeEscalation; only namespace pod-security level is privileged.
No-Sensitive-Data-In-Logs ✅ Passed New output is limited to manifest paths, driver names, and test step text; no passwords, tokens, PII, or customer data are logged.
✨ 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.

@openshift-ci
openshift-ci Bot requested review from dobsonj and sjenning July 28, 2026 20:21
@openshift-ci

openshift-ci Bot commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: radeore
Once this PR has been reviewed and has the lgtm label, please assign bertinatto 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 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)
test/extended/storage/csi/pvc_clone_larger.go (1)

26-31: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Suite name doesn't distinguish this suite from other clone suites.

Name: "OpenShift CSI extended - CSI Clone" feeds directly into generated Ginkgo test names. Something like "OpenShift CSI extended - CSI Clone Larger" keeps test IDs unambiguous and greppable if another clone suite is added later.

🤖 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 `@test/extended/storage/csi/pvc_clone_larger.go` around lines 26 - 31, Update
the TestSuiteInfo.Name value in the CSI clone-larger suite to include a
distinguishing “Larger” suffix, ensuring generated Ginkgo test names and IDs are
unambiguous while leaving the existing test patterns unchanged.
🤖 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/extended/storage/csi/pvc_clone_larger.go`:
- Around line 119-123: In the PVC clone sizing flow after retrieving sourcePVC,
validate that sourcePVC.Status.Capacity.Storage() is non-zero before creating
storageRequest. Fail the test with an explicit assertion if capacity is missing
or zero, then preserve the existing largerSize calculation for valid capacities.

---

Nitpick comments:
In `@test/extended/storage/csi/pvc_clone_larger.go`:
- Around line 26-31: Update the TestSuiteInfo.Name value in the CSI clone-larger
suite to include a distinguishing “Larger” suffix, ensuring generated Ginkgo
test names and IDs are unambiguous while leaving the existing test patterns
unchanged.
🪄 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: 5cf79345-5e21-47e3-a09a-81900b6afd35

📥 Commits

Reviewing files that changed from the base of the PR and between f2d5df6 and cb36e46.

📒 Files selected for processing (3)
  • pkg/clioptions/clusterdiscovery/csi.go
  • test/extended/storage/csi/csi.go
  • test/extended/storage/csi/pvc_clone_larger.go

Comment on lines +119 to +123
sourcePVC, err = cs.CoreV1().PersistentVolumeClaims(sourcePVC.Namespace).Get(ctx, sourcePVC.Name, metav1.GetOptions{})
e2e.ExpectNoError(err, "Failed to get source PVC: %v", err)
storageRequest := resource.NewQuantity(sourcePVC.Status.Capacity.Storage().Value(), resource.BinarySI)
storageRequest.Add(resource.MustParse("1Gi"))
largerSize := storageRequest.String()

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Assert the source capacity is non-zero before deriving the clone size.

If Status.Capacity is missing (unbound/late-status PVC), Storage() yields 0 and largerSize silently becomes exactly 1Gi, so the test no longer verifies "larger than the source" — it may even request less than the source. A cheap guard keeps the intent explicit.

🛡️ Proposed guard
 	e2e.ExpectNoError(err, "Failed to get source PVC: %v", err)
-	storageRequest := resource.NewQuantity(sourcePVC.Status.Capacity.Storage().Value(), resource.BinarySI)
+	sourceCapacity := sourcePVC.Status.Capacity.Storage().Value()
+	o.Expect(sourceCapacity).To(o.BeNumerically(">", 0), "source PVC has no reported capacity")
+	storageRequest := resource.NewQuantity(sourceCapacity, resource.BinarySI)
 	storageRequest.Add(resource.MustParse("1Gi"))
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
sourcePVC, err = cs.CoreV1().PersistentVolumeClaims(sourcePVC.Namespace).Get(ctx, sourcePVC.Name, metav1.GetOptions{})
e2e.ExpectNoError(err, "Failed to get source PVC: %v", err)
storageRequest := resource.NewQuantity(sourcePVC.Status.Capacity.Storage().Value(), resource.BinarySI)
storageRequest.Add(resource.MustParse("1Gi"))
largerSize := storageRequest.String()
sourcePVC, err = cs.CoreV1().PersistentVolumeClaims(sourcePVC.Namespace).Get(ctx, sourcePVC.Name, metav1.GetOptions{})
e2e.ExpectNoError(err, "Failed to get source PVC: %v", err)
sourceCapacity := sourcePVC.Status.Capacity.Storage().Value()
o.Expect(sourceCapacity).To(o.BeNumerically(">", 0), "source PVC has no reported capacity")
storageRequest := resource.NewQuantity(sourceCapacity, resource.BinarySI)
storageRequest.Add(resource.MustParse("1Gi"))
largerSize := storageRequest.String()
🤖 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 `@test/extended/storage/csi/pvc_clone_larger.go` around lines 119 - 123, In the
PVC clone sizing flow after retrieving sourcePVC, validate that
sourcePVC.Status.Capacity.Storage() is non-zero before creating storageRequest.
Fail the test with an explicit assertion if capacity is missing or zero, then
preserve the existing largerSize calculation for valid capacities.

@openshift-merge-bot

Copy link
Copy Markdown
Contributor

Scheduling required tests:
/test e2e-aws-csi
/test e2e-aws-ovn-fips
/test e2e-aws-ovn-microshift
/test e2e-aws-ovn-microshift-serial
/test e2e-aws-ovn-serial-1of2
/test e2e-aws-ovn-serial-2of2
/test e2e-gcp-csi
/test e2e-gcp-ovn
/test e2e-gcp-ovn-upgrade
/test e2e-metal-ipi-ovn-ipv6
/test e2e-vsphere-ovn
/test e2e-vsphere-ovn-upi

@openshift-ci

openshift-ci Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

@radeore: The following test 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-microshift cb36e46 link true /test e2e-aws-ovn-microshift

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.

@openshift-trt

openshift-trt Bot commented Jul 29, 2026

Copy link
Copy Markdown

Risk analysis has seen new tests most likely introduced by this PR.
Please ensure that new tests meet guidelines for naming and stability.

New Test Risks for sha: cb36e46

Job Name New Test Risk
pull-ci-openshift-origin-main-e2e-gcp-csi Medium - "External Storage [Driver: pd.csi.storage.gke.io] [Testpattern: Dynamic PV (block volmode)] OpenShift CSI extended - CSI Clone should provision volume with pvc data source larger than original volume" is a new test, and was only seen in one job.
pull-ci-openshift-origin-main-e2e-gcp-csi Medium - "External Storage [Driver: pd.csi.storage.gke.io] [Testpattern: Dynamic PV (default fs)] OpenShift CSI extended - CSI Clone should provision volume with pvc data source larger than original volume" is a new test, and was only seen in one job.

New tests seen in this PR at sha: cb36e46

  • "External Storage [Driver: pd.csi.storage.gke.io] [Testpattern: Dynamic PV (block volmode)] OpenShift CSI extended - CSI Clone should provision volume with pvc data source larger than original volume" [Total: 1, Pass: 1, Fail: 0, Flake: 0]
  • "External Storage [Driver: pd.csi.storage.gke.io] [Testpattern: Dynamic PV (default fs)] OpenShift CSI extended - CSI Clone should provision volume with pvc data source larger than original volume" [Total: 1, Pass: 1, Fail: 0, Flake: 0]

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.

2 participants