Skip to content

Commit

Permalink
Converted e2e test to use QuickStartSpec
Browse files Browse the repository at this point in the history
  • Loading branch information
vr4manta committed Nov 26, 2024
1 parent eb21524 commit 5f228cb
Showing 1 changed file with 40 additions and 61 deletions.
101 changes: 40 additions & 61 deletions test/e2e/multi-disk_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,82 +23,61 @@ import (
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"github.com/vmware/govmomi/vim25/types"
corev1 "k8s.io/api/core/v1"
"sigs.k8s.io/cluster-api/test/framework/clusterctl"
"k8s.io/utils/ptr"
capi_e2e "sigs.k8s.io/cluster-api/test/e2e"
"sigs.k8s.io/cluster-api/test/framework"
. "sigs.k8s.io/cluster-api/test/framework/ginkgoextensions"
capiutil "sigs.k8s.io/cluster-api/util"
)

type DiskSpecInput struct {
InfraClients
Global GlobalInput
SpecName string
Namespace *corev1.Namespace
Template string
ToVersion string
Global GlobalInput
SpecName string
Namespace string
ClusterName string
}

var _ = Describe("Ensure govmomi mode is able to add additional disks to VMs [vcsim]", func() {
const specName = "multi-disk"
Setup(specName, func(testSpecificSettingsGetter func() testSettings) {
var (
namespace *corev1.Namespace
)

BeforeEach(func() {
Expect(bootstrapClusterProxy).NotTo(BeNil(), "BootstrapClusterProxy can't be nil")
namespace = setupSpecNamespace(specName, testSpecificSettingsGetter().PostNamespaceCreatedFunc)
})

AfterEach(func() {
cleanupSpecNamespace(namespace)
})

It("should create control plane with multiple disks", func() {
Expect(e2eConfig.GetVariable("VSPHERE_TEMPLATE")).NotTo(BeEmpty())

VerifyDisks(ctx, DiskSpecInput{
SpecName: specName,
Namespace: namespace,
Template: e2eConfig.GetVariable("VSPHERE_TEMPLATE"),
ToVersion: "vmx-17",
InfraClients: InfraClients{
Client: vsphereClient,
RestClient: restClient,
Finder: vsphereFinder,
},
Global: GlobalInput{
BootstrapClusterProxy: bootstrapClusterProxy,
ClusterctlConfigPath: testSpecificSettingsGetter().ClusterctlConfigPath,
E2EConfig: e2eConfig,
ArtifactFolder: artifactFolder,
capi_e2e.QuickStartSpec(ctx, func() capi_e2e.QuickStartSpecInput {
return capi_e2e.QuickStartSpecInput{
E2EConfig: e2eConfig,
ClusterctlConfigPath: testSpecificSettingsGetter().ClusterctlConfigPath,
BootstrapClusterProxy: bootstrapClusterProxy,
ArtifactFolder: artifactFolder,
SkipCleanup: skipCleanup,
Flavor: ptr.To(testSpecificSettingsGetter().FlavorForMode("multi-disk")),
PostNamespaceCreated: testSpecificSettingsGetter().PostNamespaceCreatedFunc,
PostMachinesProvisioned: func(proxy framework.ClusterProxy, namespace, clusterName string) {

Check failure on line 52 in test/e2e/multi-disk_test.go

View workflow job for this annotation

GitHub Actions / lint (test)

unused-parameter: parameter 'proxy' seems to be unused, consider removing or renaming it as _ (revive)
dsi := DiskSpecInput{
SpecName: specName,
Namespace: namespace,
ClusterName: clusterName,
InfraClients: InfraClients{
Client: vsphereClient,
RestClient: restClient,
Finder: vsphereFinder,
},
Global: GlobalInput{
BootstrapClusterProxy: bootstrapClusterProxy,
ClusterctlConfigPath: testSpecificSettingsGetter().ClusterctlConfigPath,
E2EConfig: e2eConfig,
ArtifactFolder: artifactFolder,
},
}
verifyDisks(ctx, dsi)
},
})
ControlPlaneMachineCount: ptr.To[int64](1),
WorkerMachineCount: ptr.To[int64](1),
}
})
})
})

func VerifyDisks(ctx context.Context, input DiskSpecInput) {
var (
specName = input.SpecName
namespace = input.Namespace
clusterResources = new(clusterctl.ApplyClusterTemplateAndWaitResult)
)

clusterName := fmt.Sprintf("%s-%s", specName, capiutil.RandomString(6))
By("Creating a cluster")
configCluster := defaultConfigCluster(clusterName, namespace.Name, specName, 1, 1, input.Global)

clusterctl.ApplyClusterTemplateAndWait(ctx, clusterctl.ApplyClusterTemplateAndWaitInput{
ClusterProxy: input.Global.BootstrapClusterProxy,
ConfigCluster: configCluster,
WaitForClusterIntervals: input.Global.E2EConfig.GetIntervals(specName, "wait-cluster"),
WaitForControlPlaneIntervals: input.Global.E2EConfig.GetIntervals(specName, "wait-control-plane"),
WaitForMachineDeployments: input.Global.E2EConfig.GetIntervals(specName, "wait-worker-nodes"),
}, clusterResources)

Byf("Fetching the VSphereVM objects for the cluster %s", clusterName)
vms := getVSphereVMsForCluster(clusterName, namespace.Name)
func verifyDisks(ctx context.Context, input DiskSpecInput) {
Byf("Fetching the VSphereVM objects for the cluster %s", input.ClusterName)
vms := getVSphereVMsForCluster(input.ClusterName, input.Namespace)

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

0 comments on commit 5f228cb

Please sign in to comment.