Skip to content

Commit d30e4fd

Browse files
committed
E2E tests
1 parent 13eb94d commit d30e4fd

File tree

3 files changed

+132
-0
lines changed

3 files changed

+132
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
2+
kind: VSphereMachineTemplate
3+
metadata:
4+
name: '${CLUSTER_NAME}'
5+
namespace: '${NAMESPACE}'
6+
spec:
7+
template:
8+
spec:
9+
dataDisks:
10+
- name: "etcd"
11+
sizeGiB: 10
12+
- name: "container-images"
13+
sizeGiB: 20
14+
---
15+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
16+
kind: VSphereMachineTemplate
17+
metadata:
18+
name: '${CLUSTER_NAME}-worker'
19+
namespace: '${NAMESPACE}'
20+
spec:
21+
template:
22+
spec:
23+
dataDisks:
24+
- name: "container-images"
25+
sizeGiB: 20
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
apiVersion: kustomize.config.k8s.io/v1beta1
2+
kind: Kustomization
3+
resources:
4+
- ../base
5+
patchesStrategicMerge:
6+
- data-disks-patch.yaml

test/e2e/multi-disk.go

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
/*
2+
Copyright 2022 The Kubernetes Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package e2e
18+
19+
import (
20+
"context"
21+
"fmt"
22+
23+
. "github.com/onsi/ginkgo/v2"
24+
. "github.com/onsi/gomega"
25+
corev1 "k8s.io/api/core/v1"
26+
"sigs.k8s.io/cluster-api/test/framework/clusterctl"
27+
. "sigs.k8s.io/cluster-api/test/framework/ginkgoextensions"
28+
capiutil "sigs.k8s.io/cluster-api/util"
29+
)
30+
31+
type DiskSpecInput struct {
32+
InfraClients
33+
Global GlobalInput
34+
SpecName string
35+
Namespace *corev1.Namespace
36+
Template string
37+
ToVersion string
38+
}
39+
40+
var _ = Describe("Multi-Disk support", func() {
41+
const specName = "multi-disk"
42+
Setup(specName, func(testSpecificSettingsGetter func() testSettings) {
43+
var (
44+
namespace *corev1.Namespace
45+
)
46+
47+
BeforeEach(func() {
48+
Expect(bootstrapClusterProxy).NotTo(BeNil(), "BootstrapClusterProxy can't be nil")
49+
namespace = setupSpecNamespace(specName, testSpecificSettingsGetter().PostNamespaceCreatedFunc)
50+
})
51+
52+
AfterEach(func() {
53+
cleanupSpecNamespace(namespace)
54+
})
55+
56+
It("should create control plane with multiple disks", func() {
57+
Expect(e2eConfig.GetVariable("VSPHERE_TEMPLATE")).NotTo(BeEmpty())
58+
59+
VerifyDisks(ctx, DiskSpecInput{
60+
SpecName: specName,
61+
Namespace: namespace,
62+
Template: e2eConfig.GetVariable("VSPHERE_TEMPLATE"),
63+
ToVersion: "vmx-17",
64+
InfraClients: InfraClients{
65+
Client: vsphereClient,
66+
RestClient: restClient,
67+
Finder: vsphereFinder,
68+
},
69+
Global: GlobalInput{
70+
BootstrapClusterProxy: bootstrapClusterProxy,
71+
ClusterctlConfigPath: testSpecificSettingsGetter().ClusterctlConfigPath,
72+
E2EConfig: e2eConfig,
73+
ArtifactFolder: artifactFolder,
74+
},
75+
})
76+
})
77+
})
78+
})
79+
80+
func VerifyDisks(ctx context.Context, input DiskSpecInput) {
81+
var (
82+
specName = input.SpecName
83+
namespace = input.Namespace
84+
clusterResources = new(clusterctl.ApplyClusterTemplateAndWaitResult)
85+
)
86+
87+
Byf("Getting the hardware version of the OVA %s", input.Template)
88+
//fromVersion := getHardwareVersion(ctx, input.Finder, input.Template)
89+
90+
clusterName := fmt.Sprintf("%s-%s", specName, capiutil.RandomString(6))
91+
By("Creating a cluster")
92+
configCluster := defaultConfigCluster(clusterName, namespace.Name, specName, 1, 1, input.Global)
93+
94+
clusterctl.ApplyClusterTemplateAndWait(ctx, clusterctl.ApplyClusterTemplateAndWaitInput{
95+
ClusterProxy: input.Global.BootstrapClusterProxy,
96+
ConfigCluster: configCluster,
97+
WaitForClusterIntervals: input.Global.E2EConfig.GetIntervals(specName, "wait-cluster"),
98+
WaitForControlPlaneIntervals: input.Global.E2EConfig.GetIntervals(specName, "wait-control-plane"),
99+
WaitForMachineDeployments: input.Global.E2EConfig.GetIntervals(specName, "wait-worker-nodes"),
100+
}, clusterResources)
101+
}

0 commit comments

Comments
 (0)