-
Notifications
You must be signed in to change notification settings - Fork 296
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
154 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
test/e2e/data/infrastructure-vsphere-govmomi/main/multi-disk/data-disks-patch.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 | ||
kind: VSphereMachineTemplate | ||
metadata: | ||
name: '${CLUSTER_NAME}' | ||
namespace: '${NAMESPACE}' | ||
spec: | ||
template: | ||
spec: | ||
dataDisks: | ||
- name: "etcd" | ||
sizeGiB: 10 | ||
- name: "container-images" | ||
sizeGiB: 20 | ||
--- | ||
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 | ||
kind: VSphereMachineTemplate | ||
metadata: | ||
name: '${CLUSTER_NAME}-worker' | ||
namespace: '${NAMESPACE}' | ||
spec: | ||
template: | ||
spec: | ||
dataDisks: | ||
- name: "container-images" | ||
sizeGiB: 20 |
6 changes: 6 additions & 0 deletions
6
test/e2e/data/infrastructure-vsphere-govmomi/main/multi-disk/kustomization.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
apiVersion: kustomize.config.k8s.io/v1beta1 | ||
kind: Kustomization | ||
resources: | ||
- ../base | ||
patchesStrategicMerge: | ||
- data-disks-patch.yaml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
/* | ||
Copyright 2022 The Kubernetes Authors. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package e2e | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
|
||
. "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" | ||
. "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 | ||
} | ||
|
||
var _ = Describe("Multi-Disk support", 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, | ||
}, | ||
}) | ||
}) | ||
}) | ||
}) | ||
|
||
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) | ||
|
||
By("Verifying the disks attached to the VMs") | ||
for _, vm := range vms.Items { | ||
// vSphere machine object should have the data disks configured. We will add +1 to the count since the os image | ||
// needs to be included for comparison. | ||
Byf("VM %s Spec has %d DataDisks defined", vm.Name, len(vm.Spec.DataDisks)) | ||
diskCount := 1 + len(vm.Spec.DataDisks) | ||
Expect(diskCount).ToNot(Equal(1), "Total disk count should be larger than 1 for this test") | ||
|
||
vmObj, err := input.Finder.VirtualMachine(ctx, vm.Name) | ||
Expect(err).NotTo(HaveOccurred()) | ||
|
||
devices, err := vmObj.Device(ctx) | ||
Expect(err).NotTo(HaveOccurred()) | ||
|
||
// We expect control plane VMs to have 3 disks, and the compute VMs will have 2. | ||
disks := devices.SelectByType((*types.VirtualDisk)(nil)) | ||
Expect(disks).To(HaveLen(diskCount), fmt.Sprintf("Disk count of VM should be %d", diskCount)) | ||
} | ||
} |