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.
This commit is contained in:
Ken'ichi Ohmichi 2018-08-16 23:20:56 +00:00
parent 1da4c59e46
commit 2fa840e330

View File

@ -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")