Skip to content

Commit 89eea38

Browse files
committed
Skipping affinity tests if fewer than three hosts.
1 parent a42f390 commit 89eea38

File tree

1 file changed

+11
-13
lines changed

1 file changed

+11
-13
lines changed

test/e2e/affinity_group.go

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,14 @@ func AffinityGroupSpec(ctx context.Context, inputGetter func() CommonSpecInput)
4545
BeforeEach(func() {
4646
Expect(ctx).NotTo(BeNil(), "ctx is required for %s spec", specName)
4747
input = inputGetter()
48+
49+
csClient := CreateCloudStackClient(ctx, input.BootstrapClusterProxy.GetKubeconfigPath())
50+
zoneName := input.E2EConfig.GetVariable("CLOUDSTACK_ZONE_NAME")
51+
numHosts := GetHostCount(csClient, zoneName)
52+
if numHosts < 3 {
53+
Skip("Too few ACS hosts to run conclusive affinity tests. Please provision at least three for the zone.")
54+
}
55+
4856
Expect(input.E2EConfig).ToNot(BeNil(), "Invalid argument. input.E2EConfig can't be nil when calling %s spec", specName)
4957
Expect(input.ClusterctlConfigPath).To(BeAnExistingFile(), "Invalid argument. input.ClusterctlConfigPath must be an existing file when calling %s spec", specName)
5058
Expect(input.BootstrapClusterProxy).ToNot(BeNil(), "Invalid argument. input.BootstrapClusterProxy can't be nil when calling %s spec", specName)
@@ -79,17 +87,6 @@ func AffinityGroupSpec(ctx context.Context, inputGetter func() CommonSpecInput)
7987
}
8088

8189
func executeTest(ctx context.Context, input CommonSpecInput, namespace *corev1.Namespace, specName string, clusterResources *clusterctl.ApplyClusterTemplateAndWaitResult, affinityType string) []string {
82-
csClient := CreateCloudStackClient(ctx, input.BootstrapClusterProxy.GetKubeconfigPath())
83-
zoneName := input.E2EConfig.GetVariable("CLOUDSTACK_ZONE_NAME")
84-
numHosts := GetHostCount(csClient, zoneName)
85-
machineCount := int64(3) // Must allocate an odd number of CP machines w/ stacked etcd
86-
if numHosts < 3 {
87-
// If not enough ACS hosts to support 3 machines with anti-affinity, fall back to just allocating one machine.
88-
// Test will only confirm that the single VM is in an anti-affinity group, but not that ACS anti-affinty works.
89-
By("Fewer than three host in ACS env. Only verifying that a single VM gets placed in an AG, not that true affinity/anti-affinity is ultimately achieved.")
90-
machineCount = int64(1)
91-
}
92-
9390
clusterctl.ApplyClusterTemplateAndWait(ctx, clusterctl.ApplyClusterTemplateAndWaitInput{
9491
ClusterProxy: input.BootstrapClusterProxy,
9592
CNIManifestPath: input.E2EConfig.GetVariable(CNIPath),
@@ -102,13 +99,14 @@ func executeTest(ctx context.Context, input CommonSpecInput, namespace *corev1.N
10299
Namespace: namespace.Name,
103100
ClusterName: fmt.Sprintf("%s-%s", specName, util.RandomString(6)),
104101
KubernetesVersion: input.E2EConfig.GetVariable(KubernetesVersion),
105-
ControlPlaneMachineCount: pointer.Int64Ptr(machineCount),
106-
WorkerMachineCount: pointer.Int64Ptr(machineCount),
102+
ControlPlaneMachineCount: pointer.Int64Ptr(3),
103+
WorkerMachineCount: pointer.Int64Ptr(2),
107104
},
108105
WaitForClusterIntervals: input.E2EConfig.GetIntervals(specName, "wait-cluster"),
109106
WaitForControlPlaneIntervals: input.E2EConfig.GetIntervals(specName, "wait-control-plane"),
110107
WaitForMachineDeployments: input.E2EConfig.GetIntervals(specName, "wait-worker-nodes"),
111108
}, clusterResources)
112109

110+
csClient := CreateCloudStackClient(ctx, input.BootstrapClusterProxy.GetKubeconfigPath())
113111
return CheckAffinityGroup(csClient, clusterResources.Cluster.Name, affinityType)
114112
}

0 commit comments

Comments
 (0)