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/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/affinity_group.go b/test/e2e/affinity_group.go index a3042bd7..ab23cb00 100644 --- a/test/e2e/affinity_group.go +++ b/test/e2e/affinity_group.go @@ -58,12 +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() { - Skip("The ACS used by Prow doesn't have multiple hosts in the target zone") - executeTest(ctx, input, namespace, specName, clusterResources, "anti") + affinityIds = executeTest(ctx, input, namespace, specName, clusterResources, "anti") }) AfterEach(func() { @@ -74,6 +73,7 @@ func AffinityGroupSpec(ctx context.Context, inputGetter func() CommonSpecInput) if err != nil { Fail(err.Error()) } + By("PASSED!") }) } @@ -90,17 +90,13 @@ 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"), 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 81068517..75b6552a 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,17 +224,21 @@ 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()) } } func CheckAffinityGroupsDeleted(affinityIds []string) error { + if len(affinityIds) == 0 { + return errors.New("affinityIds are empty") + } + client := createCloudStackClient() for _, affinityId := range affinityIds { @@ -250,9 +254,11 @@ 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") + Fail("Failed to list machines: " + err.Error()) } affinityTypeString := strings.Title(fmt.Sprintf("%sAffinity", affinityType)) cpHostIdSet := make(map[string]bool) @@ -271,7 +277,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 +313,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 +454,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 +468,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/config/cloudstack.yaml b/test/e2e/config/cloudstack.yaml index 19b9a2fa..b7ccd70a 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,9 +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" CLOUDSTACK_INVALID_CONTROL_PLANE_MACHINE_OFFERING: "OfferingXXXX" CLOUDSTACK_EXTREMELY_LARGE_CONTROL_PLANE_MACHINE_OFFERING: "Extremely Large Instance" @@ -140,6 +138,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/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 fa4e6b0a..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 @@ -8,5 +8,5 @@ spec: network: name: ${CLOUDSTACK_NEW_NETWORK_NAME} controlPlaneEndpoint: - host: ${CLUSTER_ENDPOINT_NEW_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-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 new file mode 100644 index 00000000..fbada517 --- /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: "" + port: 6443 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/invalid_resource.go b/test/e2e/invalid_resource.go index 1c3681a1..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 "+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() { 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..6993c6a3 --- /dev/null +++ b/test/e2e/subdomain.go @@ -0,0 +1,94 @@ +/* +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 + affinityIds []string + ) + + 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) + + 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!") + }) +} 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, + } + }) + +})