diff --git a/e2e/validation.go b/e2e/validation.go index e0a2bd609..1ef736eb9 100644 --- a/e2e/validation.go +++ b/e2e/validation.go @@ -4,6 +4,7 @@ import ( "context" "time" + snapapi "github.com/kubernetes-csi/external-snapshotter/client/v4/apis/volumesnapshot/v1" . "github.com/onsi/gomega" lvmv1alpha1 "github.com/red-hat-storage/lvm-operator/api/v1alpha1" appsv1 "k8s.io/api/apps/v1" @@ -16,6 +17,7 @@ const ( interval = time.Second * 30 lvmVolumeGroupName = "vg1" storageClassName = "odf-lvm-vg1" + volumeSnapshotClassName = "odf-lvm-vg1" csiDriverName = "topolvm.cybozu.com" topolvmNodeDaemonSetName = "topolvm-node" topolvmCtrlDeploymentName = "topolvm-controller" @@ -48,6 +50,19 @@ func ValidateStorageClass() error { return nil } +// function to validate volume snapshot class. +func ValidateVolumeSnapshotClass() error { + vsc := snapapi.VolumeSnapshotClass{} + + Eventually(func() bool { + err := DeployManagerObj.GetCrClient().Get(context.TODO(), types.NamespacedName{Name: volumeSnapshotClassName}, &vsc) + return err == nil + }, timeout, interval).Should(BeTrue()) + + debug("VolumeSnapshotClass found\n") + return nil +} + // function to validate CSI Driver. func ValidateCSIDriver() error { cd := storagev1.CSIDriver{} @@ -141,10 +156,18 @@ func ValidateResources() error { if err != nil { return err } + // Validate Storage class err = ValidateStorageClass() if err != nil { return err } + + // Validate volume snapshot class + err = ValidateVolumeSnapshotClass() + if err != nil { + return err + } + return nil }