From 933329c46f1e5541ee31ad4a348030ec82224b4c Mon Sep 17 00:00:00 2001 From: Christian Schlotter Date: Fri, 23 Aug 2024 13:54:46 +0200 Subject: [PATCH] test: add autoscaler test for supervisor including scale from/to zero --- test/e2e/autoscaler_test.go | 54 ++++++++++++++++++++++++++++++++++++ test/e2e/config/vsphere.yaml | 14 +++++++--- 2 files changed, 64 insertions(+), 4 deletions(-) create mode 100644 test/e2e/autoscaler_test.go diff --git a/test/e2e/autoscaler_test.go b/test/e2e/autoscaler_test.go new file mode 100644 index 0000000000..288193dad0 --- /dev/null +++ b/test/e2e/autoscaler_test.go @@ -0,0 +1,54 @@ +/* +Copyright 2024 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 ( + . "github.com/onsi/ginkgo/v2" + "k8s.io/utils/ptr" + capi_e2e "sigs.k8s.io/cluster-api/test/e2e" + "sigs.k8s.io/cluster-api/test/framework" +) + +var _ = Describe("When using the autoscaler with Cluster API using ClusterClass and scale to zero [vcsim] [supervisor] [ClusterClass]", func() { + const specName = "autoscaler" // aligned to CAPI + Setup(specName, func(testSpecificSettingsGetter func() testSettings) { + capi_e2e.AutoscalerSpec(ctx, func() capi_e2e.AutoscalerSpecInput { + return capi_e2e.AutoscalerSpecInput{ + E2EConfig: e2eConfig, + ClusterctlConfigPath: testSpecificSettingsGetter().ClusterctlConfigPath, + BootstrapClusterProxy: bootstrapClusterProxy, + ArtifactFolder: artifactFolder, + SkipCleanup: skipCleanup, + Flavor: ptr.To(testSpecificSettingsGetter().FlavorForMode("topology-autoscaler")), + PostNamespaceCreated: func(managementClusterProxy framework.ClusterProxy, workloadClusterNamespace string) { + if testMode == GovmomiTestMode { + // This test is only implemented for supervisor + Skip("This test is only implemented for supervisor") + } + testSpecificSettingsGetter().PostNamespaceCreatedFunc(managementClusterProxy, workloadClusterNamespace) + }, + InfrastructureAPIGroup: "vmware.infrastructure.cluster.x-k8s.io", + InfrastructureMachineTemplateKind: "vspheremachinetemplates", + AutoscalerVersion: "v1.30.0", + ScaleToAndFromZero: true, + // We have no connectivity from the workload cluster to the kind management cluster in CI so we + // can't deploy the autoscaler to the workload cluster. + InstallOnManagementCluster: true, + } + }) + }) +}) diff --git a/test/e2e/config/vsphere.yaml b/test/e2e/config/vsphere.yaml index 5b6b8fc6d1..6d6706f200 100644 --- a/test/e2e/config/vsphere.yaml +++ b/test/e2e/config/vsphere.yaml @@ -259,6 +259,7 @@ variables: KUBERNETES_VERSION_LATEST_CI: "ci/latest-1.32" CPI_IMAGE_K8S_VERSION: "v1.31.0" CNI: "./data/cni/calico/calico.yaml" + AUTOSCALER_WORKLOAD: "./data/autoscaler/autoscaler-to-management-workload.yaml" EXP_CLUSTER_RESOURCE_SET: "true" EXP_KUBEADM_BOOTSTRAP_FORMAT_IGNITION: "true" CONTROL_PLANE_MACHINE_COUNT: 1 @@ -273,11 +274,15 @@ variables: VSPHERE_STORAGE_POLICY: "Cluster API vSphere Storage Policy" VSPHERE_STORAGE_CLASS: "test-storageclass" VSPHERE_MACHINE_CLASS_NAME: "test-machine-class" - VSPHERE_MACHINE_CLASS_CPU: "4" - VSPHERE_MACHINE_CLASS_MEMORY: "8Gi" + # CI runs vm-operator v1.8.6 on vCenter 8, setting CPU and Memory does not work and defaults to 2 CPUs / 2Gi memory. + # Changing the value results in VM's getting created but not setting the correct CPU or memory size. + VSPHERE_MACHINE_CLASS_CPU: "2" + VSPHERE_MACHINE_CLASS_MEMORY: "2Gi" VSPHERE_MACHINE_CLASS_NAME_CONFORMANCE: "test-machine-class-conformance" - VSPHERE_MACHINE_CLASS_CPU_CONFORMANCE: "8" - VSPHERE_MACHINE_CLASS_MEMORY_CONFORMANCE: "8Gi" + # CI runs vm-operator v1.8.6 on vCenter 8, setting CPU and Memory does not work and defaults to 2 CPUs / 2Gi memory. + # Changing the value results in VM's getting created but not setting the correct CPU or memory size. + VSPHERE_MACHINE_CLASS_CPU_CONFORMANCE: "2" + VSPHERE_MACHINE_CLASS_MEMORY_CONFORMANCE: "2Gi" VSPHERE_CONTENT_LIBRARY: "capv" VSPHERE_CONTENT_LIBRARY_ITEMS: "ubuntu-2204-kube-v1.28.0,ubuntu-2204-kube-v1.29.0,ubuntu-2204-kube-v1.30.0,ubuntu-2404-kube-v1.31.0" VSPHERE_IMAGE_NAME: "ubuntu-2404-kube-v1.31.0" @@ -303,6 +308,7 @@ variables: SERVICE_ACCOUNTS_CM_NAME: "service-accounts-cm" intervals: + default/wait-autoscaler: ["5m", "10s"] default/wait-controllers: ["5m", "10s"] default/wait-cluster: ["5m", "10s"] default/wait-control-plane: ["10m", "10s"]