From 6a77140cb051af161cc2fa050df339dadc684119 Mon Sep 17 00:00:00 2001 From: Zhecheng Li Date: Tue, 19 Mar 2024 03:25:58 +0000 Subject: [PATCH] [e2e] Update traffic distribution test Skip traffic distribution test if cluster has < 3 zones. Signed-off-by: Zhecheng Li --- test/e2e/framework/skipper/skipper.go | 11 +++++++++++ test/e2e/network/traffic_distribution.go | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/test/e2e/framework/skipper/skipper.go b/test/e2e/framework/skipper/skipper.go index 4a509b90a57..70f6075d424 100644 --- a/test/e2e/framework/skipper/skipper.go +++ b/test/e2e/framework/skipper/skipper.go @@ -121,6 +121,17 @@ func SkipUnlessMultizone(ctx context.Context, c clientset.Interface) { } } +// SkipUnlessAtLeastNZones skips if the cluster does not have n multizones. +func SkipUnlessAtLeastNZones(ctx context.Context, c clientset.Interface, n int) { + zones, err := e2enode.GetClusterZones(ctx, c) + if err != nil { + skipInternalf(1, "Error listing cluster zones") + } + if zones.Len() < n { + skipInternalf(1, "Requires >= %d zones", n) + } +} + // SkipIfMultizone skips if the cluster has multizone. func SkipIfMultizone(ctx context.Context, c clientset.Interface) { zones, err := e2enode.GetClusterZones(ctx, c) diff --git a/test/e2e/network/traffic_distribution.go b/test/e2e/network/traffic_distribution.go index 59ed3bbffcd..6dd6e5de974 100644 --- a/test/e2e/network/traffic_distribution.go +++ b/test/e2e/network/traffic_distribution.go @@ -49,7 +49,7 @@ var _ = common.SIGDescribe("TrafficDistribution", func() { ginkgo.BeforeEach(func(ctx context.Context) { c = f.ClientSet - e2eskipper.SkipUnlessMultizone(ctx, c) + e2eskipper.SkipUnlessAtLeastNZones(ctx, c, 3) }) ////////////////////////////////////////////////////////////////////////////