mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-11-23 23:00:19 +00:00
e2e: add tests for RBD VolumeGroupSnapshots
Signed-off-by: Niels de Vos <ndevos@ibm.com>
This commit is contained in:
parent
f4f03044f2
commit
b59a701777
13
e2e/rbd.go
13
e2e/rbd.go
@ -4856,6 +4856,19 @@ var _ = Describe("RBD", func() {
|
||||
}
|
||||
})
|
||||
|
||||
By("test volumeGroupSnapshot", func() {
|
||||
scName := "csi-rbd-sc"
|
||||
snapshotter, err := newRBDVolumeGroupSnapshot(f, f.UniqueName, scName, false, deployTimeout, 3)
|
||||
if err != nil {
|
||||
framework.Failf("failed to create RBDVolumeGroupSnapshot: %v", err)
|
||||
}
|
||||
|
||||
err = snapshotter.TestVolumeGroupSnapshot()
|
||||
if err != nil {
|
||||
framework.Failf("failed to test volumeGroupSnapshot: %v", err)
|
||||
}
|
||||
})
|
||||
|
||||
// delete RBD provisioner secret
|
||||
err := deleteCephUser(f, keyringRBDProvisionerUsername)
|
||||
if err != nil {
|
||||
|
@ -117,3 +117,65 @@ func (c *cephFSVolumeGroupSnapshot) ValidateResourcesForDelete() error {
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
type rbdVolumeGroupSnapshot struct {
|
||||
*volumeGroupSnapshotterBase
|
||||
}
|
||||
|
||||
var _ VolumeGroupSnapshotter = &rbdVolumeGroupSnapshot{}
|
||||
|
||||
func newRBDVolumeGroupSnapshot(f *framework.Framework, namespace,
|
||||
storageClass string,
|
||||
blockPVC bool,
|
||||
timeout, totalPVCCount int,
|
||||
) (VolumeGroupSnapshotter, error) {
|
||||
base, err := newVolumeGroupSnapshotBase(f, namespace, storageClass, blockPVC, timeout, totalPVCCount)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to create volumeGroupSnapshotterBase: %w", err)
|
||||
}
|
||||
|
||||
return &rbdVolumeGroupSnapshot{
|
||||
volumeGroupSnapshotterBase: base,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (rvgs *rbdVolumeGroupSnapshot) TestVolumeGroupSnapshot() error {
|
||||
return rvgs.volumeGroupSnapshotterBase.testVolumeGroupSnapshot(rvgs)
|
||||
}
|
||||
|
||||
func (rvgs *rbdVolumeGroupSnapshot) GetVolumeGroupSnapshotClass() (*groupsnapapi.VolumeGroupSnapshotClass, error) {
|
||||
vgscPath := fmt.Sprintf("%s/%s", rbdExamplePath, "groupsnapshotclass.yaml")
|
||||
vgsc := &groupsnapapi.VolumeGroupSnapshotClass{}
|
||||
err := unmarshal(vgscPath, vgsc)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to unmarshal VolumeGroupSnapshotClass: %w", err)
|
||||
}
|
||||
|
||||
vgsc.Parameters["csi.storage.k8s.io/group-snapshotter-secret-namespace"] = cephCSINamespace
|
||||
vgsc.Parameters["csi.storage.k8s.io/group-snapshotter-secret-name"] = rbdProvisionerSecretName
|
||||
vgsc.Parameters["pool"] = defaultRBDPool
|
||||
|
||||
fsID, err := getClusterID(rvgs.framework)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to get clusterID: %w", err)
|
||||
}
|
||||
vgsc.Parameters["clusterID"] = fsID
|
||||
|
||||
return vgsc, nil
|
||||
}
|
||||
|
||||
func (rvgs *rbdVolumeGroupSnapshot) ValidateResourcesForCreate(vgs *groupsnapapi.VolumeGroupSnapshot) error {
|
||||
sourcePVCCount := len(vgs.Status.PVCVolumeSnapshotRefList)
|
||||
clonePVCCount := len(vgs.Status.PVCVolumeSnapshotRefList)
|
||||
totalPVCCount := sourcePVCCount + clonePVCCount
|
||||
|
||||
validateOmapCount(rvgs.framework, totalPVCCount, rbdType, defaultRBDPool, volumesType)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (rvgs *rbdVolumeGroupSnapshot) ValidateResourcesForDelete() error {
|
||||
validateOmapCount(rvgs.framework, 0, rbdType, defaultRBDPool, volumesType)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user