From 6afcaccf7d4ec46ba5abe80fb9d9c3680da54d88 Mon Sep 17 00:00:00 2001 From: Masaki Kimura Date: Wed, 24 Oct 2018 19:21:28 +0000 Subject: [PATCH] Move the provisioning test for retain policy back to volume_provisioning.go Provisioning test for retain policy requires each driver's backend volume deletion logic. Without it, volume leakage happens. Move this test back to volume_provisioning.go and test it only for gce, until general backend volume deletion code for each driver becomes available. Fixes: #70191 --- test/e2e/storage/testsuites/provisioning.go | 13 -------- test/e2e/storage/volume_provisioning.go | 34 +++++++++++++++++++++ 2 files changed, 34 insertions(+), 13 deletions(-) diff --git a/test/e2e/storage/testsuites/provisioning.go b/test/e2e/storage/testsuites/provisioning.go index 2047b4d846a..72b9d7c3f77 100644 --- a/test/e2e/storage/testsuites/provisioning.go +++ b/test/e2e/storage/testsuites/provisioning.go @@ -185,19 +185,6 @@ func testProvisioning(input *provisioningTestInput) { TestDynamicProvisioning(input.testCase, input.cs, input.pvc, input.sc) }) - It("should provision storage with non-default reclaim policy Retain", func() { - retain := v1.PersistentVolumeReclaimRetain - input.sc.ReclaimPolicy = &retain - pv := TestDynamicProvisioning(input.testCase, input.cs, input.pvc, input.sc) - - By(fmt.Sprintf("waiting for the provisioned PV %q to enter phase %s", pv.Name, v1.VolumeReleased)) - framework.ExpectNoError(framework.WaitForPersistentVolumePhase(v1.VolumeReleased, input.cs, pv.Name, 1*time.Second, 30*time.Second)) - - By(fmt.Sprintf("deleting the PV %q", pv.Name)) - framework.ExpectNoError(framework.DeletePersistentVolume(input.cs, pv.Name), "Failed to delete PV ", pv.Name) - framework.ExpectNoError(framework.WaitForPersistentVolumeDeleted(input.cs, pv.Name, 1*time.Second, 30*time.Second)) - }) - It("should create and delete block persistent volumes [Feature:BlockVolume]", func() { if !input.dInfo.IsBlockSupported { framework.Skipf("Driver %q does not support BlockVolume - skipping", input.dInfo.Name) diff --git a/test/e2e/storage/volume_provisioning.go b/test/e2e/storage/volume_provisioning.go index 53079e5ea7f..cde6712dc5c 100644 --- a/test/e2e/storage/volume_provisioning.go +++ b/test/e2e/storage/volume_provisioning.go @@ -427,6 +427,40 @@ var _ = utils.SIGDescribe("Dynamic Provisioning", func() { } }) + It("should provision storage with non-default reclaim policy Retain", func() { + framework.SkipUnlessProviderIs("gce", "gke") + + test := testsuites.StorageClassTest{ + Name: "HDD PD on GCE/GKE", + CloudProviders: []string{"gce", "gke"}, + Provisioner: "kubernetes.io/gce-pd", + Parameters: map[string]string{ + "type": "pd-standard", + }, + ClaimSize: "1Gi", + ExpectedSize: "1Gi", + PvCheck: func(volume *v1.PersistentVolume) error { + return checkGCEPD(volume, "pd-standard") + }, + } + class := newStorageClass(test, ns, "reclaimpolicy") + retain := v1.PersistentVolumeReclaimRetain + class.ReclaimPolicy = &retain + claim := newClaim(test, ns, "reclaimpolicy") + claim.Spec.StorageClassName = &class.Name + pv := testsuites.TestDynamicProvisioning(test, c, claim, class) + + By(fmt.Sprintf("waiting for the provisioned PV %q to enter phase %s", pv.Name, v1.VolumeReleased)) + framework.ExpectNoError(framework.WaitForPersistentVolumePhase(v1.VolumeReleased, c, pv.Name, 1*time.Second, 30*time.Second)) + + By(fmt.Sprintf("deleting the storage asset backing the PV %q", pv.Name)) + framework.ExpectNoError(framework.DeletePDWithRetry(pv.Spec.GCEPersistentDisk.PDName)) + + By(fmt.Sprintf("deleting the PV %q", pv.Name)) + framework.ExpectNoError(framework.DeletePersistentVolume(c, pv.Name), "Failed to delete PV ", pv.Name) + framework.ExpectNoError(framework.WaitForPersistentVolumeDeleted(c, pv.Name, 1*time.Second, 30*time.Second)) + }) + It("should not provision a volume in an unmanaged GCE zone.", func() { framework.SkipUnlessProviderIs("gce", "gke") var suffix string = "unmananged"