Skip to content

Commit e1e449e

Browse files
committed
Add subdomain e2e test
1 parent 0468705 commit e1e449e

File tree

9 files changed

+184
-5
lines changed

9 files changed

+184
-5
lines changed

test/e2e/affinity_group.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ func AffinityGroupSpec(ctx context.Context, inputGetter func() CommonSpecInput)
6262
})
6363

6464
It("Should have host affinity group when affinity is anti", func() {
65-
Skip("The ACS used by Prow doesn't have multiple hosts in the target zone")
6665
executeTest(ctx, input, namespace, specName, clusterResources, "anti")
6766
})
6867

@@ -90,8 +89,8 @@ func executeTest(ctx context.Context, input CommonSpecInput, namespace *corev1.N
9089
Namespace: namespace.Name,
9190
ClusterName: fmt.Sprintf("%s-%s", specName, util.RandomString(6)),
9291
KubernetesVersion: input.E2EConfig.GetVariable(KubernetesVersion),
93-
ControlPlaneMachineCount: pointer.Int64Ptr(3),
94-
WorkerMachineCount: pointer.Int64Ptr(3),
92+
ControlPlaneMachineCount: pointer.Int64Ptr(1),
93+
WorkerMachineCount: pointer.Int64Ptr(1),
9594
},
9695
WaitForClusterIntervals: input.E2EConfig.GetIntervals(specName, "wait-cluster"),
9796
WaitForControlPlaneIntervals: input.E2EConfig.GetIntervals(specName, "wait-control-plane"),

test/e2e/config/cloudstack.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ providers:
9292
- sourcePath: "../data/infrastructure-cloudstack/v1beta1/cluster-template-invalid-disk-offering-size-for-customized.yaml"
9393
- sourcePath: "../data/infrastructure-cloudstack/v1beta1/cluster-template-disk-offering.yaml"
9494
- sourcePath: "../data/infrastructure-cloudstack/v1beta1/cluster-template-custom-disk-offering.yaml"
95+
- sourcePath: "../data/infrastructure-cloudstack/v1beta1/cluster-template-subdomain.yaml"
9596
- sourcePath: "../data/shared/v1beta1/metadata.yaml"
9697
versions:
9798
- name: v1.0.0
@@ -120,7 +121,6 @@ variables:
120121
CLOUDSTACK_SHARED_NETWORK_NAME: Shared1
121122
CLUSTER_ENDPOINT_IP: 172.16.2.199
122123
CLUSTER_ENDPOINT_IP_2: 172.16.2.198
123-
CLUSTER_ENDPOINT_NEW_IP: 172.16.2.201
124124
CLUSTER_ENDPOINT_PORT: 6443
125125
CLUSTER_ENDPOINT_PORT_2: 6443
126126
CLOUDSTACK_CONTROL_PLANE_MACHINE_OFFERING: "Large Instance"
@@ -140,6 +140,9 @@ variables:
140140
CLOUDSTACK_DISK_OFFERING_LABEL: my_disk
141141
CLOUDSTACK_DISK_OFFERING_MOUNT_PATH: /my_disk
142142

143+
CLOUDSTACK_SUBDOMAIN_PATH: SUBDOMAIN
144+
CLOUDSTACK_SUBDOMAIN_ACCOUNT_NAME: SUBDOMAIN-ADMIN
145+
143146
CONFORMANCE_CONFIGURATION: "./data/kubetest/conformance.yaml"
144147
CONFORMANCE_WORKER_MACHINE_COUNT: "3"
145148
CONFORMANCE_CONTROL_PLANE_MACHINE_COUNT: "1"

test/e2e/data/infrastructure-cloudstack/v1beta1/cluster-template-resource-cleanup/cloudstack-cluster.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ spec:
88
network:
99
name: ${CLOUDSTACK_NEW_NETWORK_NAME}
1010
controlPlaneEndpoint:
11-
host: ${CLUSTER_ENDPOINT_NEW_IP}
11+
host: ""
1212
port: ${CLUSTER_ENDPOINT_PORT}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
2+
kind: CloudStackCluster
3+
metadata:
4+
name: ${CLUSTER_NAME}
5+
spec:
6+
zones:
7+
- name : ${CLOUDSTACK_ZONE_NAME}
8+
network:
9+
name: ${CLOUDSTACK_NETWORK_NAME}
10+
account: ${CLOUDSTACK_SUBDOMAIN_ACCOUNT_NAME}
11+
domain: ${CLOUDSTACK_SUBDOMAIN_PATH}
12+
controlPlaneEndpoint:
13+
host: ${CLUSTER_ENDPOINT_IP}
14+
port: ${CLUSTER_ENDPOINT_PORT}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
bases:
2+
- ../bases/cluster-with-kcp.yaml
3+
- ../bases/md.yaml
4+
5+
patchesStrategicMerge:
6+
- ./cloudstack-cluster.yaml
7+
- ./md.yaml
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
---
2+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
3+
kind: CloudStackMachineTemplate
4+
metadata:
5+
name: ${CLUSTER_NAME}-control-plane
6+
spec:
7+
template:
8+
spec:
9+
offering:
10+
name: ${CLOUDSTACK_CONTROL_PLANE_MACHINE_OFFERING}
11+
template:
12+
name: ${CLOUDSTACK_TEMPLATE_NAME}
13+
sshKey: ${CLOUDSTACK_SSH_KEY_NAME}
14+
affinity: pro
15+
---
16+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
17+
kind: CloudStackMachineTemplate
18+
metadata:
19+
name: ${CLUSTER_NAME}-md-0
20+
spec:
21+
template:
22+
spec:
23+
offering:
24+
name: ${CLOUDSTACK_WORKER_MACHINE_OFFERING}
25+
template:
26+
name: ${CLOUDSTACK_TEMPLATE_NAME}
27+
sshKey: ${CLOUDSTACK_SSH_KEY_NAME}
28+
affinity: pro

test/e2e/node_drain_timeout.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,9 @@ func NodeDrainTimeoutSpec(ctx context.Context, inputGetter func() CommonSpecInpu
9292

9393
By("Add a deployment with unevictable pods and podDisruptionBudget to the workload cluster. The deployed pods cannot be evicted in the node draining process.")
9494
workloadClusterProxy := input.BootstrapClusterProxy.GetWorkloadCluster(ctx, cluster.Namespace, cluster.Name)
95+
workloadKubeconfigPath := workloadClusterProxy.GetKubeconfigPath()
96+
Byf("workload cluster kubeconfig path %s", workloadKubeconfigPath)
97+
9598
framework.DeployUnevictablePod(ctx, framework.DeployUnevictablePodInput{
9699
WorkloadClusterProxy: workloadClusterProxy,
97100
DeploymentName: fmt.Sprintf("%s-%s", "unevictable-pod", util.RandomString(3)),

test/e2e/subdomain.go

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
/*
2+
Copyright 2020 The Kubernetes Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package e2e
18+
19+
import (
20+
"context"
21+
"fmt"
22+
"os"
23+
"path/filepath"
24+
25+
. "github.com/onsi/ginkgo"
26+
. "github.com/onsi/gomega"
27+
corev1 "k8s.io/api/core/v1"
28+
"k8s.io/utils/pointer"
29+
30+
"sigs.k8s.io/cluster-api/test/framework/clusterctl"
31+
"sigs.k8s.io/cluster-api/util"
32+
)
33+
34+
// SubdomainSpec implements a test that verifies that an app deployed to the workload cluster works.
35+
func SubdomainSpec(ctx context.Context, inputGetter func() CommonSpecInput) {
36+
var (
37+
specName = "subdomain"
38+
input CommonSpecInput
39+
namespace *corev1.Namespace
40+
cancelWatches context.CancelFunc
41+
clusterResources *clusterctl.ApplyClusterTemplateAndWaitResult
42+
)
43+
44+
BeforeEach(func() {
45+
Expect(ctx).NotTo(BeNil(), "ctx is required for %s spec", specName)
46+
input = inputGetter()
47+
Expect(input.E2EConfig).ToNot(BeNil(), "Invalid argument. input.E2EConfig can't be nil when calling %s spec", specName)
48+
Expect(input.ClusterctlConfigPath).To(BeAnExistingFile(), "Invalid argument. input.ClusterctlConfigPath must be an existing file when calling %s spec", specName)
49+
Expect(input.BootstrapClusterProxy).ToNot(BeNil(), "Invalid argument. input.BootstrapClusterProxy can't be nil when calling %s spec", specName)
50+
Expect(os.MkdirAll(input.ArtifactFolder, 0750)).To(Succeed(), "Invalid argument. input.ArtifactFolder can't be created for %s spec", specName)
51+
52+
Expect(input.E2EConfig.Variables).To(HaveKey(KubernetesVersion))
53+
54+
// Setup a Namespace where to host objects for this spec and create a watcher for the namespace events.
55+
namespace, cancelWatches = setupSpecNamespace(ctx, specName, input.BootstrapClusterProxy, input.ArtifactFolder)
56+
clusterResources = new(clusterctl.ApplyClusterTemplateAndWaitResult)
57+
})
58+
59+
It("Should create a cluster in a subdomain", func() {
60+
clusterctl.ApplyClusterTemplateAndWait(ctx, clusterctl.ApplyClusterTemplateAndWaitInput{
61+
ClusterProxy: input.BootstrapClusterProxy,
62+
CNIManifestPath: input.E2EConfig.GetVariable(CNIPath),
63+
ConfigCluster: clusterctl.ConfigClusterInput{
64+
LogFolder: filepath.Join(input.ArtifactFolder, "clusters", input.BootstrapClusterProxy.GetName()),
65+
ClusterctlConfigPath: input.ClusterctlConfigPath,
66+
KubeconfigPath: input.BootstrapClusterProxy.GetKubeconfigPath(),
67+
InfrastructureProvider: clusterctl.DefaultInfrastructureProvider,
68+
Flavor: specName,
69+
Namespace: namespace.Name,
70+
ClusterName: fmt.Sprintf("%s-%s", specName, util.RandomString(6)),
71+
KubernetesVersion: input.E2EConfig.GetVariable(KubernetesVersion),
72+
ControlPlaneMachineCount: pointer.Int64Ptr(1),
73+
WorkerMachineCount: pointer.Int64Ptr(1),
74+
},
75+
WaitForClusterIntervals: input.E2EConfig.GetIntervals(specName, "wait-cluster"),
76+
WaitForControlPlaneIntervals: input.E2EConfig.GetIntervals(specName, "wait-control-plane"),
77+
WaitForMachineDeployments: input.E2EConfig.GetIntervals(specName, "wait-worker-nodes"),
78+
}, clusterResources)
79+
80+
By("PASSED!")
81+
})
82+
83+
AfterEach(func() {
84+
// Dumps all the resources in the spec namespace, then cleanups the cluster object and the spec namespace itself.
85+
dumpSpecResourcesAndCleanup(ctx, specName, input.BootstrapClusterProxy, input.ArtifactFolder, namespace, cancelWatches, clusterResources.Cluster, input.E2EConfig.GetIntervals, input.SkipCleanup)
86+
})
87+
}

test/e2e/subdomain_test.go

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
//go:build e2e
2+
// +build e2e
3+
4+
/*
5+
Copyright 2020 The Kubernetes Authors.
6+
7+
Licensed under the Apache License, Version 2.0 (the "License");
8+
you may not use this file except in compliance with the License.
9+
You may obtain a copy of the License at
10+
11+
http://www.apache.org/licenses/LICENSE-2.0
12+
13+
Unless required by applicable law or agreed to in writing, software
14+
distributed under the License is distributed on an "AS IS" BASIS,
15+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
See the License for the specific language governing permissions and
17+
limitations under the License.
18+
*/
19+
20+
package e2e
21+
22+
import (
23+
"context"
24+
. "github.com/onsi/ginkgo"
25+
)
26+
27+
var _ = Describe("When testing subdomain", func() {
28+
SubdomainSpec(context.TODO(), func() CommonSpecInput {
29+
return CommonSpecInput{
30+
E2EConfig: e2eConfig,
31+
ClusterctlConfigPath: clusterctlConfigPath,
32+
BootstrapClusterProxy: bootstrapClusterProxy,
33+
ArtifactFolder: artifactFolder,
34+
SkipCleanup: skipCleanup,
35+
}
36+
})
37+
38+
})

0 commit comments

Comments
 (0)