Skip to content

Commit 5f228cb

Browse files
committed
Converted e2e test to use QuickStartSpec
1 parent eb21524 commit 5f228cb

File tree

1 file changed

+40
-61
lines changed

1 file changed

+40
-61
lines changed

test/e2e/multi-disk_test.go

Lines changed: 40 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -23,82 +23,61 @@ import (
2323
. "github.com/onsi/ginkgo/v2"
2424
. "github.com/onsi/gomega"
2525
"github.com/vmware/govmomi/vim25/types"
26-
corev1 "k8s.io/api/core/v1"
27-
"sigs.k8s.io/cluster-api/test/framework/clusterctl"
26+
"k8s.io/utils/ptr"
27+
capi_e2e "sigs.k8s.io/cluster-api/test/e2e"
28+
"sigs.k8s.io/cluster-api/test/framework"
2829
. "sigs.k8s.io/cluster-api/test/framework/ginkgoextensions"
29-
capiutil "sigs.k8s.io/cluster-api/util"
3030
)
3131

3232
type DiskSpecInput struct {
3333
InfraClients
34-
Global GlobalInput
35-
SpecName string
36-
Namespace *corev1.Namespace
37-
Template string
38-
ToVersion string
34+
Global GlobalInput
35+
SpecName string
36+
Namespace string
37+
ClusterName string
3938
}
4039

4140
var _ = Describe("Ensure govmomi mode is able to add additional disks to VMs [vcsim]", func() {
4241
const specName = "multi-disk"
4342
Setup(specName, func(testSpecificSettingsGetter func() testSettings) {
44-
var (
45-
namespace *corev1.Namespace
46-
)
47-
48-
BeforeEach(func() {
49-
Expect(bootstrapClusterProxy).NotTo(BeNil(), "BootstrapClusterProxy can't be nil")
50-
namespace = setupSpecNamespace(specName, testSpecificSettingsGetter().PostNamespaceCreatedFunc)
51-
})
52-
53-
AfterEach(func() {
54-
cleanupSpecNamespace(namespace)
55-
})
56-
57-
It("should create control plane with multiple disks", func() {
58-
Expect(e2eConfig.GetVariable("VSPHERE_TEMPLATE")).NotTo(BeEmpty())
59-
60-
VerifyDisks(ctx, DiskSpecInput{
61-
SpecName: specName,
62-
Namespace: namespace,
63-
Template: e2eConfig.GetVariable("VSPHERE_TEMPLATE"),
64-
ToVersion: "vmx-17",
65-
InfraClients: InfraClients{
66-
Client: vsphereClient,
67-
RestClient: restClient,
68-
Finder: vsphereFinder,
69-
},
70-
Global: GlobalInput{
71-
BootstrapClusterProxy: bootstrapClusterProxy,
72-
ClusterctlConfigPath: testSpecificSettingsGetter().ClusterctlConfigPath,
73-
E2EConfig: e2eConfig,
74-
ArtifactFolder: artifactFolder,
43+
capi_e2e.QuickStartSpec(ctx, func() capi_e2e.QuickStartSpecInput {
44+
return capi_e2e.QuickStartSpecInput{
45+
E2EConfig: e2eConfig,
46+
ClusterctlConfigPath: testSpecificSettingsGetter().ClusterctlConfigPath,
47+
BootstrapClusterProxy: bootstrapClusterProxy,
48+
ArtifactFolder: artifactFolder,
49+
SkipCleanup: skipCleanup,
50+
Flavor: ptr.To(testSpecificSettingsGetter().FlavorForMode("multi-disk")),
51+
PostNamespaceCreated: testSpecificSettingsGetter().PostNamespaceCreatedFunc,
52+
PostMachinesProvisioned: func(proxy framework.ClusterProxy, namespace, clusterName string) {
53+
dsi := DiskSpecInput{
54+
SpecName: specName,
55+
Namespace: namespace,
56+
ClusterName: clusterName,
57+
InfraClients: InfraClients{
58+
Client: vsphereClient,
59+
RestClient: restClient,
60+
Finder: vsphereFinder,
61+
},
62+
Global: GlobalInput{
63+
BootstrapClusterProxy: bootstrapClusterProxy,
64+
ClusterctlConfigPath: testSpecificSettingsGetter().ClusterctlConfigPath,
65+
E2EConfig: e2eConfig,
66+
ArtifactFolder: artifactFolder,
67+
},
68+
}
69+
verifyDisks(ctx, dsi)
7570
},
76-
})
71+
ControlPlaneMachineCount: ptr.To[int64](1),
72+
WorkerMachineCount: ptr.To[int64](1),
73+
}
7774
})
7875
})
7976
})
8077

81-
func VerifyDisks(ctx context.Context, input DiskSpecInput) {
82-
var (
83-
specName = input.SpecName
84-
namespace = input.Namespace
85-
clusterResources = new(clusterctl.ApplyClusterTemplateAndWaitResult)
86-
)
87-
88-
clusterName := fmt.Sprintf("%s-%s", specName, capiutil.RandomString(6))
89-
By("Creating a cluster")
90-
configCluster := defaultConfigCluster(clusterName, namespace.Name, specName, 1, 1, input.Global)
91-
92-
clusterctl.ApplyClusterTemplateAndWait(ctx, clusterctl.ApplyClusterTemplateAndWaitInput{
93-
ClusterProxy: input.Global.BootstrapClusterProxy,
94-
ConfigCluster: configCluster,
95-
WaitForClusterIntervals: input.Global.E2EConfig.GetIntervals(specName, "wait-cluster"),
96-
WaitForControlPlaneIntervals: input.Global.E2EConfig.GetIntervals(specName, "wait-control-plane"),
97-
WaitForMachineDeployments: input.Global.E2EConfig.GetIntervals(specName, "wait-worker-nodes"),
98-
}, clusterResources)
99-
100-
Byf("Fetching the VSphereVM objects for the cluster %s", clusterName)
101-
vms := getVSphereVMsForCluster(clusterName, namespace.Name)
78+
func verifyDisks(ctx context.Context, input DiskSpecInput) {
79+
Byf("Fetching the VSphereVM objects for the cluster %s", input.ClusterName)
80+
vms := getVSphereVMsForCluster(input.ClusterName, input.Namespace)
10281

10382
By("Verifying the disks attached to the VMs")
10483
for _, vm := range vms.Items {

0 commit comments

Comments
 (0)