From c8dab57cf30cf9034b7de336646be7c6182b8dcc Mon Sep 17 00:00:00 2001 From: Christian Schlotter Date: Fri, 7 Jul 2023 10:25:56 +0200 Subject: [PATCH] test/e2e: add check at anti-affinity test to ensure enough hosts exist --- test/e2e/anti_affinity_test.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/test/e2e/anti_affinity_test.go b/test/e2e/anti_affinity_test.go index ebcca98f3c..b5fe70df2e 100644 --- a/test/e2e/anti_affinity_test.go +++ b/test/e2e/anti_affinity_test.go @@ -59,9 +59,9 @@ var _ = Describe("Cluster creation with anti affined nodes", func() { }) It("should create a cluster with anti-affined nodes", func() { - // Since the upstream CI has five nodes, worker node count is set to 5 + // Since the upstream CI has four nodes, worker node count is set to 4. VerifyAntiAffinity(ctx, AntiAffinitySpecInput{ - WorkerNodeCount: 5, + WorkerNodeCount: 4, Namespace: namespace, InfraClients: InfraClients{ Client: vsphereClient, @@ -88,7 +88,12 @@ func VerifyAntiAffinity(ctx context.Context, input AntiAffinitySpecInput) { clusterName := fmt.Sprintf("anti-affinity-%s", util.RandomString(6)) Expect(namespace).NotTo(BeNil()) - Byf("creating a workload cluster with") + By("checking if the target system has enough hosts") + hostSystems, err := input.Finder.HostSystemList(ctx, "*") + Expect(err).ToNot(HaveOccurred()) + Expect(len(hostSystems) >= int(input.WorkerNodeCount)).To(BeTrue(), "This test requires more or equal number of hosts compared to the WorkerNodeCount. Expected at least %d but only got %d hosts.", input.WorkerNodeCount, len(hostSystems)) + + Byf("creating a workload cluster %s", clusterName) configCluster := defaultConfigCluster(clusterName, namespace.Name, "", 1, input.WorkerNodeCount, input.Global)