-
Notifications
You must be signed in to change notification settings - Fork 551
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
e2e: add tests for RBD VolumeGroupSnapshots #4899
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. good to have comment for function description, maybe describe the validation criteria. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Comments are provided in the interface at |
||
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 | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function creates volumegroupsnapshot but the function name is not self-explanatory, so I think it will be good to have a comment here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe, but it follows the same naming as CephFS.