Skip to content

Commit

Permalink
E2E experiments
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathanrainer committed Oct 1, 2022
1 parent ed5aae4 commit 8126091
Showing 1 changed file with 37 additions and 39 deletions.
76 changes: 37 additions & 39 deletions test/e2e/e2e.go
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ var _ = ginkgo.Describe("[efs-csi] EFS CSI", func() {
testEncryptInTransit(f, &encryptInTransit)
})

createProvisionedDirectory := func(f *framework.Framework, basePath string, pvcName string) *v1.PersistentVolumeClaim {
createProvisionedDirectory := func(f *framework.Framework, basePath string, pvcName string) (*v1.PersistentVolumeClaim, *storagev1.StorageClass) {
immediateBinding := storagev1.VolumeBindingImmediate
sc := storageframework.GetStorageClass("efs.csi.aws.com", map[string]string{
"provisioningMode": "efs-dir",
Expand All @@ -384,9 +384,6 @@ var _ = ginkgo.Describe("[efs-csi] EFS CSI", func() {
"gid": "1000",
"basePath": basePath,
}, &immediateBinding, EfsDriverNamespace)
defer func() {
_ = f.ClientSet.StorageV1().StorageClasses().Delete(context.TODO(), sc.Name, metav1.DeleteOptions{})
}()
_, err := f.ClientSet.StorageV1().StorageClasses().Create(context.TODO(), sc, metav1.CreateOptions{})
framework.ExpectNoError(err, "creating dynamic provisioning storage class")
pvc := makeEFSPVC(f.Namespace.Name, pvcName, sc.Name)
Expand All @@ -396,12 +393,15 @@ var _ = ginkgo.Describe("[efs-csi] EFS CSI", func() {
framework.ExpectNoError(err, "waiting for pv to be provisioned and bound")
pvc, err = f.ClientSet.CoreV1().PersistentVolumeClaims(f.Namespace.Name).Get(context.TODO(), pvc.Name, metav1.GetOptions{})

return pvc
return pvc, sc
}

ginkgo.It("should create a directory with the correct permissions when in directory provisioning mode", func() {
basePath := "dynamic_provisioning"
dynamicPvc := createProvisionedDirectory(f, basePath, "directory-pvc-1")
dynamicPvc, sc := createProvisionedDirectory(f, basePath, "directory-pvc-1")
defer func() {
_ = f.ClientSet.StorageV1().StorageClasses().Delete(context.TODO(), sc.Name, metav1.DeleteOptions{})
}()

pvc, pv, err := createEFSPVCPV(f.ClientSet, f.Namespace.Name, "root-dir-pvc", "/", map[string]string{})
defer func() {
Expand All @@ -421,44 +421,42 @@ var _ = ginkgo.Describe("[efs-csi] EFS CSI", func() {
uid, _, err := e2evolume.PodExec(f, pod, "stat -c \"%u\" "+provisionedPath)
framework.ExpectNoError(err, "ran stat command in /mnt/volume1")
framework.ExpectEqual(uid, fmt.Sprintf("%d", 1000), "Checking UID of mounted folder")
gid, _, err := e2evolume.PodExec(f, pod, "stat -c \"%g\" "+provisionedPath)
framework.ExpectNoError(err, "ran stat command in /mnt/volume1")
framework.ExpectEqual(gid, fmt.Sprintf("%d", 1000), "Checking GID of mounted folder")
_ = f.ClientSet.CoreV1().Pods(f.Namespace.Name).Delete(context.TODO(), pod.Name, metav1.DeleteOptions{})
err = e2epod.WaitForPodToDisappear(f.ClientSet, f.Namespace.Name, pod.Name, labels.Everything(), time.Second*5, time.Second*60)
framework.ExpectNoError(err, "Cleaning up no longer required pod")
})

ginkgo.It("should delete a directory provisioned in directory provisioning mode", func() {
basePath := "dynamic_provisioning"
pvc := createProvisionedDirectory(f, basePath, "directory-pvc-2")
volumeName := pvc.Spec.VolumeName

err := f.ClientSet.CoreV1().PersistentVolumeClaims(f.Namespace.Name).Delete(context.TODO(), pvc.Name,
metav1.DeleteOptions{})
framework.ExpectNoError(err, "deleting pvc")

pvc, pv, err := createEFSPVCPV(f.ClientSet, f.Namespace.Name, "root-dir-pvc", "/", map[string]string{})
defer func() {
_ = f.ClientSet.CoreV1().PersistentVolumeClaims(f.Namespace.Name).Delete(context.TODO(), pvc.Name, metav1.DeleteOptions{})
_ = f.ClientSet.CoreV1().PersistentVolumes().Delete(context.TODO(), pv.Name, metav1.DeleteOptions{})
}()
framework.ExpectNoError(err, "creating root mounted pv, pvc to check")

podSpec := e2epod.MakePod(f.Namespace.Name, nil, []*v1.PersistentVolumeClaim{pvc}, false, "")
podSpec.Spec.RestartPolicy = v1.RestartPolicyNever
pod, err := f.ClientSet.CoreV1().Pods(f.Namespace.Name).Create(context.TODO(), podSpec, metav1.CreateOptions{})
framework.ExpectNoError(err, "creating pod")
err = e2epod.WaitForPodRunningInNamespace(f.ClientSet, pod)
framework.ExpectNoError(err, "pod started running successfully")

e2evolume.VerifyExecInPodFail(f, pod, "test -f "+"/mnt/volume1/"+basePath+"/"+volumeName, 1)

_ = f.ClientSet.CoreV1().Pods(f.Namespace.Name).Delete(context.TODO(), pod.Name, metav1.DeleteOptions{})
err = e2epod.WaitForPodToDisappear(f.ClientSet, f.Namespace.Name, pod.Name, labels.Everything(), time.Second*5, time.Second*60)
framework.ExpectNoError(err, "Cleaning up no longer required pod")

})

//ginkgo.It("should delete a directory provisioned in directory provisioning mode", func() {
// basePath := "dynamic_provisioning"
// pvc := createProvisionedDirectory(f, basePath, "directory-pvc-2")
// volumeName := pvc.Spec.VolumeName
//
// err := f.ClientSet.CoreV1().PersistentVolumeClaims(f.Namespace.Name).Delete(context.TODO(), pvc.Name,
// metav1.DeleteOptions{})
// framework.ExpectNoError(err, "deleting pvc")
//
// pvc, pv, err := createEFSPVCPV(f.ClientSet, f.Namespace.Name, "root-dir-pvc", "/", map[string]string{})
// defer func() {
// _ = f.ClientSet.CoreV1().PersistentVolumeClaims(f.Namespace.Name).Delete(context.TODO(), pvc.Name, metav1.DeleteOptions{})
// _ = f.ClientSet.CoreV1().PersistentVolumes().Delete(context.TODO(), pv.Name, metav1.DeleteOptions{})
// }()
// framework.ExpectNoError(err, "creating root mounted pv, pvc to check")
//
// podSpec := e2epod.MakePod(f.Namespace.Name, nil, []*v1.PersistentVolumeClaim{pvc}, false, "")
// podSpec.Spec.RestartPolicy = v1.RestartPolicyNever
// pod, err := f.ClientSet.CoreV1().Pods(f.Namespace.Name).Create(context.TODO(), podSpec, metav1.CreateOptions{})
// framework.ExpectNoError(err, "creating pod")
// err = e2epod.WaitForPodRunningInNamespace(f.ClientSet, pod)
// framework.ExpectNoError(err, "pod started running successfully")
//
// e2evolume.VerifyExecInPodFail(f, pod, "test -f "+"/mnt/volume1/"+basePath+"/"+volumeName, 1)
//
// _ = f.ClientSet.CoreV1().Pods(f.Namespace.Name).Delete(context.TODO(), pod.Name, metav1.DeleteOptions{})
// err = e2epod.WaitForPodToDisappear(f.ClientSet, f.Namespace.Name, pod.Name, labels.Everything(), time.Second*5, time.Second*60)
// framework.ExpectNoError(err, "Cleaning up no longer required pod")
//
//})
})
})

Expand Down

0 comments on commit 8126091

Please sign in to comment.