Skip to content

Commit bc56de8

Browse files
e2e: add VolumeGroupSnapshot tests and examples for NVMe-oF
Add VolumeGroupSnapshot e2e test type for NVMe-oF and example YAMLs for VolumeGroupSnapshotClass and VolumeGroupSnapshot resources. Signed-off-by: Praveen M <m.praveen@ibm.com>
1 parent 4666634 commit bc56de8

4 files changed

Lines changed: 127 additions & 0 deletions

File tree

e2e/nvmeof.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -498,5 +498,18 @@ var _ = ginkgo.Describe("nvmeof", func() {
498498
validateRBDImageCount(f, 0, nvmeofPool)
499499
validateOmapCount(f, 0, rbdType, nvmeofPool, volumesType)
500500
})
501+
502+
ginkgo.It("test volumeGroupSnapshot", func() {
503+
scName := nvmeofStorageClass
504+
snapshotter, err := newNVMeOFVolumeGroupSnapshot(
505+
f, f.UniqueName, scName, false, deployTimeout, 3, 0)
506+
if err != nil {
507+
logAndFail("failed to create volumeGroupSnapshot Base: %v", err)
508+
}
509+
err = snapshotter.TestVolumeGroupSnapshot()
510+
if err != nil {
511+
logAndFail("failed to test volumeGroupSnapshot: %v", err)
512+
}
513+
})
501514
})
502515
})

e2e/volumegroupsnapshot.go

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,3 +322,86 @@ func (rvgs *rbdVolumeGroupSnapshot) ValidateResourcesForDelete() error {
322322

323323
return nil
324324
}
325+
326+
type nvmeofVolumeGroupSnapshot struct {
327+
*volumeGroupSnapshotterBase
328+
}
329+
330+
var _ VolumeGroupSnapshotter = &nvmeofVolumeGroupSnapshot{}
331+
332+
func newNVMeOFVolumeGroupSnapshot(f *framework.Framework, namespace,
333+
storageClass string,
334+
blockPVC bool,
335+
timeout, totalPVCCount, additionalVGSnapshotCount int,
336+
) (VolumeGroupSnapshotter, error) {
337+
base, err := newVolumeGroupSnapshotBase(f, namespace, storageClass, blockPVC,
338+
timeout, totalPVCCount, additionalVGSnapshotCount)
339+
if err != nil {
340+
return nil, fmt.Errorf("failed to create volumeGroupSnapshotterBase: %w", err)
341+
}
342+
343+
return &nvmeofVolumeGroupSnapshot{
344+
volumeGroupSnapshotterBase: base,
345+
}, nil
346+
}
347+
348+
func (nvgs *nvmeofVolumeGroupSnapshot) TestVolumeGroupSnapshot() error {
349+
return nvgs.volumeGroupSnapshotterBase.testVolumeGroupSnapshot(nvgs)
350+
}
351+
352+
func (nvgs *nvmeofVolumeGroupSnapshot) GetVolumeGroupSnapshotClass() (
353+
*groupsnapapi.VolumeGroupSnapshotClass, error,
354+
) {
355+
vgscPath := fmt.Sprintf("%s/%s", nvmeofExamplePath, "groupsnapshotclass.yaml")
356+
vgsc := &groupsnapapi.VolumeGroupSnapshotClass{}
357+
err := unmarshal(vgscPath, vgsc)
358+
if err != nil {
359+
return nil, fmt.Errorf("failed to unmarshal VolumeGroupSnapshotClass: %w", err)
360+
}
361+
362+
vgsc.Parameters["csi.storage.k8s.io/group-snapshotter-secret-namespace"] = cephCSINamespace
363+
vgsc.Parameters["csi.storage.k8s.io/group-snapshotter-secret-name"] = nvmeofProvisionerSecretName
364+
vgsc.Parameters["pool"] = nvmeofPool
365+
366+
fsID, err := getClusterID(nvgs.framework)
367+
if err != nil {
368+
return nil, fmt.Errorf("failed to get clusterID: %w", err)
369+
}
370+
vgsc.Parameters["clusterID"] = fsID
371+
372+
return vgsc, nil
373+
}
374+
375+
func (nvgs *nvmeofVolumeGroupSnapshot) ValidateResourcesForCreate(
376+
vgs *groupsnapapi.VolumeGroupSnapshot,
377+
) error {
378+
vgsc, err := nvgs.groupclient.VolumeGroupSnapshotContents().Get(
379+
context.TODO(),
380+
*vgs.Status.BoundVolumeGroupSnapshotContentName,
381+
metav1.GetOptions{})
382+
if err != nil {
383+
return fmt.Errorf("failed to get VolumeGroupSnapshotContent: %w", err)
384+
}
385+
386+
sourcePVCCount := len(vgsc.Status.VolumeSnapshotInfoList)
387+
clonePVCCount := len(vgsc.Status.VolumeSnapshotInfoList)
388+
totalPVCCount := sourcePVCCount + clonePVCCount
389+
390+
validateOmapCount(nvgs.framework, totalPVCCount, rbdType, nvmeofPool, volumesType)
391+
392+
return nil
393+
}
394+
395+
func (nvgs *nvmeofVolumeGroupSnapshot) ValidateResourcesForDelete() error {
396+
validateOmapCount(nvgs.framework, 0, rbdType, nvmeofPool, volumesType)
397+
validateOmapCount(nvgs.framework, 0, rbdType, nvmeofPool, snapsType)
398+
validateOmapCount(nvgs.framework, 0, rbdType, nvmeofPool, groupSnapsType)
399+
validateRBDImageCount(nvgs.framework, 0, nvmeofPool)
400+
401+
err := waitToRemoveImagesFromTrash(nvgs.framework, nvmeofPool, deployTimeout)
402+
if err != nil {
403+
return err
404+
}
405+
406+
return nil
407+
}

examples/nvmeof/groupsnapshot.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
apiVersion: groupsnapshot.storage.k8s.io/v1
3+
kind: VolumeGroupSnapshot
4+
metadata:
5+
name: new-groupsnapshot-demo-1
6+
spec:
7+
source:
8+
selector:
9+
matchLabels:
10+
# The PVCs will need to have this label for it to be
11+
# included in the VolumeGroupSnapshot
12+
group: test
13+
volumeGroupSnapshotClassName: csi-nvmeofplugin-groupsnapclass
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
apiVersion: groupsnapshot.storage.k8s.io/v1
3+
kind: VolumeGroupSnapshotClass
4+
metadata:
5+
name: csi-nvmeofplugin-groupsnapclass
6+
driver: nvmeof.csi.ceph.com
7+
parameters:
8+
# String representing a Ceph cluster to provision storage from.
9+
# Should be unique across all Ceph clusters in use for provisioning,
10+
# cannot be greater than 36 bytes in length, and should remain immutable for
11+
# the lifetime of the StorageClass in use
12+
clusterID: <cluster-id>
13+
# eg: pool: replicapool
14+
pool: <rbd-pool-name>
15+
# Group snapshot operations use the RBD backend credentials
16+
csi.storage.k8s.io/group-snapshotter-secret-name: csi-rbd-secret
17+
csi.storage.k8s.io/group-snapshotter-secret-namespace: default
18+
deletionPolicy: Delete

0 commit comments

Comments
 (0)