Skip to content

Commit

Permalink
Adding defers to remove PVCs and PVs once finished with
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathanrainer committed Jul 15, 2022
1 parent be57dd5 commit 745af0d
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions test/e2e/e2e.go
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,11 @@ var _ = ginkgo.Describe("[efs-csi] EFS CSI", func() {
basePath := "dynamic_provisioning"
dynamicPvc := createProvisionedDirectory(f, basePath)

pvc, _, err := createEFSPVCPV(f.ClientSet, f.Namespace.Name, "root-dir-pvc", "/", map[string]string{})
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, "")
Expand Down Expand Up @@ -431,7 +435,11 @@ var _ = ginkgo.Describe("[efs-csi] EFS CSI", func() {
metav1.DeleteOptions{})
framework.ExpectNoError(err, "deleting pvc")

pvc, _, err = createEFSPVCPV(f.ClientSet, f.Namespace.Name, "root-dir-pvc", "/", map[string]string{})
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, "")
Expand Down

0 comments on commit 745af0d

Please sign in to comment.