From e1e449ee5bc15015a104ffddd93656f8e4a3f573 Mon Sep 17 00:00:00 2001 From: Wonkun Kim Date: Fri, 20 May 2022 09:58:46 -0500 Subject: [PATCH 1/6] Add subdomain e2e test --- test/e2e/affinity_group.go | 5 +- test/e2e/config/cloudstack.yaml | 5 +- .../cloudstack-cluster.yaml | 2 +- .../cloudstack-cluster.yaml | 14 +++ .../kustomization.yaml | 7 ++ .../cluster-template-subdomain/md.yaml | 28 ++++++ test/e2e/node_drain_timeout.go | 3 + test/e2e/subdomain.go | 87 +++++++++++++++++++ test/e2e/subdomain_test.go | 38 ++++++++ 9 files changed, 184 insertions(+), 5 deletions(-) create mode 100644 test/e2e/data/infrastructure-cloudstack/v1beta1/cluster-template-subdomain/cloudstack-cluster.yaml create mode 100644 test/e2e/data/infrastructure-cloudstack/v1beta1/cluster-template-subdomain/kustomization.yaml create mode 100644 test/e2e/data/infrastructure-cloudstack/v1beta1/cluster-template-subdomain/md.yaml create mode 100644 test/e2e/subdomain.go create mode 100644 test/e2e/subdomain_test.go diff --git a/test/e2e/affinity_group.go b/test/e2e/affinity_group.go index a3042bd7..b6d1dafc 100644 --- a/test/e2e/affinity_group.go +++ b/test/e2e/affinity_group.go @@ -62,7 +62,6 @@ func AffinityGroupSpec(ctx context.Context, inputGetter func() CommonSpecInput) }) It("Should have host affinity group when affinity is anti", func() { - Skip("The ACS used by Prow doesn't have multiple hosts in the target zone") executeTest(ctx, input, namespace, specName, clusterResources, "anti") }) @@ -90,8 +89,8 @@ func executeTest(ctx context.Context, input CommonSpecInput, namespace *corev1.N Namespace: namespace.Name, ClusterName: fmt.Sprintf("%s-%s", specName, util.RandomString(6)), KubernetesVersion: input.E2EConfig.GetVariable(KubernetesVersion), - ControlPlaneMachineCount: pointer.Int64Ptr(3), - WorkerMachineCount: pointer.Int64Ptr(3), + ControlPlaneMachineCount: pointer.Int64Ptr(1), + WorkerMachineCount: pointer.Int64Ptr(1), }, WaitForClusterIntervals: input.E2EConfig.GetIntervals(specName, "wait-cluster"), WaitForControlPlaneIntervals: input.E2EConfig.GetIntervals(specName, "wait-control-plane"), diff --git a/test/e2e/config/cloudstack.yaml b/test/e2e/config/cloudstack.yaml index 19b9a2fa..97836fc0 100644 --- a/test/e2e/config/cloudstack.yaml +++ b/test/e2e/config/cloudstack.yaml @@ -92,6 +92,7 @@ providers: - sourcePath: "../data/infrastructure-cloudstack/v1beta1/cluster-template-invalid-disk-offering-size-for-customized.yaml" - sourcePath: "../data/infrastructure-cloudstack/v1beta1/cluster-template-disk-offering.yaml" - sourcePath: "../data/infrastructure-cloudstack/v1beta1/cluster-template-custom-disk-offering.yaml" + - sourcePath: "../data/infrastructure-cloudstack/v1beta1/cluster-template-subdomain.yaml" - sourcePath: "../data/shared/v1beta1/metadata.yaml" versions: - name: v1.0.0 @@ -120,7 +121,6 @@ variables: CLOUDSTACK_SHARED_NETWORK_NAME: Shared1 CLUSTER_ENDPOINT_IP: 172.16.2.199 CLUSTER_ENDPOINT_IP_2: 172.16.2.198 - CLUSTER_ENDPOINT_NEW_IP: 172.16.2.201 CLUSTER_ENDPOINT_PORT: 6443 CLUSTER_ENDPOINT_PORT_2: 6443 CLOUDSTACK_CONTROL_PLANE_MACHINE_OFFERING: "Large Instance" @@ -140,6 +140,9 @@ variables: CLOUDSTACK_DISK_OFFERING_LABEL: my_disk CLOUDSTACK_DISK_OFFERING_MOUNT_PATH: /my_disk + CLOUDSTACK_SUBDOMAIN_PATH: SUBDOMAIN + CLOUDSTACK_SUBDOMAIN_ACCOUNT_NAME: SUBDOMAIN-ADMIN + CONFORMANCE_CONFIGURATION: "./data/kubetest/conformance.yaml" CONFORMANCE_WORKER_MACHINE_COUNT: "3" CONFORMANCE_CONTROL_PLANE_MACHINE_COUNT: "1" diff --git a/test/e2e/data/infrastructure-cloudstack/v1beta1/cluster-template-resource-cleanup/cloudstack-cluster.yaml b/test/e2e/data/infrastructure-cloudstack/v1beta1/cluster-template-resource-cleanup/cloudstack-cluster.yaml index fa4e6b0a..8c237cef 100644 --- a/test/e2e/data/infrastructure-cloudstack/v1beta1/cluster-template-resource-cleanup/cloudstack-cluster.yaml +++ b/test/e2e/data/infrastructure-cloudstack/v1beta1/cluster-template-resource-cleanup/cloudstack-cluster.yaml @@ -8,5 +8,5 @@ spec: network: name: ${CLOUDSTACK_NEW_NETWORK_NAME} controlPlaneEndpoint: - host: ${CLUSTER_ENDPOINT_NEW_IP} + host: "" port: ${CLUSTER_ENDPOINT_PORT} \ No newline at end of file diff --git a/test/e2e/data/infrastructure-cloudstack/v1beta1/cluster-template-subdomain/cloudstack-cluster.yaml b/test/e2e/data/infrastructure-cloudstack/v1beta1/cluster-template-subdomain/cloudstack-cluster.yaml new file mode 100644 index 00000000..7580bd59 --- /dev/null +++ b/test/e2e/data/infrastructure-cloudstack/v1beta1/cluster-template-subdomain/cloudstack-cluster.yaml @@ -0,0 +1,14 @@ +apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 +kind: CloudStackCluster +metadata: + name: ${CLUSTER_NAME} +spec: + zones: + - name : ${CLOUDSTACK_ZONE_NAME} + network: + name: ${CLOUDSTACK_NETWORK_NAME} + account: ${CLOUDSTACK_SUBDOMAIN_ACCOUNT_NAME} + domain: ${CLOUDSTACK_SUBDOMAIN_PATH} + controlPlaneEndpoint: + host: ${CLUSTER_ENDPOINT_IP} + port: ${CLUSTER_ENDPOINT_PORT} \ No newline at end of file diff --git a/test/e2e/data/infrastructure-cloudstack/v1beta1/cluster-template-subdomain/kustomization.yaml b/test/e2e/data/infrastructure-cloudstack/v1beta1/cluster-template-subdomain/kustomization.yaml new file mode 100644 index 00000000..9953367a --- /dev/null +++ b/test/e2e/data/infrastructure-cloudstack/v1beta1/cluster-template-subdomain/kustomization.yaml @@ -0,0 +1,7 @@ +bases: + - ../bases/cluster-with-kcp.yaml + - ../bases/md.yaml + +patchesStrategicMerge: +- ./cloudstack-cluster.yaml +- ./md.yaml diff --git a/test/e2e/data/infrastructure-cloudstack/v1beta1/cluster-template-subdomain/md.yaml b/test/e2e/data/infrastructure-cloudstack/v1beta1/cluster-template-subdomain/md.yaml new file mode 100644 index 00000000..9082b594 --- /dev/null +++ b/test/e2e/data/infrastructure-cloudstack/v1beta1/cluster-template-subdomain/md.yaml @@ -0,0 +1,28 @@ +--- +apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 +kind: CloudStackMachineTemplate +metadata: + name: ${CLUSTER_NAME}-control-plane +spec: + template: + spec: + offering: + name: ${CLOUDSTACK_CONTROL_PLANE_MACHINE_OFFERING} + template: + name: ${CLOUDSTACK_TEMPLATE_NAME} + sshKey: ${CLOUDSTACK_SSH_KEY_NAME} + affinity: pro +--- +apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 +kind: CloudStackMachineTemplate +metadata: + name: ${CLUSTER_NAME}-md-0 +spec: + template: + spec: + offering: + name: ${CLOUDSTACK_WORKER_MACHINE_OFFERING} + template: + name: ${CLOUDSTACK_TEMPLATE_NAME} + sshKey: ${CLOUDSTACK_SSH_KEY_NAME} + affinity: pro diff --git a/test/e2e/node_drain_timeout.go b/test/e2e/node_drain_timeout.go index fc682eb2..083a1a0f 100644 --- a/test/e2e/node_drain_timeout.go +++ b/test/e2e/node_drain_timeout.go @@ -92,6 +92,9 @@ func NodeDrainTimeoutSpec(ctx context.Context, inputGetter func() CommonSpecInpu By("Add a deployment with unevictable pods and podDisruptionBudget to the workload cluster. The deployed pods cannot be evicted in the node draining process.") workloadClusterProxy := input.BootstrapClusterProxy.GetWorkloadCluster(ctx, cluster.Namespace, cluster.Name) + workloadKubeconfigPath := workloadClusterProxy.GetKubeconfigPath() + Byf("workload cluster kubeconfig path %s", workloadKubeconfigPath) + framework.DeployUnevictablePod(ctx, framework.DeployUnevictablePodInput{ WorkloadClusterProxy: workloadClusterProxy, DeploymentName: fmt.Sprintf("%s-%s", "unevictable-pod", util.RandomString(3)), diff --git a/test/e2e/subdomain.go b/test/e2e/subdomain.go new file mode 100644 index 00000000..e07ff5db --- /dev/null +++ b/test/e2e/subdomain.go @@ -0,0 +1,87 @@ +/* +Copyright 2020 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" + "os" + "path/filepath" + + . "github.com/onsi/ginkgo" + . "github.com/onsi/gomega" + corev1 "k8s.io/api/core/v1" + "k8s.io/utils/pointer" + + "sigs.k8s.io/cluster-api/test/framework/clusterctl" + "sigs.k8s.io/cluster-api/util" +) + +// SubdomainSpec implements a test that verifies that an app deployed to the workload cluster works. +func SubdomainSpec(ctx context.Context, inputGetter func() CommonSpecInput) { + var ( + specName = "subdomain" + input CommonSpecInput + namespace *corev1.Namespace + cancelWatches context.CancelFunc + clusterResources *clusterctl.ApplyClusterTemplateAndWaitResult + ) + + BeforeEach(func() { + Expect(ctx).NotTo(BeNil(), "ctx is required for %s spec", specName) + input = inputGetter() + Expect(input.E2EConfig).ToNot(BeNil(), "Invalid argument. input.E2EConfig can't be nil when calling %s spec", specName) + Expect(input.ClusterctlConfigPath).To(BeAnExistingFile(), "Invalid argument. input.ClusterctlConfigPath must be an existing file when calling %s spec", specName) + Expect(input.BootstrapClusterProxy).ToNot(BeNil(), "Invalid argument. input.BootstrapClusterProxy can't be nil when calling %s spec", specName) + Expect(os.MkdirAll(input.ArtifactFolder, 0750)).To(Succeed(), "Invalid argument. input.ArtifactFolder can't be created for %s spec", specName) + + Expect(input.E2EConfig.Variables).To(HaveKey(KubernetesVersion)) + + // Setup a Namespace where to host objects for this spec and create a watcher for the namespace events. + namespace, cancelWatches = setupSpecNamespace(ctx, specName, input.BootstrapClusterProxy, input.ArtifactFolder) + clusterResources = new(clusterctl.ApplyClusterTemplateAndWaitResult) + }) + + It("Should create a cluster in a subdomain", func() { + clusterctl.ApplyClusterTemplateAndWait(ctx, clusterctl.ApplyClusterTemplateAndWaitInput{ + ClusterProxy: input.BootstrapClusterProxy, + CNIManifestPath: input.E2EConfig.GetVariable(CNIPath), + ConfigCluster: clusterctl.ConfigClusterInput{ + LogFolder: filepath.Join(input.ArtifactFolder, "clusters", input.BootstrapClusterProxy.GetName()), + ClusterctlConfigPath: input.ClusterctlConfigPath, + KubeconfigPath: input.BootstrapClusterProxy.GetKubeconfigPath(), + InfrastructureProvider: clusterctl.DefaultInfrastructureProvider, + Flavor: specName, + Namespace: namespace.Name, + ClusterName: fmt.Sprintf("%s-%s", specName, util.RandomString(6)), + KubernetesVersion: input.E2EConfig.GetVariable(KubernetesVersion), + ControlPlaneMachineCount: pointer.Int64Ptr(1), + WorkerMachineCount: pointer.Int64Ptr(1), + }, + WaitForClusterIntervals: input.E2EConfig.GetIntervals(specName, "wait-cluster"), + WaitForControlPlaneIntervals: input.E2EConfig.GetIntervals(specName, "wait-control-plane"), + WaitForMachineDeployments: input.E2EConfig.GetIntervals(specName, "wait-worker-nodes"), + }, clusterResources) + + By("PASSED!") + }) + + AfterEach(func() { + // Dumps all the resources in the spec namespace, then cleanups the cluster object and the spec namespace itself. + dumpSpecResourcesAndCleanup(ctx, specName, input.BootstrapClusterProxy, input.ArtifactFolder, namespace, cancelWatches, clusterResources.Cluster, input.E2EConfig.GetIntervals, input.SkipCleanup) + }) +} diff --git a/test/e2e/subdomain_test.go b/test/e2e/subdomain_test.go new file mode 100644 index 00000000..4f5143ad --- /dev/null +++ b/test/e2e/subdomain_test.go @@ -0,0 +1,38 @@ +//go:build e2e +// +build e2e + +/* +Copyright 2020 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" + . "github.com/onsi/ginkgo" +) + +var _ = Describe("When testing subdomain", func() { + SubdomainSpec(context.TODO(), func() CommonSpecInput { + return CommonSpecInput{ + E2EConfig: e2eConfig, + ClusterctlConfigPath: clusterctlConfigPath, + BootstrapClusterProxy: bootstrapClusterProxy, + ArtifactFolder: artifactFolder, + SkipCleanup: skipCleanup, + } + }) + +}) From 6ed691d7e3daab3485ee6fd23e4813a8352fea0e Mon Sep 17 00:00:00 2001 From: Wonkun Kim Date: Fri, 20 May 2022 10:02:25 -0500 Subject: [PATCH 2/6] Do not specify IP address for tests with isolated network --- test/e2e/README.md | 2 -- test/e2e/config/cloudstack.yaml | 2 -- .../v1beta1/bases/cluster-with-kcp.yaml | 4 ++-- .../cluster-template-invalid-account/cloudstack-cluster.yaml | 4 ++-- .../cluster-template-invalid-domain/cloudstack-cluster.yaml | 4 ++-- .../cluster-template-invalid-zone/cloudstack-cluster.yaml | 4 ++-- .../cluster-template-resource-cleanup/cloudstack-cluster.yaml | 2 +- .../cluster-template-second-cluster/cloudstack-cluster.yaml | 2 +- .../cluster-with-shared-network-and-kubevip.yaml | 2 +- .../cluster-template-subdomain/cloudstack-cluster.yaml | 4 ++-- 10 files changed, 13 insertions(+), 17 deletions(-) diff --git a/test/e2e/README.md b/test/e2e/README.md index 2b847a90..cb474370 100644 --- a/test/e2e/README.md +++ b/test/e2e/README.md @@ -27,9 +27,7 @@ The first step to running the e2e tests is setting up the required environment v | `CLOUDSTACK_ZONE_NAME` | The zone name | `zone1` | | `CLOUDSTACK_NETWORK_NAME` | The network name. If not exisiting an isolated network with the name is created. | `Shared1` | | `CLUSTER_ENDPOINT_IP` | The cluster endpoint IP | `172.16.2.199` | -| `CLUSTER_ENDPOINT_PORT` | The cluster endpoint port | `6443` | | `CLUSTER_ENDPOINT_IP_2` | The cluster endpoint IP for a second cluster | `172.16.2.199` | -| `CLUSTER_ENDPOINT_PORT_2` | The cluster endpoint port for a second cluster | `6444` | | `CLOUDSTACK_CONTROL_PLANE_MACHINE_OFFERING` | The machine offering for the control plane VM instances | `Large Instance` | | `CLOUDSTACK_WORKER_MACHINE_OFFERING` | The machine offering for the worker node VM instances | `Medium Instance` | | `CLOUDSTACK_TEMPLATE_NAME` | The machine template for both control plane and worke node VM instances | `kube-v1.20.10/ubuntu-2004` | diff --git a/test/e2e/config/cloudstack.yaml b/test/e2e/config/cloudstack.yaml index 97836fc0..b7ccd70a 100644 --- a/test/e2e/config/cloudstack.yaml +++ b/test/e2e/config/cloudstack.yaml @@ -121,8 +121,6 @@ variables: CLOUDSTACK_SHARED_NETWORK_NAME: Shared1 CLUSTER_ENDPOINT_IP: 172.16.2.199 CLUSTER_ENDPOINT_IP_2: 172.16.2.198 - CLUSTER_ENDPOINT_PORT: 6443 - CLUSTER_ENDPOINT_PORT_2: 6443 CLOUDSTACK_CONTROL_PLANE_MACHINE_OFFERING: "Large Instance" CLOUDSTACK_INVALID_CONTROL_PLANE_MACHINE_OFFERING: "OfferingXXXX" CLOUDSTACK_EXTREMELY_LARGE_CONTROL_PLANE_MACHINE_OFFERING: "Extremely Large Instance" diff --git a/test/e2e/data/infrastructure-cloudstack/v1beta1/bases/cluster-with-kcp.yaml b/test/e2e/data/infrastructure-cloudstack/v1beta1/bases/cluster-with-kcp.yaml index 9650b5cf..c4726072 100644 --- a/test/e2e/data/infrastructure-cloudstack/v1beta1/bases/cluster-with-kcp.yaml +++ b/test/e2e/data/infrastructure-cloudstack/v1beta1/bases/cluster-with-kcp.yaml @@ -28,8 +28,8 @@ spec: network: name: ${CLOUDSTACK_NETWORK_NAME} controlPlaneEndpoint: - host: ${CLUSTER_ENDPOINT_IP} - port: ${CLUSTER_ENDPOINT_PORT} + host: "" + port: 6443 --- kind: KubeadmControlPlane apiVersion: controlplane.cluster.x-k8s.io/v1beta1 diff --git a/test/e2e/data/infrastructure-cloudstack/v1beta1/cluster-template-invalid-account/cloudstack-cluster.yaml b/test/e2e/data/infrastructure-cloudstack/v1beta1/cluster-template-invalid-account/cloudstack-cluster.yaml index b7dab957..6a94c057 100644 --- a/test/e2e/data/infrastructure-cloudstack/v1beta1/cluster-template-invalid-account/cloudstack-cluster.yaml +++ b/test/e2e/data/infrastructure-cloudstack/v1beta1/cluster-template-invalid-account/cloudstack-cluster.yaml @@ -10,5 +10,5 @@ spec: account: ${CLOUDSTACK_INVALID_ACCOUNT_NAME} domain: ${CLOUDSTACK_DOMAIN_NAME} controlPlaneEndpoint: - host: ${CLUSTER_ENDPOINT_IP} - port: ${CLUSTER_ENDPOINT_PORT} \ No newline at end of file + host: "" + port: 6443 diff --git a/test/e2e/data/infrastructure-cloudstack/v1beta1/cluster-template-invalid-domain/cloudstack-cluster.yaml b/test/e2e/data/infrastructure-cloudstack/v1beta1/cluster-template-invalid-domain/cloudstack-cluster.yaml index 935dd892..ec9f35c5 100644 --- a/test/e2e/data/infrastructure-cloudstack/v1beta1/cluster-template-invalid-domain/cloudstack-cluster.yaml +++ b/test/e2e/data/infrastructure-cloudstack/v1beta1/cluster-template-invalid-domain/cloudstack-cluster.yaml @@ -10,5 +10,5 @@ spec: account: ${CLOUDSTACK_ACCOUNT_NAME} domain: ${CLOUDSTACK_INVALID_DOMAIN_NAME} controlPlaneEndpoint: - host: ${CLUSTER_ENDPOINT_IP} - port: ${CLUSTER_ENDPOINT_PORT} \ No newline at end of file + host: "" + port: 6443 diff --git a/test/e2e/data/infrastructure-cloudstack/v1beta1/cluster-template-invalid-zone/cloudstack-cluster.yaml b/test/e2e/data/infrastructure-cloudstack/v1beta1/cluster-template-invalid-zone/cloudstack-cluster.yaml index 37ca1428..4b652ef3 100644 --- a/test/e2e/data/infrastructure-cloudstack/v1beta1/cluster-template-invalid-zone/cloudstack-cluster.yaml +++ b/test/e2e/data/infrastructure-cloudstack/v1beta1/cluster-template-invalid-zone/cloudstack-cluster.yaml @@ -8,5 +8,5 @@ spec: network: name: ${CLOUDSTACK_NETWORK_NAME} controlPlaneEndpoint: - host: ${CLUSTER_ENDPOINT_IP} - port: ${CLUSTER_ENDPOINT_PORT} \ No newline at end of file + host: "" + port: 6443 \ No newline at end of file diff --git a/test/e2e/data/infrastructure-cloudstack/v1beta1/cluster-template-resource-cleanup/cloudstack-cluster.yaml b/test/e2e/data/infrastructure-cloudstack/v1beta1/cluster-template-resource-cleanup/cloudstack-cluster.yaml index 8c237cef..3d1b1f49 100644 --- a/test/e2e/data/infrastructure-cloudstack/v1beta1/cluster-template-resource-cleanup/cloudstack-cluster.yaml +++ b/test/e2e/data/infrastructure-cloudstack/v1beta1/cluster-template-resource-cleanup/cloudstack-cluster.yaml @@ -9,4 +9,4 @@ spec: name: ${CLOUDSTACK_NEW_NETWORK_NAME} controlPlaneEndpoint: host: "" - port: ${CLUSTER_ENDPOINT_PORT} \ No newline at end of file + port: 6443 diff --git a/test/e2e/data/infrastructure-cloudstack/v1beta1/cluster-template-second-cluster/cloudstack-cluster.yaml b/test/e2e/data/infrastructure-cloudstack/v1beta1/cluster-template-second-cluster/cloudstack-cluster.yaml index 985b3fe4..b8fe7a78 100644 --- a/test/e2e/data/infrastructure-cloudstack/v1beta1/cluster-template-second-cluster/cloudstack-cluster.yaml +++ b/test/e2e/data/infrastructure-cloudstack/v1beta1/cluster-template-second-cluster/cloudstack-cluster.yaml @@ -11,4 +11,4 @@ spec: domain: ${CLOUDSTACK_DOMAIN_NAME} controlPlaneEndpoint: host: ${CLUSTER_ENDPOINT_IP_2} - port: ${CLUSTER_ENDPOINT_PORT_2} \ No newline at end of file + port: 6443 diff --git a/test/e2e/data/infrastructure-cloudstack/v1beta1/cluster-template-shared-network-kubevip/cluster-with-shared-network-and-kubevip.yaml b/test/e2e/data/infrastructure-cloudstack/v1beta1/cluster-template-shared-network-kubevip/cluster-with-shared-network-and-kubevip.yaml index 405b3b10..0d2667ec 100644 --- a/test/e2e/data/infrastructure-cloudstack/v1beta1/cluster-template-shared-network-kubevip/cluster-with-shared-network-and-kubevip.yaml +++ b/test/e2e/data/infrastructure-cloudstack/v1beta1/cluster-template-shared-network-kubevip/cluster-with-shared-network-and-kubevip.yaml @@ -29,7 +29,7 @@ spec: name: ${CLOUDSTACK_SHARED_NETWORK_NAME} controlPlaneEndpoint: host: ${CLUSTER_ENDPOINT_IP} - port: ${CLUSTER_ENDPOINT_PORT} + port: 6443 --- kind: KubeadmControlPlane apiVersion: controlplane.cluster.x-k8s.io/v1beta1 diff --git a/test/e2e/data/infrastructure-cloudstack/v1beta1/cluster-template-subdomain/cloudstack-cluster.yaml b/test/e2e/data/infrastructure-cloudstack/v1beta1/cluster-template-subdomain/cloudstack-cluster.yaml index 7580bd59..fbada517 100644 --- a/test/e2e/data/infrastructure-cloudstack/v1beta1/cluster-template-subdomain/cloudstack-cluster.yaml +++ b/test/e2e/data/infrastructure-cloudstack/v1beta1/cluster-template-subdomain/cloudstack-cluster.yaml @@ -10,5 +10,5 @@ spec: account: ${CLOUDSTACK_SUBDOMAIN_ACCOUNT_NAME} domain: ${CLOUDSTACK_SUBDOMAIN_PATH} controlPlaneEndpoint: - host: ${CLUSTER_ENDPOINT_IP} - port: ${CLUSTER_ENDPOINT_PORT} \ No newline at end of file + host: "" + port: 6443 From 3ed31ffd14be2f485ae372e78c03c65b491efc20 Mon Sep 17 00:00:00 2001 From: Wonkun Kim Date: Fri, 20 May 2022 13:09:21 -0500 Subject: [PATCH 3/6] Fix invalid domain/account tests Add error messages when failing --- pkg/cloud/user_credentials.go | 2 ++ test/e2e/common.go | 18 +++++++++--------- test/e2e/invalid_resource.go | 2 +- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/pkg/cloud/user_credentials.go b/pkg/cloud/user_credentials.go index 878d87b5..1fac33ec 100644 --- a/pkg/cloud/user_credentials.go +++ b/pkg/cloud/user_credentials.go @@ -140,6 +140,8 @@ func (c *client) ResolveAccount(account *Account) error { resp, retErr := c.cs.Account.ListAccounts(p) if retErr != nil { return retErr + } else if resp.Count == 0 { + return errors.Errorf("could not find account %s", account.Name) } else if resp.Count != 1 { return errors.Errorf("expected 1 Account with account name %s in domain ID %s, but got %d", account.Name, account.Domain.ID, resp.Count) diff --git a/test/e2e/common.go b/test/e2e/common.go index 81068517..9d128e61 100644 --- a/test/e2e/common.go +++ b/test/e2e/common.go @@ -206,7 +206,7 @@ func DestroyOneMachine(clusterName string, machineType string) { Byf("Listing machines with %q", matcher) listResp, err := client.VirtualMachine.ListVirtualMachines(client.VirtualMachine.NewListVirtualMachinesParams()) if err != nil { - Fail("Failed to list machines") + Fail("Failed to list machines: " + err.Error()) } var vmToDestroy *cloudstack.VirtualMachine originalCount := 0 @@ -224,13 +224,13 @@ func DestroyOneMachine(clusterName string, machineType string) { stopParams.SetForced(true) _, err = client.VirtualMachine.StopVirtualMachine(stopParams) if err != nil { - Fail("Failed to stop machine") + Fail("Failed to stop machine: " + err.Error()) } destroyParams := client.VirtualMachine.NewDestroyVirtualMachineParams(vmToDestroy.Id) destroyParams.SetExpunge(true) _, err = client.VirtualMachine.DestroyVirtualMachine(destroyParams) if err != nil { - Fail("Failed to destroy machine") + Fail("Failed to destroy machine: " + err.Error()) } } @@ -252,7 +252,7 @@ func CheckAffinityGroup(clusterName string, affinityType string) []string { By("Listing all machines") listResp, err := client.VirtualMachine.ListVirtualMachines(client.VirtualMachine.NewListVirtualMachinesParams()) if err != nil { - Fail("Failed to list machines") + Fail("Failed to list machines: " + err.Error()) } affinityTypeString := strings.Title(fmt.Sprintf("%sAffinity", affinityType)) cpHostIdSet := make(map[string]bool) @@ -271,7 +271,7 @@ func CheckAffinityGroup(clusterName string, affinityType string) []string { affinityIds = append(affinityIds, affinity.Id) affinity, _, _ := client.AffinityGroup.GetAffinityGroupByID(affinity.Id) if err != nil { - Fail("Failed to get affinity group for " + affinity.Id) + Fail("Failed to get affinity group for " + affinity.Id + " : " + err.Error()) } if !strings.Contains(affinity.Name, affinityTypeString) { Fail(affinity.Name + " does not contain " + affinityTypeString) @@ -307,11 +307,11 @@ func createCloudStackClient() *cloudstack.CloudStackClient { encodedSecret := os.Getenv("CLOUDSTACK_B64ENCODED_SECRET") secret, err := base64.StdEncoding.DecodeString(encodedSecret) if err != nil { - Fail("Failed ") + Fail("Failed to decode: " + err.Error()) } cfg := &cloudConfig{VerifySSL: true} if rawCfg, err := ini.Load(secret); err != nil { - Fail("Failed to load INI file") + Fail("Failed to load INI file: " + err.Error()) } else if g := rawCfg.Section("Global"); len(g.Keys()) == 0 { Fail("Global section not found") } else if err = rawCfg.Section("Global").StrictMapTo(cfg); err != nil { @@ -448,7 +448,7 @@ func CheckDiskOfferingOfVmInstances(clusterName string, diskOfferingName string) Byf("Listing machines with %q", clusterName) listResp, err := client.VirtualMachine.ListVirtualMachines(client.VirtualMachine.NewListVirtualMachinesParams()) if err != nil { - Fail("Failed to list machines") + Fail("Failed to list machines: " + err.Error()) } for _, vm := range listResp.VirtualMachines { if strings.Contains(vm.Name, clusterName) { @@ -462,7 +462,7 @@ func CheckVolumeSizeofVmInstances(clusterName string, volumeSize int64) { Byf("Listing machines with %q", clusterName) listResp, err := client.VirtualMachine.ListVirtualMachines(client.VirtualMachine.NewListVirtualMachinesParams()) if err != nil { - Fail("Failed to list machines") + Fail("Failed to list machines: " + err.Error()) } for _, vm := range listResp.VirtualMachines { if strings.Contains(vm.Name, clusterName) { diff --git a/test/e2e/invalid_resource.go b/test/e2e/invalid_resource.go index 1c3681a1..a312dbdb 100644 --- a/test/e2e/invalid_resource.go +++ b/test/e2e/invalid_resource.go @@ -66,7 +66,7 @@ func InvalidResourceSpec(ctx context.Context, inputGetter func() CommonSpecInput }) It("Should fail due to the specified domain is not found [TC4b]", func() { - testInvalidResource(ctx, input, "invalid-domain", "domain not found for domain path "+input.E2EConfig.GetVariable(InvalidDomainName)) + testInvalidResource(ctx, input, "invalid-domain", "domain not found for domain path")) }) It("Should fail due to the specified control plane offering is not found [TC7]", func() { From 159812b29460f138e25c03a1b5ac32f7d71c44b7 Mon Sep 17 00:00:00 2001 From: Wonkun Kim Date: Mon, 23 May 2022 11:53:10 -0500 Subject: [PATCH 4/6] Fix a compile error --- test/e2e/invalid_resource.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/e2e/invalid_resource.go b/test/e2e/invalid_resource.go index a312dbdb..c2ae3adf 100644 --- a/test/e2e/invalid_resource.go +++ b/test/e2e/invalid_resource.go @@ -66,7 +66,7 @@ func InvalidResourceSpec(ctx context.Context, inputGetter func() CommonSpecInput }) It("Should fail due to the specified domain is not found [TC4b]", func() { - testInvalidResource(ctx, input, "invalid-domain", "domain not found for domain path")) + testInvalidResource(ctx, input, "invalid-domain", "domain not found for domain path") }) It("Should fail due to the specified control plane offering is not found [TC7]", func() { From 7e0b08894415feadbdec5e5db76a11b44983775e Mon Sep 17 00:00:00 2001 From: Wonkun Kim Date: Tue, 24 May 2022 02:18:55 -0500 Subject: [PATCH 5/6] Fix logical error in affinity group and subdomain tests --- test/e2e/affinity_group.go | 11 ++++------- test/e2e/common.go | 8 +++++++- test/e2e/subdomain.go | 9 ++++++++- 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/test/e2e/affinity_group.go b/test/e2e/affinity_group.go index b6d1dafc..ab23cb00 100644 --- a/test/e2e/affinity_group.go +++ b/test/e2e/affinity_group.go @@ -58,11 +58,11 @@ func AffinityGroupSpec(ctx context.Context, inputGetter func() CommonSpecInput) }) It("Should have host affinity group when affinity is pro", func() { - executeTest(ctx, input, namespace, specName, clusterResources, "pro") + affinityIds = executeTest(ctx, input, namespace, specName, clusterResources, "pro") }) It("Should have host affinity group when affinity is anti", func() { - executeTest(ctx, input, namespace, specName, clusterResources, "anti") + affinityIds = executeTest(ctx, input, namespace, specName, clusterResources, "anti") }) AfterEach(func() { @@ -73,6 +73,7 @@ func AffinityGroupSpec(ctx context.Context, inputGetter func() CommonSpecInput) if err != nil { Fail(err.Error()) } + By("PASSED!") }) } @@ -97,9 +98,5 @@ func executeTest(ctx context.Context, input CommonSpecInput, namespace *corev1.N WaitForMachineDeployments: input.E2EConfig.GetIntervals(specName, "wait-worker-nodes"), }, clusterResources) - affinityIds := CheckAffinityGroup(clusterResources.Cluster.Name, affinityType) - - By("PASSED!") - - return affinityIds + return CheckAffinityGroup(clusterResources.Cluster.Name, affinityType) } diff --git a/test/e2e/common.go b/test/e2e/common.go index 9d128e61..75b6552a 100644 --- a/test/e2e/common.go +++ b/test/e2e/common.go @@ -235,6 +235,10 @@ func DestroyOneMachine(clusterName string, machineType string) { } func CheckAffinityGroupsDeleted(affinityIds []string) error { + if len(affinityIds) == 0 { + return errors.New("affinityIds are empty") + } + client := createCloudStackClient() for _, affinityId := range affinityIds { @@ -250,7 +254,9 @@ func CheckAffinityGroup(clusterName string, affinityType string) []string { client := createCloudStackClient() By("Listing all machines") - listResp, err := client.VirtualMachine.ListVirtualMachines(client.VirtualMachine.NewListVirtualMachinesParams()) + p := client.VirtualMachine.NewListVirtualMachinesParams() + p.SetListall(true) + listResp, err := client.VirtualMachine.ListVirtualMachines(p) if err != nil { Fail("Failed to list machines: " + err.Error()) } diff --git a/test/e2e/subdomain.go b/test/e2e/subdomain.go index e07ff5db..6993c6a3 100644 --- a/test/e2e/subdomain.go +++ b/test/e2e/subdomain.go @@ -39,6 +39,7 @@ func SubdomainSpec(ctx context.Context, inputGetter func() CommonSpecInput) { namespace *corev1.Namespace cancelWatches context.CancelFunc clusterResources *clusterctl.ApplyClusterTemplateAndWaitResult + affinityIds []string ) BeforeEach(func() { @@ -77,11 +78,17 @@ func SubdomainSpec(ctx context.Context, inputGetter func() CommonSpecInput) { WaitForMachineDeployments: input.E2EConfig.GetIntervals(specName, "wait-worker-nodes"), }, clusterResources) - By("PASSED!") + affinityIds = CheckAffinityGroup(clusterResources.Cluster.Name, "pro") }) AfterEach(func() { // Dumps all the resources in the spec namespace, then cleanups the cluster object and the spec namespace itself. dumpSpecResourcesAndCleanup(ctx, specName, input.BootstrapClusterProxy, input.ArtifactFolder, namespace, cancelWatches, clusterResources.Cluster, input.E2EConfig.GetIntervals, input.SkipCleanup) + + err := CheckAffinityGroupsDeleted(affinityIds) + if err != nil { + Fail(err.Error()) + } + By("PASSED!") }) } From 548d8493b06b53664c090c75dca9eee1661d9a88 Mon Sep 17 00:00:00 2001 From: Joshua Reed Date: Tue, 17 May 2022 09:25:41 -0700 Subject: [PATCH 6/6] Fixup ginkgo targets. --- Makefile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index d3a49e0a..b0754fa4 100644 --- a/Makefile +++ b/Makefile @@ -145,10 +145,11 @@ bin/golangci-lint: ## Install golangci-lint to bin. GOBIN=$(PROJECT_DIR)/bin go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.46.0 bin/staticcheck: ## Install staticcheck to bin. GOBIN=$(PROJECT_DIR)/bin go install honnef.co/go/tools/cmd/staticcheck@v0.3.1 -bin/ginkgo: ## Install ginkgo to bin. +bin/ginkgo: bin/ginkgo_v1 bin/ginkgo_v2 ## Install ginkgo to bin. +bin/ginkgo_v2: GOBIN=$(PROJECT_DIR)/bin go install github.com/onsi/ginkgo/v2/ginkgo@v2.1.4 mv $(PROJECT_DIR)/bin/ginkgo $(PROJECT_DIR)/bin/ginkgo_v2 -bin/ginkgo_v1: ## Install ginkgo to bin. +bin/ginkgo_v1: GOBIN=$(PROJECT_DIR)/bin go install github.com/onsi/ginkgo/ginkgo@v1.16.5 mv $(PROJECT_DIR)/bin/ginkgo $(PROJECT_DIR)/bin/ginkgo_v1 bin/mockgen: