From 2fa840e3306f9cdc42948a9d06375e8a1fa4747f Mon Sep 17 00:00:00 2001 From: Ken'ichi Ohmichi Date: Thu, 16 Aug 2018 23:20:56 +0000 Subject: [PATCH] Wait for Available in PV protection test Just after creating a PV, its phase is "Pending" and its finalizers doesn't contain "kubernetes.io/pv-protection". If the e2e test performs so faster than the target k8s cluster, the test fails because the PV is not ready. This adds WaitForPersistentVolumePhase() for waiting the phase "Available" to avoid such situation. --- test/e2e/storage/pv_protection.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test/e2e/storage/pv_protection.go b/test/e2e/storage/pv_protection.go index 363e212fb52..44865d1d026 100644 --- a/test/e2e/storage/pv_protection.go +++ b/test/e2e/storage/pv_protection.go @@ -17,6 +17,8 @@ limitations under the License. package storage import ( + "time" + . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" @@ -77,6 +79,9 @@ var _ = utils.SIGDescribe("PV Protection", func() { pv, err = client.CoreV1().PersistentVolumes().Create(pv) Expect(err).NotTo(HaveOccurred(), "Error creating PV") + By("Waiting for PV to enter phase Available") + framework.ExpectNoError(framework.WaitForPersistentVolumePhase(v1.VolumeAvailable, client, pv.Name, 1*time.Second, 30*time.Second)) + By("Checking that PV Protection finalizer is set") pv, err = client.CoreV1().PersistentVolumes().Get(pv.Name, metav1.GetOptions{}) Expect(err).NotTo(HaveOccurred(), "While getting PV status")