diff --git a/test/e2e/framework/util.go b/test/e2e/framework/util.go index ba871e48006..3a4c00de5eb 100644 --- a/test/e2e/framework/util.go +++ b/test/e2e/framework/util.go @@ -2039,6 +2039,11 @@ func RandomSuffix() string { return strconv.Itoa(r.Int() % 10000) } +// ExpectError expects an error happens, otherwise an exception raises +func ExpectError(err error, explain ...interface{}) { + gomega.Expect(err).To(gomega.HaveOccurred(), explain...) +} + // ExpectNoError checks if "err" is set, and if so, fails assertion while logging the error. func ExpectNoError(err error, explain ...interface{}) { ExpectNoErrorWithOffset(1, err, explain...) diff --git a/test/e2e/storage/testsuites/provisioning.go b/test/e2e/storage/testsuites/provisioning.go index 8e83ea5ea89..160ac444f9f 100644 --- a/test/e2e/storage/testsuites/provisioning.go +++ b/test/e2e/storage/testsuites/provisioning.go @@ -483,7 +483,7 @@ func (t StorageClassTest) TestBindingWaitForFirstConsumerMultiPVC(claims []*v1.P // Wait for ClaimProvisionTimeout (across all PVCs in parallel) and make sure the phase did not become Bound i.e. the Wait errors out By("checking the claims are in pending state") err = framework.WaitForPersistentVolumeClaimsPhase(v1.ClaimBound, t.Client, namespace, claimNames, 2*time.Second /* Poll */, framework.ClaimProvisionShortTimeout, true) - Expect(err).To(HaveOccurred()) + framework.ExpectError(err) verifyPVCsPending(t.Client, createdClaims) By("creating a pod referring to the claims")