Skip to content

Commit

Permalink
e2e: test vgs beta api
Browse files Browse the repository at this point in the history
testing vgs beta api

Signed-off-by: Madhu Rajanna <[email protected]>
  • Loading branch information
Madhu-1 committed Nov 28, 2024
1 parent dd1c302 commit c63b4cd
Show file tree
Hide file tree
Showing 33 changed files with 1,545 additions and 297 deletions.
12 changes: 4 additions & 8 deletions deploy/cephfs/kubernetes/csi-cephfsplugin-provisioner.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -145,14 +145,14 @@ spec:
- name: socket-dir
mountPath: /csi
- name: csi-snapshotter
image: registry.k8s.io/sig-storage/csi-snapshotter:v8.0.1
image: quay.io/madhupr001/csi-snapshotter:latest
args:
- "--csi-address=$(ADDRESS)"
- "--v=1"
- "--timeout=150s"
- "--leader-election=true"
- "--extra-create-metadata=true"
- "--enable-volume-group-snapshots=true"
- "--feature-gates=CSIVolumeGroupSnapshot=true"
- "--http-endpoint=$(POD_IP):8092"
env:
- name: ADDRESS
Expand Down Expand Up @@ -195,9 +195,7 @@ spec:
imagePullPolicy: "IfNotPresent"
volumes:
- name: socket-dir
emptyDir: {
medium: "Memory"
}
emptyDir: { medium: "Memory" }
- name: host-sys
hostPath:
path: /sys
Expand All @@ -214,9 +212,7 @@ spec:
configMap:
name: ceph-csi-config
- name: keys-tmp-dir
emptyDir: {
medium: "Memory"
}
emptyDir: { medium: "Memory" }
- name: ceph-csi-encryption-kms-config
configMap:
name: ceph-csi-encryption-kms-config
12 changes: 4 additions & 8 deletions deploy/rbd/kubernetes/csi-rbdplugin-provisioner.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -134,14 +134,14 @@ spec:
- name: socket-dir
mountPath: /csi
- name: csi-snapshotter
image: registry.k8s.io/sig-storage/csi-snapshotter:v8.0.1
image: quay.io/madhupr001/csi-snapshotter:latest
args:
- "--csi-address=$(ADDRESS)"
- "--v=1"
- "--timeout=150s"
- "--leader-election=true"
- "--extra-create-metadata=true"
- "--enable-volume-group-snapshots=true"
- "--feature-gates=CSIVolumeGroupSnapshot=true"
- "--http-endpoint=$(POD_IP):8092"
env:
- name: ADDRESS
Expand Down Expand Up @@ -265,9 +265,7 @@ spec:
hostPath:
path: /lib/modules
- name: socket-dir
emptyDir: {
medium: "Memory"
}
emptyDir: { medium: "Memory" }
- name: ceph-config
configMap:
name: ceph-config
Expand All @@ -278,9 +276,7 @@ spec:
configMap:
name: ceph-csi-encryption-kms-config
- name: keys-tmp-dir
emptyDir: {
medium: "Memory"
}
emptyDir: { medium: "Memory" }
- name: oidc-token
projected:
sources:
Expand Down
57 changes: 44 additions & 13 deletions e2e/cephfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,50 @@ var _ = Describe(cephfsType, func() {
}
})

By("test volumeGroupSnapshot", func() {
err := createCephfsStorageClass(f.ClientSet, f, true, nil)
if err != nil {
framework.Failf("failed to create CephFS storageclass: %v", err)
}
scName := "csi-cephfs-sc"
snapshotter, err := newCephFSVolumeGroupSnapshot(f, f.UniqueName, scName, false, deployTimeout, 10)
if err != nil {
framework.Failf("failed to create volumeGroupSnapshot Base: %v", err)
}

snapTestErr := snapshotter.TestVolumeGroupSnapshot()
err = retryKubectlInput(f.UniqueName, kubectlGet, "volumegroupsnapshot", deployTimeout, "-oyaml")
if err != nil {
framework.Logf("failed to get volumegroupsnapshot: %v", err)
}

err = retryKubectlInput(f.UniqueName, kubectlGet, "volumegroupsnapshotcontent", deployTimeout, "-oyaml")
if err != nil {
framework.Logf("failed to get volumegroupsnapshot: %v", err)
}

err = retryKubectlInput(f.UniqueName, kubectlGet, "volumesnapshot", deployTimeout, "-oyaml")
if err != nil {
framework.Logf("failed to get volumesnapshot: %v", err)
}

err = retryKubectlInput(f.UniqueName, kubectlGet, "volumesnapshotcontent", deployTimeout, "-oyaml")
if err != nil {
framework.Logf("failed to get volumesnapshotcontent: %v", err)
}

if snapTestErr != nil {
framework.Failf("failed to test volumeGroupSnapshot: %v", snapTestErr)
}
err = deleteResource(cephFSExamplePath + "storageclass.yaml")
if err != nil {
framework.Failf("failed to delete CephFS storageclass: %v", err)
}

framework.Logf("[Debug] volumeGroupSnapshot test passed")
return
})

By("validate fuseMountOptions", func() {
params := map[string]string{
"mounter": "fuse",
Expand Down Expand Up @@ -2478,19 +2522,6 @@ var _ = Describe(cephfsType, func() {
}
})

By("test volumeGroupSnapshot", func() {
scName := "csi-cephfs-sc"
snapshotter, err := newCephFSVolumeGroupSnapshot(f, f.UniqueName, scName, false, deployTimeout, 3)
if err != nil {
framework.Failf("failed to create volumeGroupSnapshot Base: %v", err)
}

err = snapshotter.TestVolumeGroupSnapshot()
if err != nil {
framework.Failf("failed to test volumeGroupSnapshot: %v", err)
}
})

By("verify rados objects are within a namespace", func() {
updateRadosNamespace := func(radosNamespaceName string) {
framework.Logf("updating configmap with rados namespace %s", radosNamespace)
Expand Down
8 changes: 5 additions & 3 deletions e2e/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func init() {
flag.BoolVar(&deployNFS, "deploy-nfs", false, "deploy nfs csi driver")
flag.BoolVar(&testCephFS, "test-cephfs", true, "test cephFS csi driver")
flag.BoolVar(&testCephFSFscrypt, "test-cephfs-fscrypt", false, "test CephFS csi driver fscrypt support")
flag.BoolVar(&testRBD, "test-rbd", true, "test rbd csi driver")
flag.BoolVar(&testRBD, "test-rbd", false, "test rbd csi driver")
flag.BoolVar(&testRBDFSCrypt, "test-rbd-fscrypt", false, "test rbd csi driver fscrypt support")
flag.BoolVar(&testNBD, "test-nbd", false, "test rbd csi driver with rbd-nbd mounter")
flag.BoolVar(&testNFS, "test-nfs", false, "test nfs csi driver")
Expand All @@ -59,6 +59,8 @@ func init() {
framework.AfterReadingAllFlags(&framework.TestContext)

fmt.Println("timeout for deploytimeout ", deployTimeout)
testRBD = false
testNFS = false
}

func setDefaultKubeconfig() {
Expand Down Expand Up @@ -88,7 +90,7 @@ func handleFlags() {
// variable, it is still possible to only run the NFS tests, when both
// CephFS and RBD are disabled.
if testCephFS {
testNFS = testCephFS
deployNFS = deployCephFS
//testNFS = testCephFS
//deployNFS = deployCephFS
}
}
7 changes: 5 additions & 2 deletions e2e/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -1614,6 +1614,9 @@ const (
kubectlCreate = kubectlAction("create")
// kubectlDelete tells retryKubectlInput() to run "delete".
kubectlDelete = kubectlAction("delete")

//kubectlGet tells retryKubectlInput() to run "get".
kubectlGet = kubectlAction("get")
)

// String returns the string format of the kubectlAction, this is automatically
Expand All @@ -1637,7 +1640,7 @@ func retryKubectlInput(namespace string, action kubectlAction, data string, t in
}
cmd = append(cmd, []string{string(action), "-f", "-"}...)

_, err := e2ekubectl.RunKubectlInput(namespace, data, cmd...)
output, err := e2ekubectl.RunKubectlInput(namespace, data, cmd...)
if err != nil {
if isRetryableAPIError(err) {
return false, nil
Expand All @@ -1656,7 +1659,7 @@ func retryKubectlInput(namespace string, action kubectlAction, data string, t in

return false, fmt.Errorf("failed to run kubectl: %w", err)
}

framework.Logf("kubectl output: %s\n", output)
return true, nil
})
}
Expand Down
35 changes: 27 additions & 8 deletions e2e/volumegroupsnapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@ package e2e

import (
"context"
"crypto/sha256"
"fmt"

groupsnapapi "github.com/kubernetes-csi/external-snapshotter/client/v8/apis/volumegroupsnapshot/v1alpha1"
groupsnapapi "github.com/kubernetes-csi/external-snapshotter/client/v8/apis/volumegroupsnapshot/v1beta1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/kubernetes/test/e2e/framework"
)
Expand Down Expand Up @@ -78,17 +79,29 @@ func (c *cephFSVolumeGroupSnapshot) ValidateResourcesForCreate(vgs *groupsnapapi
return fmt.Errorf("failed getting cephFS metadata pool name: %w", err)
}

sourcePVCCount := len(vgs.Status.PVCVolumeSnapshotRefList)
vgsc, err := c.groupclient.VolumeGroupSnapshotContents().Get(ctx, *vgs.Status.BoundVolumeGroupSnapshotContentName, metav1.GetOptions{})
if err != nil {
return fmt.Errorf("failed to get VolumeGroupSnapshotContent: %w", err)
}

sourcePVCCount := len(vgsc.Status.VolumeSnapshotHandlePairList)
// we are creating clones for each source PVC
clonePVCCount := len(vgs.Status.PVCVolumeSnapshotRefList)
clonePVCCount := len(vgsc.Status.VolumeSnapshotHandlePairList)
totalPVCCount := sourcePVCCount + clonePVCCount
validateSubvolumeCount(c.framework, totalPVCCount, fileSystemName, subvolumegroup)

// we are creating 1 snapshot for each source PVC, validate the snapshot count
for _, pvcSnap := range vgs.Status.PVCVolumeSnapshotRefList {
for _, snapshot := range vgsc.Status.VolumeSnapshotHandlePairList {
volumeHandle := snapshot.VolumeHandle
volumeSnapshotName := fmt.Sprintf("snapshot-%x", sha256.Sum256([]byte(
string(vgsc.UID)+volumeHandle)))
volumeSnapshot, err := c.snapClient.VolumeSnapshots(vgs.Namespace).Get(ctx, volumeSnapshotName, metav1.GetOptions{})
if err != nil {
return fmt.Errorf("failed to get VolumeSnapshot: %w", err)
}
pvcName := *volumeSnapshot.Spec.Source.PersistentVolumeClaimName
pvc, err := c.framework.ClientSet.CoreV1().PersistentVolumeClaims(vgs.Namespace).Get(ctx,
pvcSnap.PersistentVolumeClaimRef.Name,
metav1.GetOptions{})
pvcName, metav1.GetOptions{})
if err != nil {
return fmt.Errorf("failed to get PVC: %w", err)
}
Expand Down Expand Up @@ -165,8 +178,14 @@ func (rvgs *rbdVolumeGroupSnapshot) GetVolumeGroupSnapshotClass() (*groupsnapapi
}

func (rvgs *rbdVolumeGroupSnapshot) ValidateResourcesForCreate(vgs *groupsnapapi.VolumeGroupSnapshot) error {
sourcePVCCount := len(vgs.Status.PVCVolumeSnapshotRefList)
clonePVCCount := len(vgs.Status.PVCVolumeSnapshotRefList)

vgsc, err := rvgs.groupclient.VolumeGroupSnapshotContents().Get(context.TODO(), *vgs.Status.BoundVolumeGroupSnapshotContentName, metav1.GetOptions{})
if err != nil {
return fmt.Errorf("failed to get VolumeGroupSnapshotContent: %w", err)
}

sourcePVCCount := len(vgsc.Status.VolumeSnapshotHandlePairList)
clonePVCCount := len(vgsc.Status.VolumeSnapshotHandlePairList)
totalPVCCount := sourcePVCCount + clonePVCCount

validateOmapCount(rvgs.framework, totalPVCCount, rbdType, defaultRBDPool, volumesType)
Expand Down
Loading

0 comments on commit c63b4cd

Please sign in to comment.