Skip to content

Commit 494d058

Browse files
authored
E2e/add disk offering tests (#80)
* Add e2e tests for disk offering feature * Add checking disk offering of the cluster VM instances Co-authored-by: Wonkun Kim <[email protected]>
1 parent 5d01545 commit 494d058

File tree

12 files changed

+463
-1
lines changed

12 files changed

+463
-1
lines changed
Lines changed: 158 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,158 @@
1+
---
2+
apiVersion: cluster.x-k8s.io/v1beta1
3+
kind: Cluster
4+
metadata:
5+
name: ${CLUSTER_NAME}
6+
spec:
7+
clusterNetwork:
8+
pods:
9+
cidrBlocks:
10+
- 192.168.0.0/16
11+
serviceDomain: cluster.local
12+
infrastructureRef:
13+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
14+
kind: CloudStackCluster
15+
name: ${CLUSTER_NAME}
16+
controlPlaneRef:
17+
kind: KubeadmControlPlane
18+
apiVersion: controlplane.cluster.x-k8s.io/v1beta1
19+
name: ${CLUSTER_NAME}-control-plane
20+
---
21+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
22+
kind: CloudStackCluster
23+
metadata:
24+
name: ${CLUSTER_NAME}
25+
spec:
26+
controlPlaneEndpoint:
27+
host: ${CLUSTER_ENDPOINT_IP}
28+
port: ${CLUSTER_ENDPOINT_PORT}
29+
zones:
30+
- name : ${CLOUDSTACK_ZONE_NAME}
31+
network:
32+
name: ${CLOUDSTACK_NETWORK_NAME}
33+
---
34+
apiVersion: controlplane.cluster.x-k8s.io/v1beta1
35+
kind: KubeadmControlPlane
36+
metadata:
37+
name: "${CLUSTER_NAME}-control-plane"
38+
spec:
39+
kubeadmConfigSpec:
40+
clusterConfiguration:
41+
imageRepository: k8s.gcr.io
42+
initConfiguration:
43+
nodeRegistration:
44+
kubeletExtraArgs:
45+
provider-id: "cloudstack:///'{{ ds.meta_data.instance_id }}'"
46+
name: '{{ local_hostname }}'
47+
joinConfiguration:
48+
nodeRegistration:
49+
kubeletExtraArgs:
50+
provider-id: "cloudstack:///'{{ ds.meta_data.instance_id }}'"
51+
name: '{{ local_hostname }}'
52+
ignorePreflightErrors:
53+
- DirAvailable--etc-kubernetes-manifests
54+
preKubeadmCommands:
55+
- swapoff -a
56+
diskSetup:
57+
filesystems:
58+
- device: ${CLOUDSTACK_DISK_OFFERING_DEVICE}1
59+
overwrite: false
60+
extraOpts:
61+
- -E
62+
- lazy_itable_init=1,lazy_journal_init=1
63+
filesystem: ${CLOUDSTACK_DISK_OFFERING_FILESYSTEM}
64+
label: data_disk
65+
partitions:
66+
- device: ${CLOUDSTACK_DISK_OFFERING_DEVICE}
67+
layout: true
68+
overwrite: false
69+
tableType: gpt
70+
mounts:
71+
- - LABEL=${CLOUDSTACK_DISK_OFFERING_LABEL}
72+
- ${CLOUDSTACK_DISK_OFFERING_MOUNT_PATH}
73+
machineTemplate:
74+
infrastructureRef:
75+
kind: CloudStackMachineTemplate
76+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
77+
name: "${CLUSTER_NAME}-control-plane"
78+
replicas: ${CONTROL_PLANE_MACHINE_COUNT}
79+
version: ${KUBERNETES_VERSION}
80+
---
81+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
82+
kind: CloudStackMachineTemplate
83+
metadata:
84+
name: ${CLUSTER_NAME}-control-plane
85+
spec:
86+
template:
87+
spec:
88+
offering:
89+
name: ${CLOUDSTACK_CONTROL_PLANE_MACHINE_OFFERING}
90+
template:
91+
name: ${CLOUDSTACK_TEMPLATE_NAME}
92+
---
93+
apiVersion: cluster.x-k8s.io/v1beta1
94+
kind: MachineDeployment
95+
metadata:
96+
name: "${CLUSTER_NAME}-md-0"
97+
spec:
98+
clusterName: "${CLUSTER_NAME}"
99+
replicas: ${WORKER_MACHINE_COUNT}
100+
selector:
101+
matchLabels: null
102+
template:
103+
spec:
104+
bootstrap:
105+
configRef:
106+
apiVersion: bootstrap.cluster.x-k8s.io/v1beta1
107+
kind: KubeadmConfigTemplate
108+
name: "${CLUSTER_NAME}-md-0"
109+
clusterName: "${CLUSTER_NAME}"
110+
infrastructureRef:
111+
name: "${CLUSTER_NAME}-md-0"
112+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
113+
kind: CloudStackMachineTemplate
114+
version: ${KUBERNETES_VERSION}
115+
---
116+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
117+
kind: CloudStackMachineTemplate
118+
metadata:
119+
name: ${CLUSTER_NAME}-md-0
120+
spec:
121+
template:
122+
spec:
123+
offering:
124+
name: ${CLOUDSTACK_WORKER_MACHINE_OFFERING}
125+
template:
126+
name: ${CLOUDSTACK_TEMPLATE_NAME}
127+
---
128+
apiVersion: bootstrap.cluster.x-k8s.io/v1beta1
129+
kind: KubeadmConfigTemplate
130+
metadata:
131+
name: ${CLUSTER_NAME}-md-0
132+
spec:
133+
template:
134+
spec:
135+
joinConfiguration:
136+
nodeRegistration:
137+
kubeletExtraArgs:
138+
provider-id: "cloudstack:///'{{ ds.meta_data.instance_id }}'"
139+
name: '{{ local_hostname }}'
140+
preKubeadmCommands:
141+
- swapoff -a
142+
diskSetup:
143+
filesystems:
144+
- device: ${CLOUDSTACK_DISK_OFFERING_DEVICE}1
145+
overwrite: false
146+
extraOpts:
147+
- -E
148+
- lazy_itable_init=1,lazy_journal_init=1
149+
filesystem: ${CLOUDSTACK_DISK_OFFERING_FILESYSTEM}
150+
label: data_disk
151+
partitions:
152+
- device: ${CLOUDSTACK_DISK_OFFERING_DEVICE}
153+
layout: true
154+
overwrite: false
155+
tableType: gpt
156+
mounts:
157+
- - LABEL=${CLOUDSTACK_DISK_OFFERING_LABEL}
158+
- ${CLOUDSTACK_DISK_OFFERING_MOUNT_PATH}

test/e2e/common.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ const (
5252
CNIResources = "CNI_RESOURCES"
5353
IPFamily = "IP_FAMILY"
5454
InvalidZoneName = "CLOUDSTACK_INVALID_ZONE_NAME"
55+
InvalidDiskOfferingName = "CLOUDSTACK_INVALID_DISK_OFFERING_NAME"
5556
InvalidNetworkName = "CLOUDSTACK_INVALID_NETWORK_NAME"
5657
InvalidAccountName = "CLOUDSTACK_INVALID_ACCOUNT_NAME"
5758
InvalidDomainName = "CLOUDSTACK_INVALID_DOMAIN_NAME"
@@ -439,3 +440,18 @@ func IsClusterReady(ctx context.Context, mgmtClient client.Client, cluster *clus
439440
Expect(err).To(BeNil(), "Failed to get cluster status")
440441
return c.Status.ControlPlaneReady && c.Status.InfrastructureReady
441442
}
443+
444+
func CheckDiskOfferingOfVmInstances(clusterName string, diskOfferingName string) {
445+
client := createCloudStackClient()
446+
447+
Byf("Listing machines with %q", clusterName)
448+
listResp, err := client.VirtualMachine.ListVirtualMachines(client.VirtualMachine.NewListVirtualMachinesParams())
449+
if err != nil {
450+
Fail("Failed to list machines")
451+
}
452+
for _, vm := range listResp.VirtualMachines {
453+
if strings.Contains(vm.Name, clusterName) {
454+
Expect(vm.Diskofferingname).To(Equal(diskOfferingName))
455+
}
456+
}
457+
}

test/e2e/config/cloudstack.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@ providers:
8787
- sourcePath: "../data/infrastructure-cloudstack/v1beta1/cluster-template-resource-cleanup.yaml"
8888
- sourcePath: "../data/infrastructure-cloudstack/v1beta1/cluster-template-second-cluster.yaml"
8989
- sourcePath: "../data/infrastructure-cloudstack/v1beta1/cluster-template-shared-network-kubevip.yaml"
90+
- sourcePath: "../data/infrastructure-cloudstack/v1beta1/cluster-template-invalid-disk-offering.yaml"
91+
- sourcePath: "../data/infrastructure-cloudstack/v1beta1/cluster-template-disk-offering.yaml"
9092
- sourcePath: "../data/shared/v1beta1/metadata.yaml"
9193
versions:
9294
- name: v1.0.0
@@ -126,6 +128,13 @@ variables:
126128
CLOUDSTACK_INVALID_TEMPLATE_NAME: templateXXXX
127129
CLOUDSTACK_SSH_KEY_NAME: CAPCKeyPair6
128130

131+
CLOUDSTACK_INVALID_DISK_OFFERING_NAME: diskOfferingXXXX
132+
CLOUDSTACK_DISK_OFFERING_NAME: Small
133+
CLOUDSTACK_DISK_OFFERING_DEVICE: /dev/vdc
134+
CLOUDSTACK_DISK_OFFERING_FILESYSTEM: ext4
135+
CLOUDSTACK_DISK_OFFERING_LABEL: my_disk
136+
CLOUDSTACK_DISK_OFFERING_MOUNT_PATH: /my_disk
137+
129138
CONFORMANCE_CONFIGURATION: "./data/kubetest/conformance.yaml"
130139
CONFORMANCE_WORKER_MACHINE_COUNT: "3"
131140
CONFORMANCE_CONTROL_PLANE_MACHINE_COUNT: "1"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
kind: KubeadmControlPlane
2+
apiVersion: controlplane.cluster.x-k8s.io/v1beta1
3+
metadata:
4+
name: ${CLUSTER_NAME}-control-plane
5+
spec:
6+
kubeadmConfigSpec:
7+
initConfiguration:
8+
nodeRegistration:
9+
name: '{{ local_hostname }}'
10+
kubeletExtraArgs:
11+
provider-id: cloudstack:///'{{ ds.meta_data.instance_id }}'
12+
clusterConfiguration:
13+
imageRepository: k8s.gcr.io
14+
joinConfiguration:
15+
nodeRegistration:
16+
name: '{{ local_hostname }}'
17+
kubeletExtraArgs:
18+
provider-id: cloudstack:///'{{ ds.meta_data.instance_id }}'
19+
preKubeadmCommands:
20+
- swapoff -a
21+
diskSetup:
22+
filesystems:
23+
- device: ${CLOUDSTACK_DISK_OFFERING_DEVICE}1
24+
overwrite: false
25+
extraOpts:
26+
- -E
27+
- lazy_itable_init=1,lazy_journal_init=1
28+
filesystem: ${CLOUDSTACK_DISK_OFFERING_FILESYSTEM}
29+
label: data_disk
30+
partitions:
31+
- device: ${CLOUDSTACK_DISK_OFFERING_DEVICE}
32+
layout: true
33+
overwrite: false
34+
tableType: gpt
35+
mounts:
36+
- - LABEL=${CLOUDSTACK_DISK_OFFERING_LABEL}
37+
- ${CLOUDSTACK_DISK_OFFERING_MOUNT_PATH}
38+
machineTemplate:
39+
infrastructureRef:
40+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
41+
kind: CloudStackMachineTemplate
42+
name: ${CLUSTER_NAME}-control-plane
43+
replicas: ${CONTROL_PLANE_MACHINE_COUNT}
44+
version: ${KUBERNETES_VERSION}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
bases:
2+
- ../bases/cluster-with-kcp.yaml
3+
- ../bases/md.yaml
4+
5+
patchesStrategicMerge:
6+
- ./cluster-with-disk-offering.yaml
7+
- ./md.yaml
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
2+
kind: CloudStackMachineTemplate
3+
metadata:
4+
name: ${CLUSTER_NAME}-control-plane
5+
spec:
6+
template:
7+
spec:
8+
offering:
9+
name: ${CLOUDSTACK_CONTROL_PLANE_MACHINE_OFFERING}
10+
diskOffering:
11+
name: ${CLOUDSTACK_DISK_OFFERING_NAME}
12+
mountPath: ${CLOUDSTACK_DISK_OFFERING_MOUNT_PATH}
13+
device: ${CLOUDSTACK_DISK_OFFERING_DEVICE}
14+
filesystem: ${CLOUDSTACK_DISK_OFFERING_FILESYSTEM}
15+
label: ${CLOUDSTACK_DISK_OFFERING_LABEL}
16+
template:
17+
name: ${CLOUDSTACK_TEMPLATE_NAME}
18+
sshKey: ${CLOUDSTACK_SSH_KEY_NAME}
19+
---
20+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
21+
kind: CloudStackMachineTemplate
22+
metadata:
23+
name: ${CLUSTER_NAME}-md-0
24+
spec:
25+
template:
26+
spec:
27+
offering:
28+
name: ${CLOUDSTACK_WORKER_MACHINE_OFFERING}
29+
diskOffering:
30+
name: ${CLOUDSTACK_DISK_OFFERING_NAME}
31+
mountPath: ${CLOUDSTACK_DISK_OFFERING_MOUNT_PATH}
32+
device: ${CLOUDSTACK_DISK_OFFERING_DEVICE}
33+
filesystem: ${CLOUDSTACK_DISK_OFFERING_FILESYSTEM}
34+
label: ${CLOUDSTACK_DISK_OFFERING_LABEL}
35+
template:
36+
name: ${CLOUDSTACK_TEMPLATE_NAME}
37+
sshKey: ${CLOUDSTACK_SSH_KEY_NAME}
38+
---
39+
apiVersion: bootstrap.cluster.x-k8s.io/v1beta1
40+
kind: KubeadmConfigTemplate
41+
metadata:
42+
name: ${CLUSTER_NAME}-md-0
43+
spec:
44+
template:
45+
spec:
46+
joinConfiguration:
47+
nodeRegistration:
48+
name: '{{ local_hostname }}'
49+
kubeletExtraArgs:
50+
provider-id: cloudstack:///'{{ ds.meta_data.instance_id }}'
51+
preKubeadmCommands:
52+
- swapoff -a
53+
diskSetup:
54+
filesystems:
55+
- device: ${CLOUDSTACK_DISK_OFFERING_DEVICE}1
56+
overwrite: false
57+
extraOpts:
58+
- -E
59+
- lazy_itable_init=1,lazy_journal_init=1
60+
filesystem: ${CLOUDSTACK_DISK_OFFERING_FILESYSTEM}
61+
label: data_disk
62+
partitions:
63+
- device: ${CLOUDSTACK_DISK_OFFERING_DEVICE}
64+
layout: true
65+
overwrite: false
66+
tableType: gpt
67+
mounts:
68+
- - LABEL=${CLOUDSTACK_DISK_OFFERING_LABEL}
69+
- ${CLOUDSTACK_DISK_OFFERING_MOUNT_PATH}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
bases:
2+
- ../bases/cluster-with-kcp.yaml
3+
- ../bases/md.yaml
4+
5+
patchesStrategicMerge:
6+
- ./md.yaml
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
2+
kind: CloudStackMachineTemplate
3+
metadata:
4+
name: ${CLUSTER_NAME}-control-plane
5+
spec:
6+
template:
7+
spec:
8+
offering:
9+
name: ${CLOUDSTACK_CONTROL_PLANE_MACHINE_OFFERING}
10+
diskOffering:
11+
name: ${CLOUDSTACK_INVALID_DISK_OFFERING_NAME}
12+
mountPath: /disk
13+
device: /dev/vdb
14+
filesystem: ext4
15+
label: my_disk
16+
template:
17+
name: ${CLOUDSTACK_TEMPLATE_NAME}
18+
sshKey: ${CLOUDSTACK_SSH_KEY_NAME}

0 commit comments

Comments
 (0)