Skip to content

Commit 887e3fe

Browse files
committed
Modified affinity test to dynamically select one or three VMs based on number of available hosts. Added alternate e2e config file for 10.11.0.2.
1 parent 734b333 commit 887e3fe

File tree

3 files changed

+205
-3
lines changed

3 files changed

+205
-3
lines changed

test/e2e/affinity_group.go

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,17 @@ func AffinityGroupSpec(ctx context.Context, inputGetter func() CommonSpecInput)
7979
}
8080

8181
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+
8293
clusterctl.ApplyClusterTemplateAndWait(ctx, clusterctl.ApplyClusterTemplateAndWaitInput{
8394
ClusterProxy: input.BootstrapClusterProxy,
8495
CNIManifestPath: input.E2EConfig.GetVariable(CNIPath),
@@ -91,14 +102,13 @@ func executeTest(ctx context.Context, input CommonSpecInput, namespace *corev1.N
91102
Namespace: namespace.Name,
92103
ClusterName: fmt.Sprintf("%s-%s", specName, util.RandomString(6)),
93104
KubernetesVersion: input.E2EConfig.GetVariable(KubernetesVersion),
94-
ControlPlaneMachineCount: pointer.Int64Ptr(1),
95-
WorkerMachineCount: pointer.Int64Ptr(1),
105+
ControlPlaneMachineCount: pointer.Int64Ptr(int64(machineCount)),
106+
WorkerMachineCount: pointer.Int64Ptr(machineCount),
96107
},
97108
WaitForClusterIntervals: input.E2EConfig.GetIntervals(specName, "wait-cluster"),
98109
WaitForControlPlaneIntervals: input.E2EConfig.GetIntervals(specName, "wait-control-plane"),
99110
WaitForMachineDeployments: input.E2EConfig.GetIntervals(specName, "wait-worker-nodes"),
100111
}, clusterResources)
101112

102-
csClient := CreateCloudStackClient(ctx, input.BootstrapClusterProxy.GetKubeconfigPath())
103113
return CheckAffinityGroup(csClient, clusterResources.Cluster.Name, affinityType)
104114
}

test/e2e/common.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,24 @@ func CheckAffinityGroupsDeleted(client *cloudstack.CloudStackClient, affinityIds
287287
return nil
288288
}
289289

290+
func GetHostCount(client *cloudstack.CloudStackClient, zoneName string) int {
291+
pz := client.Zone.NewListZonesParams()
292+
pz.SetName(zoneName)
293+
listZonesResponse, err := client.Zone.ListZones(pz)
294+
Expect(err).To(BeNil(), "error listing zones")
295+
Expect(listZonesResponse.Count).To(Equal(1), "multiple zones resolve to zone name %s", zoneName)
296+
zoneId := listZonesResponse.Zones[0].Id
297+
298+
ph := client.Host.NewListHostsParams()
299+
ph.SetZoneid(zoneId)
300+
ph.SetHypervisor("KVM")
301+
ph.SetResourcestate("Enabled")
302+
ph.SetState("Up")
303+
listHostsResponse, err := client.Host.ListHosts(ph)
304+
Expect(err).To(BeNil(), "error listing hosts")
305+
return listHostsResponse.Count
306+
}
307+
290308
func CheckAffinityGroup(client *cloudstack.CloudStackClient, clusterName string, affinityType string) []string {
291309
By("Listing all machines")
292310
p := client.VirtualMachine.NewListVirtualMachinesParams()
Lines changed: 174 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,174 @@
1+
---
2+
# E2E test scenario using local dev images and manifests built from the source tree for following providers:
3+
# - cluster-api
4+
# - bootstrap kubeadm
5+
# - control-plane kubeadm
6+
# - cloudstack
7+
8+
managementClusterName: capi-test
9+
10+
images:
11+
# Use local dev images built source tree;
12+
- name: localhost:5000/cluster-api-provider-cloudstack:latest
13+
loadBehavior: mustLoad
14+
15+
## PLEASE KEEP THESE UP TO DATE WITH THE COMPONENTS
16+
17+
# Cluster API v1beta1 Preloads
18+
- name: gcr.io/k8s-staging-cluster-api/cluster-api-controller-amd64:v1.0.0
19+
loadBehavior: tryLoad
20+
- name: gcr.io/k8s-staging-cluster-api/kubeadm-bootstrap-controller-amd64:v1.0.0
21+
loadBehavior: tryLoad
22+
- name: gcr.io/k8s-staging-cluster-api/kubeadm-control-plane-controller-amd64:v1.0.0
23+
loadBehavior: tryLoad
24+
- name: gcr.io/k8s-staging-cluster-api/capd-manager-amd64:v1.0.0
25+
loadBehavior: tryLoad
26+
- name: quay.io/jetstack/cert-manager-cainjector:v1.5.3
27+
loadBehavior: tryLoad
28+
- name: quay.io/jetstack/cert-manager-webhook:v1.5.3
29+
loadBehavior: tryLoad
30+
- name: quay.io/jetstack/cert-manager-controller:v1.5.3
31+
loadBehavior: tryLoad
32+
33+
providers:
34+
- name: cluster-api
35+
type: CoreProvider
36+
versions:
37+
- name: v1.0.0
38+
value: "https://github.com/kubernetes-sigs/cluster-api/releases/download/v1.0.0/core-components.yaml"
39+
type: "url"
40+
contract: v1beta1
41+
replacements:
42+
- old: --metrics-addr=127.0.0.1:8080
43+
new: --metrics-addr=:8080
44+
files:
45+
- sourcePath: "../data/shared/v1beta1/metadata.yaml"
46+
47+
- name: kubeadm
48+
type: BootstrapProvider
49+
versions:
50+
- name: v1.0.0
51+
value: "https://github.com/kubernetes-sigs/cluster-api/releases/download/v1.0.0/bootstrap-components.yaml"
52+
type: "url"
53+
contract: v1beta1
54+
replacements:
55+
- old: --metrics-addr=127.0.0.1:8080
56+
new: --metrics-addr=:8080
57+
files:
58+
- sourcePath: "../data/shared/v1beta1/metadata.yaml"
59+
60+
- name: kubeadm
61+
type: ControlPlaneProvider
62+
versions:
63+
- name: v1.0.0
64+
value: "https://github.com/kubernetes-sigs/cluster-api/releases/download/v1.0.0/control-plane-components.yaml"
65+
type: "url"
66+
contract: v1beta1
67+
replacements:
68+
- old: --metrics-addr=127.0.0.1:8080
69+
new: --metrics-addr=:8080
70+
files:
71+
- sourcePath: "../data/shared/v1beta1/metadata.yaml"
72+
73+
- name: cloudstack
74+
type: InfrastructureProvider
75+
files:
76+
- sourcePath: "../data/infrastructure-cloudstack/v1beta2/cluster-template.yaml"
77+
- sourcePath: "../data/infrastructure-cloudstack/v1beta2/cluster-template-invalid-zone.yaml"
78+
- sourcePath: "../data/infrastructure-cloudstack/v1beta2/cluster-template-invalid-account.yaml"
79+
- sourcePath: "../data/infrastructure-cloudstack/v1beta2/cluster-template-invalid-domain.yaml"
80+
- sourcePath: "../data/infrastructure-cloudstack/v1beta2/cluster-template-invalid-template.yaml"
81+
- sourcePath: "../data/infrastructure-cloudstack/v1beta2/cluster-template-invalid-cp-offering.yaml"
82+
- sourcePath: "../data/infrastructure-cloudstack/v1beta2/cluster-template-insufficient-compute-resources.yaml"
83+
- sourcePath: "../data/infrastructure-cloudstack/v1beta2/cluster-template-insufficient-compute-resources-for-upgrade.yaml"
84+
- sourcePath: "../data/infrastructure-cloudstack/v1beta2/cluster-template-node-drain.yaml"
85+
- sourcePath: "../data/infrastructure-cloudstack/v1beta2/cluster-template-machine-remediation.yaml"
86+
- sourcePath: "../data/infrastructure-cloudstack/v1beta2/cluster-template-affinity-group-pro.yaml"
87+
- sourcePath: "../data/infrastructure-cloudstack/v1beta2/cluster-template-affinity-group-anti.yaml"
88+
- sourcePath: "../data/infrastructure-cloudstack/v1beta2/cluster-template-resource-cleanup.yaml"
89+
- sourcePath: "../data/infrastructure-cloudstack/v1beta2/cluster-template-second-cluster.yaml"
90+
- sourcePath: "../data/infrastructure-cloudstack/v1beta2/cluster-template-shared-network-kubevip.yaml"
91+
- sourcePath: "../data/infrastructure-cloudstack/v1beta2/cluster-template-invalid-disk-offering.yaml"
92+
- sourcePath: "../data/infrastructure-cloudstack/v1beta2/cluster-template-invalid-disk-offering-size-for-non-customized.yaml"
93+
- sourcePath: "../data/infrastructure-cloudstack/v1beta2/cluster-template-invalid-disk-offering-size-for-customized.yaml"
94+
- sourcePath: "../data/infrastructure-cloudstack/v1beta2/cluster-template-disk-offering.yaml"
95+
- sourcePath: "../data/infrastructure-cloudstack/v1beta2/cluster-template-custom-disk-offering.yaml"
96+
- sourcePath: "../data/infrastructure-cloudstack/v1beta2/cluster-template-subdomain.yaml"
97+
- sourcePath: "../data/infrastructure-cloudstack/v1beta2/cluster-template-invalid-ip.yaml"
98+
- sourcePath: "../data/shared/v1beta1/metadata.yaml"
99+
versions:
100+
- name: v1.0.0
101+
value: ../../../config/default
102+
contract: v1beta1
103+
replacements:
104+
- old: --metrics-bind-addr=localhost:8080
105+
new: --metrics-bind-addr=:8080
106+
- old: "--leader-elect"
107+
new: "--leader-elect\n - --metrics-bind-addr=:8080"
108+
109+
variables:
110+
KUBERNETES_VERSION_MANAGEMENT: "v1.20.10"
111+
KUBERNETES_VERSION: "v1.20.10"
112+
CNI: "./data/cni/kindnet.yaml"
113+
IP_FAMILY: "IPv4"
114+
NODE_DRAIN_TIMEOUT: "60s"
115+
116+
CLOUDSTACK_FD1_NAME: "fd1"
117+
CLOUDSTACK_FD1_SECRET_NAME: "secret1"
118+
CLOUDSTACK_FD1_SECRET_NAMESPACE: "default"
119+
CLOUDSTACK_ZONE_NAME: Zone2
120+
CLOUDSTACK_INVALID_ZONE_NAME: zoneXXXX
121+
CLOUDSTACK_INVALID_NETWORK_NAME: networkXXXX
122+
CLOUDSTACK_ACCOUNT_NAME: admin
123+
CLOUDSTACK_INVALID_ACCOUNT_NAME: accountXXXX
124+
CLOUDSTACK_DOMAIN_NAME: ROOT
125+
CLOUDSTACK_INVALID_DOMAIN_NAME: domainXXXX
126+
CLOUDSTACK_NETWORK_NAME: isolated-for-e2e-1
127+
CLOUDSTACK_NEW_NETWORK_NAME: isolated-for-e2e-new
128+
CLOUDSTACK_SHARED_NETWORK_NAME: SharedNet2
129+
CLUSTER_ENDPOINT_IP: 10.11.3.98
130+
CLUSTER_ENDPOINT_IP_2: 10.11.3.97
131+
CLOUDSTACK_INVALID_IP: 1.2.3.4
132+
CLOUDSTACK_CONTROL_PLANE_MACHINE_OFFERING: "Fruitstand Instance"
133+
CLOUDSTACK_INVALID_CONTROL_PLANE_MACHINE_OFFERING: "OfferingXXXX"
134+
CLOUDSTACK_IMPOSSIBLE_CONTROL_PLANE_MACHINE_OFFERING: "Impossible Instance"
135+
CLOUDSTACK_WORKER_MACHINE_OFFERING: "Medium Instance"
136+
CLOUDSTACK_IMPOSSIBLE_WORKER_MACHINE_OFFERING: "Impossible Instance"
137+
CLOUDSTACK_TEMPLATE_NAME: ubuntu-2004-kube-v1.20.10
138+
CLOUDSTACK_INVALID_TEMPLATE_NAME: templateXXXX
139+
CLOUDSTACK_SSH_KEY_NAME: CAPCKeyPair6
140+
141+
CLOUDSTACK_INVALID_DISK_OFFERING_NAME: diskOfferingXXXX
142+
CLOUDSTACK_DISK_OFFERING_NAME: Small
143+
CLOUDSTACK_CUSTOM_DISK_OFFERING_NAME: Custom
144+
CLOUDSTACK_DISK_OFFERING_CUSTOM_SIZE: 1
145+
CLOUDSTACK_DISK_OFFERING_DEVICE: /dev/vdc
146+
CLOUDSTACK_DISK_OFFERING_FILESYSTEM: ext4
147+
CLOUDSTACK_DISK_OFFERING_LABEL: my_disk
148+
CLOUDSTACK_DISK_OFFERING_MOUNT_PATH: /my_disk
149+
150+
CLOUDSTACK_SUBDOMAIN_PATH: SUBDOMAIN
151+
CLOUDSTACK_SUBDOMAIN_ACCOUNT_NAME: SUBDOMAIN-ADMIN
152+
153+
CONFORMANCE_CONFIGURATION: "./data/kubetest/conformance.yaml"
154+
CONFORMANCE_WORKER_MACHINE_COUNT: "3"
155+
CONFORMANCE_CONTROL_PLANE_MACHINE_COUNT: "1"
156+
157+
intervals:
158+
conformance/wait-control-plane: ["20m", "10s"]
159+
conformance/wait-worker-nodes: ["20m", "10s"]
160+
161+
default/wait-errors: ["5m", "10s"]
162+
default/wait-controllers: ["3m", "10s"]
163+
default/wait-cluster: ["5m", "10s"]
164+
default/wait-control-plane: ["20m", "10s"]
165+
default/wait-worker-nodes: ["20m", "10s"]
166+
default/wait-delete-cluster: ["20m", "10s"]
167+
default/wait-machine-remediation: ["20m", "10s"]
168+
default/wait-machine-upgrade: ["20m", "10s"]
169+
170+
node-drain/wait-deployment-available: ["3m", "10s"]
171+
node-drain/wait-control-plane: ["15m", "10s"]
172+
node-drain/wait-machine-deleted: ["5m", "10s"]
173+
174+

0 commit comments

Comments
 (0)