Skip to content

e2e: add snapshot metadata e2e tests for RBD - #6459

Open
Rakshith-R wants to merge 2 commits into
ceph:develfrom
Rakshith-R:worktree-e2e-snapshot-metadata
Open

e2e: add snapshot metadata e2e tests for RBD#6459
Rakshith-R wants to merge 2 commits into
ceph:develfrom
Rakshith-R:worktree-e2e-snapshot-metadata

Conversation

@Rakshith-R

@Rakshith-R Rakshith-R commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Vendor github.com/kubernetes-csi/external-snapshot-metadata for sidecar gRPC API
  • Add 8 e2e test cases for CSI snapshot metadata (CBT) covering GetMetadataAllocated and GetMetadataDelta sidecar API
  • Tests require --operator-deployment (ceph-csi-operator mode)

Test Cases

# Test Validates
1 Allocated blocks 4 blocks at 4MB offsets returned correctly
2 Delta blocks Only changed blocks between two snapshots
3 Starting offset Blocks before offset are skipped
4 Empty volume 0 blocks for empty snapshot
5 No-change delta 0 delta blocks when nothing changed
6 Max-results batching Response batching respects limit
7 Invalid audience Unauthenticated error on wrong token audience
8 Missing RBAC PermissionDenied error without RBAC

Architecture

  • snapshot_metadata_helper.go: Infrastructure setup/teardown (TLS certs, OperatorConfig patch, sidecar verification, SMS CRD/CR, RBAC, port-forward, gRPC client)
  • snapshot_metadata.go: 8 Ginkgo test cases in Describe("RBD") > Context("[SnapshotMetadata]", Ordered)

Test plan

  • go build ./... passes in e2e/
  • All 8 TCs pass in minikube + Rook Ceph + ceph-csi-operator (3 consecutive green runs)

depends-on: #6452

🤖 Generated with Claude Code

Add github.com/kubernetes-csi/external-snapshot-metadata v1.1.0 to
e2e/go.mod for the sidecar gRPC API used by snapshot metadata e2e tests.

Assisted-by: Claude <noreply@anthropic.com>
Signed-off-by: Rakshith R <rar@redhat.com>
@Rakshith-R

Copy link
Copy Markdown
Contributor Author

/test ci/centos/mini-e2e/k8s-1.36/rbd

@mergify mergify Bot added the component/testing Additional test cases or CI work label Aug 5, 2026
@Rakshith-R

Copy link
Copy Markdown
Contributor Author

/test ci/centos/mini-e2e-operator/k8s-1.36/rbd

1 similar comment
@Rakshith-R

Copy link
Copy Markdown
Contributor Author

/test ci/centos/mini-e2e-operator/k8s-1.36/rbd

Add 8 end-to-end test cases for CSI snapshot metadata (CBT) covering
the sidecar gRPC API for GetMetadataAllocated and GetMetadataDelta.

Tests require --operator-deployment and exercise:
- Allocated block retrieval with exact offset verification
- Delta block detection between two snapshots
- Starting offset filtering
- Empty volume and no-change delta edge cases
- Max-results batching across streaming responses
- Authentication rejection with invalid audience
- Authorization rejection without RBAC

Assisted-by: Claude <noreply@anthropic.com>
Signed-off-by: Rakshith R <rar@redhat.com>
@Rakshith-R
Rakshith-R force-pushed the worktree-e2e-snapshot-metadata branch from 486cc9f to 06cf113 Compare August 5, 2026 14:22
@Rakshith-R

Copy link
Copy Markdown
Contributor Author

/test ci/centos/mini-e2e-operator/k8s-1.36/rbd

@Rakshith-R
Rakshith-R marked this pull request as ready for review August 6, 2026 07:53
@Rakshith-R
Rakshith-R requested review from a team as code owners August 6, 2026 07:53
Copilot AI lite review requested due to automatic review settings August 6, 2026 07:53

Copilot AI 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.

Pull request overview

Adds an RBD-focused E2E test suite that validates the Kubernetes SnapshotMetadata (CBT) sidecar gRPC API (GetMetadataAllocated, GetMetadataDelta) when running Ceph-CSI via the operator, and vendors the required external SnapshotMetadata API dependency into the e2e/ module.

Changes:

  • Add SnapshotMetadata E2E coverage for RBD (8 test cases) plus supporting infra/helper code (TLS, CRD/CR, RBAC, port-forward, gRPC client).
  • Vendor github.com/kubernetes-csi/external-snapshot-metadata and update e2e/ module dependencies (OpenTelemetry, go-openapi, fsnotify, genproto, etc.).
  • Update e2e/ module metadata (go.mod, go.sum, vendored module manifests/files) to reflect the new dependency set.

Reviewed changes

Copilot reviewed 3 out of 93 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
e2e/snapshot_metadata.go Adds 8 SnapshotMetadata E2E test cases for RBD in operator mode.
e2e/snapshot_metadata_helper.go Adds infra helpers (TLS, OperatorConfig patching, CRD/CR, RBAC, port-forward, gRPC client).
e2e/go.mod Adds external-snapshot-metadata + grpc dependency; bumps/adjusts indirect deps.
e2e/go.sum Updates checksums for new/updated dependencies.
e2e/vendor/modules.txt Records newly vendored module set (incl. external-snapshot-metadata) and version bumps.
e2e/vendor/github.com/kubernetes-csi/external-snapshot-metadata/pkg/api/schema_grpc.pb.go Vendored SnapshotMetadata gRPC API client/server stubs used by E2E.
e2e/vendor/github.com/kubernetes-csi/external-snapshot-metadata/LICENSE Vendored license file for external-snapshot-metadata.
e2e/vendor/go.opentelemetry.io/otel/versions.yaml Vendored OTel module-set version bumps.
e2e/vendor/go.opentelemetry.io/otel/version.go Updates OTel version constant.
e2e/vendor/go.opentelemetry.io/otel/trace/internal/telemetry/span.go OTel trace JSON marshal refactor (vendor update).
e2e/vendor/go.opentelemetry.io/otel/trace/config.go Skips experimental options in stable config constructors (vendor update).
e2e/vendor/go.opentelemetry.io/otel/trace/auto.go Updates semconv import + adds BYTESLICE/SLICE handling (vendor update).
e2e/vendor/go.opentelemetry.io/otel/semconv/v1.41.0/schema.go Adds vendored semconv v1.41.0 package.
e2e/vendor/go.opentelemetry.io/otel/semconv/v1.41.0/README.md Adds semconv v1.41.0 README (vendor).
e2e/vendor/go.opentelemetry.io/otel/semconv/v1.41.0/MIGRATION.md Adds semconv v1.41.0 migration doc (vendor).
e2e/vendor/go.opentelemetry.io/otel/semconv/v1.41.0/exception.go Adds semconv v1.41.0 exception constants (vendor).
e2e/vendor/go.opentelemetry.io/otel/semconv/v1.41.0/error_type.go Adds semconv v1.41.0 ErrorType helpers (vendor).
e2e/vendor/go.opentelemetry.io/otel/semconv/v1.41.0/doc.go Adds semconv v1.41.0 package docs (vendor).
e2e/vendor/go.opentelemetry.io/otel/semconv/v1.40.0/otelconv/metric.go Vendor update: metric helpers + Enabled short-circuits.
e2e/vendor/go.opentelemetry.io/otel/semconv/v1.40.0/error_type.go Vendor update: fmt-wrapped error unwrapping for ErrorType.
e2e/vendor/go.opentelemetry.io/otel/semconv/v1.40.0/attribute_group.go Vendor update: comment formatting + whitespace fixes.
e2e/vendor/go.opentelemetry.io/otel/semconv/v1.39.0/otelconv/metric.go Vendor update: metric helpers formatting.
e2e/vendor/go.opentelemetry.io/otel/semconv/v1.39.0/httpconv/metric.go Vendor update: doc layout tweaks.
e2e/vendor/go.opentelemetry.io/otel/semconv/v1.39.0/attribute_group.go Vendor update: comment formatting + whitespace fixes.
e2e/vendor/go.opentelemetry.io/otel/semconv/v1.37.0/attribute_group.go Vendor update: comment formatting + whitespace fixes.
e2e/vendor/go.opentelemetry.io/otel/propagation/baggage.go Vendor update: enforce baggage limits + limit error reporting.
e2e/vendor/go.opentelemetry.io/otel/metric/syncint64.go Vendor update: skip experimental options in config constructors.
e2e/vendor/go.opentelemetry.io/otel/metric/syncfloat64.go Vendor update: skip experimental options in config constructors.
e2e/vendor/go.opentelemetry.io/otel/metric/instrument.go Vendor update: settable attr options + skip experimental options.
e2e/vendor/go.opentelemetry.io/otel/metric/doc.go Vendor update: docs for gauges + Enabled optimization guidance.
e2e/vendor/go.opentelemetry.io/otel/metric/config.go Vendor update: skip experimental options in Meter config.
e2e/vendor/go.opentelemetry.io/otel/metric/asyncint64.go Vendor update: skip experimental options in async config constructors.
e2e/vendor/go.opentelemetry.io/otel/metric/asyncfloat64.go Vendor update: skip experimental options in async config constructors.
e2e/vendor/go.opentelemetry.io/otel/baggage/baggage.go Vendor update: enforce 8192-byte parsing limit + error truncation.
e2e/vendor/go.opentelemetry.io/otel/attribute/type_string.go Vendor update: add BYTESLICE and SLICE types.
e2e/vendor/go.opentelemetry.io/otel/attribute/set.go Vendor update: Value.String in MarshalLog + minor reflection assignment.
e2e/vendor/go.opentelemetry.io/otel/attribute/kv.go Vendor update: add ByteSlice/Slice KeyValue helpers.
e2e/vendor/go.opentelemetry.io/otel/attribute/key.go Vendor update: add ByteSlice/Slice Key helpers.
e2e/vendor/go.opentelemetry.io/otel/attribute/hash.go Vendor update: hash BYTESLICE/SLICE values + refactor hashing.
e2e/vendor/go.opentelemetry.io/otel/attribute/encoder.go Vendor update: keep Emit output w/ lint suppression.
e2e/vendor/go.opentelemetry.io/otel/Makefile Vendor update: benchmark sharding variables.
e2e/vendor/go.opentelemetry.io/otel/dependencies.Dockerfile Vendor update: bump weaver image.
e2e/vendor/go.opentelemetry.io/otel/CONTRIBUTING.md Vendor update: semconv version references + guidance edits.
e2e/vendor/go.opentelemetry.io/otel/CHANGELOG.md Vendor update: add 1.44.0 release notes/links.
e2e/vendor/go.opentelemetry.io/otel/AGENTS.md Vendor adds upstream agent guide doc.
e2e/vendor/go.opentelemetry.io/otel/.golangci.yml Vendor update: semconv depguard + revive arg key renames.
e2e/vendor/github.com/go-openapi/swag/README.md Vendor update: docs/links and module list changes.
e2e/vendor/github.com/go-openapi/swag/loading/options.go Vendor update: add WithRoot confinement + security notes.
e2e/vendor/github.com/go-openapi/swag/loading/loading.go Vendor update: safer http(s) scheme detection + FS-backed path handling.
e2e/vendor/github.com/go-openapi/swag/loading/doc.go Vendor update: expanded security documentation.
e2e/vendor/github.com/go-openapi/swag/loading_iface.go Vendor update: avoid extra allocations in default options assembly.
e2e/vendor/github.com/go-openapi/swag/jsonname_iface.go Vendor update: jsonname import relocation/deprecation plumbing.
e2e/vendor/github.com/go-openapi/swag/go.work Vendor update: includes new pools module.
e2e/vendor/github.com/go-openapi/swag/CONTRIBUTORS.md Vendor update: contributor counts/links.
e2e/vendor/github.com/go-openapi/swag/.golangci.yml Vendor update: enable additional linters.
e2e/vendor/github.com/go-openapi/swag/.gitignore Vendor update: ignores worktree artifacts.
e2e/vendor/github.com/go-openapi/jsonreference/README.md Vendor update: docs links + announcement block comment.
e2e/vendor/github.com/go-openapi/jsonreference/CONTRIBUTORS.md Vendor update: contributor counts/formatting.
e2e/vendor/github.com/go-openapi/jsonreference/.gitignore Vendor update: ignore list adjustments.
e2e/vendor/github.com/go-openapi/jsonpointer/README.md Vendor update: announcements and project status text.
e2e/vendor/github.com/go-openapi/jsonpointer/pointer.go Vendor update: doc/comment restructuring and behavior clarifications.
e2e/vendor/github.com/go-openapi/jsonpointer/options.go Vendor update: jsonname import relocation + doc tweaks.
e2e/vendor/github.com/go-openapi/jsonpointer/jsonname/name_provider.go Vendor update: globals lint suppression + minor refactors.
e2e/vendor/github.com/go-openapi/jsonpointer/jsonname/ifaces.go Vendor update: doc formatting.
e2e/vendor/github.com/go-openapi/jsonpointer/jsonname/go_name_provider.go Vendor update: reflect.Pointer usage + minor refactors.
e2e/vendor/github.com/go-openapi/jsonpointer/jsonname/doc.go Vendor adds SPDX + package doc.
e2e/vendor/github.com/go-openapi/jsonpointer/ifaces.go Vendor update: docs + jsonname import relocation.
e2e/vendor/github.com/go-openapi/jsonpointer/errors.go Vendor update: doc formatting.
e2e/vendor/github.com/go-openapi/jsonpointer/CONTRIBUTORS.md Vendor update: contributor counts/links.
e2e/vendor/github.com/go-openapi/jsonpointer/.golangci.yml Vendor update: linter configuration.
e2e/vendor/github.com/fsnotify/fsnotify/README.md Vendor update: Go version requirement + expanded platform notes.
e2e/vendor/github.com/fsnotify/fsnotify/internal/windows.go Vendor update: remove SetRlimit stub.
e2e/vendor/github.com/fsnotify/fsnotify/internal/unix2.go Vendor adds IgnoringEINTR helper.
e2e/vendor/github.com/fsnotify/fsnotify/internal/unix.go Vendor update: removes SetRlimit implementation.
e2e/vendor/github.com/fsnotify/fsnotify/internal/freebsd.go Vendor update: removes SetRlimit implementation.
e2e/vendor/github.com/fsnotify/fsnotify/internal/darwin.go Vendor update: removes SetRlimit implementation.
e2e/vendor/github.com/fsnotify/fsnotify/internal/debug_openbsd.go Vendor update: debug mask list trimming.
e2e/vendor/github.com/fsnotify/fsnotify/internal/debug_netbsd.go Vendor update: debug mask list trimming.
e2e/vendor/github.com/fsnotify/fsnotify/internal/debug_kqueue.go Vendor update: debug output formatting tweak.
e2e/vendor/github.com/fsnotify/fsnotify/internal/debug_freebsd.go Vendor update: debug mask list reorder/trim.
e2e/vendor/github.com/fsnotify/fsnotify/internal/debug_dragonfly.go Vendor update: debug mask list trimming.
e2e/vendor/github.com/fsnotify/fsnotify/internal/debug_darwin.go Vendor update: debug mask list trimming.
e2e/vendor/github.com/fsnotify/fsnotify/fsnotify.go Vendor update: docs + internal flags for recursion.
e2e/vendor/github.com/fsnotify/fsnotify/CONTRIBUTING.md Vendor update: adds internal debug command notes.
e2e/vendor/github.com/fsnotify/fsnotify/CHANGELOG.md Vendor update: adds 1.10.x entries.
e2e/vendor/github.com/fsnotify/fsnotify/backend_windows.go Vendor update: concurrency fixes + unsafe.Slice usage.
e2e/vendor/github.com/fsnotify/fsnotify/backend_kqueue.go Vendor update: fd leak fix + IgnoringEINTR usage + state dump.
e2e/vendor/github.com/fsnotify/fsnotify/backend_inotify.go Vendor update: improved errors + recursion/watch flag semantics.
e2e/vendor/github.com/fsnotify/fsnotify/backend_fen.go Vendor update: IgnoringEINTR usage.
e2e/vendor/github.com/fsnotify/fsnotify/.cirrus.yml Vendor removes Cirrus CI config.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread e2e/snapshot_metadata.go
dynClient, err = dynamic.NewForConfig(f.ClientConfig())
Expect(err).ShouldNot(HaveOccurred())

testNamespace = "sms-e2e-test"
Comment on lines +243 to +270
// patchOperatorConfigWithTLS patches the OperatorConfig CR to add a
// tls-key volume, triggering operator sidecar injection.
func patchOperatorConfigWithTLS(namespace, tlsSecretName string) error {
patch := fmt.Sprintf(`{"spec":{"driverSpecDefaults":{"controllerPlugin":{"volumes":[{"volume":{"name":"tls-key","secret":{"secretName":%q}},"mount":{"name":"tls-key","mountPath":"/tmp/certificates","readOnly":true}}]}}}}`, tlsSecretName)

args := []string{
"operatorconfigs.csi.ceph.io",
OperatorConfigName,
"--type=merge",
"-p",
patch,
}

return retryKubectlArgs(namespace, kubectlPatch, deployTimeout, args...)
}

// unpatchOperatorConfigTLS removes the controllerPlugin volumes.
func unpatchOperatorConfigTLS(namespace string) error {
args := []string{
"operatorconfigs.csi.ceph.io",
OperatorConfigName,
"--type=json",
"-p",
`[{"op":"remove","path":"/spec/driverSpecDefaults/controllerPlugin/volumes"}]`,
}

return retryKubectlArgs(namespace, kubectlPatch, deployTimeout, args...)
}
Comment thread e2e/snapshot_metadata.go
Comment on lines +147 to +156
if clientSet != nil {
if err := clientSet.CoreV1().Secrets(cephCSINamespace).Delete(
context.TODO(), rbdProvisionerSecretName, metav1.DeleteOptions{}); err != nil {
framework.Logf("Warning: failed to delete provisioner secret: %v", err)
}
if err := clientSet.CoreV1().Secrets(cephCSINamespace).Delete(
context.TODO(), rbdNodePluginSecretName, metav1.DeleteOptions{}); err != nil {
framework.Logf("Warning: failed to delete node secret: %v", err)
}
}
Comment on lines +425 to +472
if _, err := clientSet.CoreV1().ServiceAccounts(testNamespace).Create(ctx, sa, metav1.CreateOptions{}); err != nil {
return fmt.Errorf("failed to create SA %s: %w", saName, err)
}

cr := &rbacv1.ClusterRole{
ObjectMeta: metav1.ObjectMeta{Name: smsClusterRole},
Rules: []rbacv1.PolicyRule{
{
APIGroups: []string{"snapshot.storage.k8s.io"},
Resources: []string{"volumesnapshots", "volumesnapshotcontents"},
Verbs: []string{"get", "list", "watch"},
},
{
APIGroups: []string{"cbt.storage.k8s.io"},
Resources: []string{"snapshotmetadataservices"},
Verbs: []string{"get", "list"},
},
{
APIGroups: []string{""},
Resources: []string{"serviceaccounts/token"},
Verbs: []string{"create", "get"},
},
},
}
if _, err := clientSet.RbacV1().ClusterRoles().Create(ctx, cr, metav1.CreateOptions{}); err != nil {
return fmt.Errorf("failed to create ClusterRole %s: %w", smsClusterRole, err)
}

crb := &rbacv1.ClusterRoleBinding{
ObjectMeta: metav1.ObjectMeta{Name: smsClusterRole},
RoleRef: rbacv1.RoleRef{
APIGroup: "rbac.authorization.k8s.io",
Kind: "ClusterRole",
Name: smsClusterRole,
},
Subjects: []rbacv1.Subject{
{
Kind: "ServiceAccount",
Name: saName,
Namespace: testNamespace,
},
},
}
if _, err := clientSet.RbacV1().ClusterRoleBindings().Create(ctx, crb, metav1.CreateOptions{}); err != nil {
return fmt.Errorf("failed to create ClusterRoleBinding %s: %w", smsClusterRole, err)
}

return nil
Comment thread e2e/snapshot_metadata.go
Comment on lines +131 to +134
AfterAll(func() {
if conn != nil {
_ = conn.Close()
}
smsServiceName = "csi-snapshot-metadata"
smsTestSAName = "sms-e2e-tester"
smsClusterRole = "sms-e2e-tester"
smsLocalPort = 6443
@mergify

mergify Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Merge Protections

🔴 1 of 2 protections blocking · waiting on ⛓️ dependency

Protection Waiting on
🔴 ⛓️ Depends-On Requirements ⛓️ dependency
🟢 🚦 Auto-queue

🔴 ⛓️ Depends-On Requirements

Waiting for

This rule is failing.

Requirement based on the presence of Depends-On in the body of the pull request


Show 1 satisfied protection

🟢 🚦 Auto-queue

When all merge protections are satisfied, this pull request will be queued automatically.

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

Labels

component/testing Additional test cases or CI work

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants