From 8d0936b74362b54dece6a660caa187b1a8ce4438 Mon Sep 17 00:00:00 2001 From: Dave Chen Date: Tue, 8 Jun 2021 13:47:58 +0800 Subject: [PATCH] Check empty zone after the validation of providers This make sure the testcase that cannot run locally will be skipped instead of throwing the misleading failure message. Signed-off-by: Dave Chen --- test/e2e/storage/volume_provisioning.go | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/test/e2e/storage/volume_provisioning.go b/test/e2e/storage/volume_provisioning.go index e5511139856..66b7ff1fe0e 100644 --- a/test/e2e/storage/volume_provisioning.go +++ b/test/e2e/storage/volume_provisioning.go @@ -351,6 +351,10 @@ var _ = utils.SIGDescribe("Dynamic Provisioning", func() { continue } + if zone, ok := test.Parameters["zone"]; ok { + framework.ExpectNotEqual(len(zone), 0, "expect at least one zone") + } + ginkgo.By("Testing " + test.Name) suffix := fmt.Sprintf("%d", i) test.Client = c @@ -1061,9 +1065,11 @@ func deleteProvisionedVolumesAndDisks(c clientset.Interface, pvs []*v1.Persisten func getRandomClusterZone(c clientset.Interface) string { zones, err := e2enode.GetClusterZones(c) + zone := "" framework.ExpectNoError(err) - framework.ExpectNotEqual(len(zones), 0) - - zonesList := zones.UnsortedList() - return zonesList[rand.Intn(zones.Len())] + if len(zones) != 0 { + zonesList := zones.UnsortedList() + zone = zonesList[rand.Intn(zones.Len())] + } + return zone }