Skip to content

Commit 7918d6e

Browse files
authored
Merge pull request #99 from aws/add-sub-domain-e2e-test
Add sub domain e2e test and fix some failing tests
2 parents 0468705 + 7e0b088 commit 7918d6e

File tree

19 files changed

+225
-38
lines changed

19 files changed

+225
-38
lines changed

pkg/cloud/user_credentials.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,8 @@ func (c *client) ResolveAccount(account *Account) error {
140140
resp, retErr := c.cs.Account.ListAccounts(p)
141141
if retErr != nil {
142142
return retErr
143+
} else if resp.Count == 0 {
144+
return errors.Errorf("could not find account %s", account.Name)
143145
} else if resp.Count != 1 {
144146
return errors.Errorf("expected 1 Account with account name %s in domain ID %s, but got %d",
145147
account.Name, account.Domain.ID, resp.Count)

test/e2e/README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,7 @@ The first step to running the e2e tests is setting up the required environment v
2727
| `CLOUDSTACK_ZONE_NAME` | The zone name | `zone1` |
2828
| `CLOUDSTACK_NETWORK_NAME` | The network name. If not exisiting an isolated network with the name is created. | `Shared1` |
2929
| `CLUSTER_ENDPOINT_IP` | The cluster endpoint IP | `172.16.2.199` |
30-
| `CLUSTER_ENDPOINT_PORT` | The cluster endpoint port | `6443` |
3130
| `CLUSTER_ENDPOINT_IP_2` | The cluster endpoint IP for a second cluster | `172.16.2.199` |
32-
| `CLUSTER_ENDPOINT_PORT_2` | The cluster endpoint port for a second cluster | `6444` |
3331
| `CLOUDSTACK_CONTROL_PLANE_MACHINE_OFFERING` | The machine offering for the control plane VM instances | `Large Instance` |
3432
| `CLOUDSTACK_WORKER_MACHINE_OFFERING` | The machine offering for the worker node VM instances | `Medium Instance` |
3533
| `CLOUDSTACK_TEMPLATE_NAME` | The machine template for both control plane and worke node VM instances | `kube-v1.20.10/ubuntu-2004` |

test/e2e/affinity_group.go

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,11 @@ func AffinityGroupSpec(ctx context.Context, inputGetter func() CommonSpecInput)
5858
})
5959

6060
It("Should have host affinity group when affinity is pro", func() {
61-
executeTest(ctx, input, namespace, specName, clusterResources, "pro")
61+
affinityIds = executeTest(ctx, input, namespace, specName, clusterResources, "pro")
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")
66-
executeTest(ctx, input, namespace, specName, clusterResources, "anti")
65+
affinityIds = executeTest(ctx, input, namespace, specName, clusterResources, "anti")
6766
})
6867

6968
AfterEach(func() {
@@ -74,6 +73,7 @@ func AffinityGroupSpec(ctx context.Context, inputGetter func() CommonSpecInput)
7473
if err != nil {
7574
Fail(err.Error())
7675
}
76+
By("PASSED!")
7777
})
7878
}
7979

@@ -90,17 +90,13 @@ func executeTest(ctx context.Context, input CommonSpecInput, namespace *corev1.N
9090
Namespace: namespace.Name,
9191
ClusterName: fmt.Sprintf("%s-%s", specName, util.RandomString(6)),
9292
KubernetesVersion: input.E2EConfig.GetVariable(KubernetesVersion),
93-
ControlPlaneMachineCount: pointer.Int64Ptr(3),
94-
WorkerMachineCount: pointer.Int64Ptr(3),
93+
ControlPlaneMachineCount: pointer.Int64Ptr(1),
94+
WorkerMachineCount: pointer.Int64Ptr(1),
9595
},
9696
WaitForClusterIntervals: input.E2EConfig.GetIntervals(specName, "wait-cluster"),
9797
WaitForControlPlaneIntervals: input.E2EConfig.GetIntervals(specName, "wait-control-plane"),
9898
WaitForMachineDeployments: input.E2EConfig.GetIntervals(specName, "wait-worker-nodes"),
9999
}, clusterResources)
100100

101-
affinityIds := CheckAffinityGroup(clusterResources.Cluster.Name, affinityType)
102-
103-
By("PASSED!")
104-
105-
return affinityIds
101+
return CheckAffinityGroup(clusterResources.Cluster.Name, affinityType)
106102
}

test/e2e/common.go

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ func DestroyOneMachine(clusterName string, machineType string) {
206206
Byf("Listing machines with %q", matcher)
207207
listResp, err := client.VirtualMachine.ListVirtualMachines(client.VirtualMachine.NewListVirtualMachinesParams())
208208
if err != nil {
209-
Fail("Failed to list machines")
209+
Fail("Failed to list machines: " + err.Error())
210210
}
211211
var vmToDestroy *cloudstack.VirtualMachine
212212
originalCount := 0
@@ -224,17 +224,21 @@ func DestroyOneMachine(clusterName string, machineType string) {
224224
stopParams.SetForced(true)
225225
_, err = client.VirtualMachine.StopVirtualMachine(stopParams)
226226
if err != nil {
227-
Fail("Failed to stop machine")
227+
Fail("Failed to stop machine: " + err.Error())
228228
}
229229
destroyParams := client.VirtualMachine.NewDestroyVirtualMachineParams(vmToDestroy.Id)
230230
destroyParams.SetExpunge(true)
231231
_, err = client.VirtualMachine.DestroyVirtualMachine(destroyParams)
232232
if err != nil {
233-
Fail("Failed to destroy machine")
233+
Fail("Failed to destroy machine: " + err.Error())
234234
}
235235
}
236236

237237
func CheckAffinityGroupsDeleted(affinityIds []string) error {
238+
if len(affinityIds) == 0 {
239+
return errors.New("affinityIds are empty")
240+
}
241+
238242
client := createCloudStackClient()
239243

240244
for _, affinityId := range affinityIds {
@@ -250,9 +254,11 @@ func CheckAffinityGroup(clusterName string, affinityType string) []string {
250254
client := createCloudStackClient()
251255

252256
By("Listing all machines")
253-
listResp, err := client.VirtualMachine.ListVirtualMachines(client.VirtualMachine.NewListVirtualMachinesParams())
257+
p := client.VirtualMachine.NewListVirtualMachinesParams()
258+
p.SetListall(true)
259+
listResp, err := client.VirtualMachine.ListVirtualMachines(p)
254260
if err != nil {
255-
Fail("Failed to list machines")
261+
Fail("Failed to list machines: " + err.Error())
256262
}
257263
affinityTypeString := strings.Title(fmt.Sprintf("%sAffinity", affinityType))
258264
cpHostIdSet := make(map[string]bool)
@@ -271,7 +277,7 @@ func CheckAffinityGroup(clusterName string, affinityType string) []string {
271277
affinityIds = append(affinityIds, affinity.Id)
272278
affinity, _, _ := client.AffinityGroup.GetAffinityGroupByID(affinity.Id)
273279
if err != nil {
274-
Fail("Failed to get affinity group for " + affinity.Id)
280+
Fail("Failed to get affinity group for " + affinity.Id + " : " + err.Error())
275281
}
276282
if !strings.Contains(affinity.Name, affinityTypeString) {
277283
Fail(affinity.Name + " does not contain " + affinityTypeString)
@@ -307,11 +313,11 @@ func createCloudStackClient() *cloudstack.CloudStackClient {
307313
encodedSecret := os.Getenv("CLOUDSTACK_B64ENCODED_SECRET")
308314
secret, err := base64.StdEncoding.DecodeString(encodedSecret)
309315
if err != nil {
310-
Fail("Failed ")
316+
Fail("Failed to decode: " + err.Error())
311317
}
312318
cfg := &cloudConfig{VerifySSL: true}
313319
if rawCfg, err := ini.Load(secret); err != nil {
314-
Fail("Failed to load INI file")
320+
Fail("Failed to load INI file: " + err.Error())
315321
} else if g := rawCfg.Section("Global"); len(g.Keys()) == 0 {
316322
Fail("Global section not found")
317323
} else if err = rawCfg.Section("Global").StrictMapTo(cfg); err != nil {
@@ -448,7 +454,7 @@ func CheckDiskOfferingOfVmInstances(clusterName string, diskOfferingName string)
448454
Byf("Listing machines with %q", clusterName)
449455
listResp, err := client.VirtualMachine.ListVirtualMachines(client.VirtualMachine.NewListVirtualMachinesParams())
450456
if err != nil {
451-
Fail("Failed to list machines")
457+
Fail("Failed to list machines: " + err.Error())
452458
}
453459
for _, vm := range listResp.VirtualMachines {
454460
if strings.Contains(vm.Name, clusterName) {
@@ -462,7 +468,7 @@ func CheckVolumeSizeofVmInstances(clusterName string, volumeSize int64) {
462468
Byf("Listing machines with %q", clusterName)
463469
listResp, err := client.VirtualMachine.ListVirtualMachines(client.VirtualMachine.NewListVirtualMachinesParams())
464470
if err != nil {
465-
Fail("Failed to list machines")
471+
Fail("Failed to list machines: " + err.Error())
466472
}
467473
for _, vm := range listResp.VirtualMachines {
468474
if strings.Contains(vm.Name, clusterName) {

test/e2e/config/cloudstack.yaml

Lines changed: 4 additions & 3 deletions
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,9 +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
124-
CLUSTER_ENDPOINT_PORT: 6443
125-
CLUSTER_ENDPOINT_PORT_2: 6443
126124
CLOUDSTACK_CONTROL_PLANE_MACHINE_OFFERING: "Large Instance"
127125
CLOUDSTACK_INVALID_CONTROL_PLANE_MACHINE_OFFERING: "OfferingXXXX"
128126
CLOUDSTACK_EXTREMELY_LARGE_CONTROL_PLANE_MACHINE_OFFERING: "Extremely Large Instance"
@@ -140,6 +138,9 @@ variables:
140138
CLOUDSTACK_DISK_OFFERING_LABEL: my_disk
141139
CLOUDSTACK_DISK_OFFERING_MOUNT_PATH: /my_disk
142140

141+
CLOUDSTACK_SUBDOMAIN_PATH: SUBDOMAIN
142+
CLOUDSTACK_SUBDOMAIN_ACCOUNT_NAME: SUBDOMAIN-ADMIN
143+
143144
CONFORMANCE_CONFIGURATION: "./data/kubetest/conformance.yaml"
144145
CONFORMANCE_WORKER_MACHINE_COUNT: "3"
145146
CONFORMANCE_CONTROL_PLANE_MACHINE_COUNT: "1"

test/e2e/data/infrastructure-cloudstack/v1beta1/bases/cluster-with-kcp.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ spec:
2828
network:
2929
name: ${CLOUDSTACK_NETWORK_NAME}
3030
controlPlaneEndpoint:
31-
host: ${CLUSTER_ENDPOINT_IP}
32-
port: ${CLUSTER_ENDPOINT_PORT}
31+
host: ""
32+
port: 6443
3333
---
3434
kind: KubeadmControlPlane
3535
apiVersion: controlplane.cluster.x-k8s.io/v1beta1

test/e2e/data/infrastructure-cloudstack/v1beta1/cluster-template-invalid-account/cloudstack-cluster.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@ spec:
1010
account: ${CLOUDSTACK_INVALID_ACCOUNT_NAME}
1111
domain: ${CLOUDSTACK_DOMAIN_NAME}
1212
controlPlaneEndpoint:
13-
host: ${CLUSTER_ENDPOINT_IP}
14-
port: ${CLUSTER_ENDPOINT_PORT}
13+
host: ""
14+
port: 6443

test/e2e/data/infrastructure-cloudstack/v1beta1/cluster-template-invalid-domain/cloudstack-cluster.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@ spec:
1010
account: ${CLOUDSTACK_ACCOUNT_NAME}
1111
domain: ${CLOUDSTACK_INVALID_DOMAIN_NAME}
1212
controlPlaneEndpoint:
13-
host: ${CLUSTER_ENDPOINT_IP}
14-
port: ${CLUSTER_ENDPOINT_PORT}
13+
host: ""
14+
port: 6443

test/e2e/data/infrastructure-cloudstack/v1beta1/cluster-template-invalid-zone/cloudstack-cluster.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ spec:
88
network:
99
name: ${CLOUDSTACK_NETWORK_NAME}
1010
controlPlaneEndpoint:
11-
host: ${CLUSTER_ENDPOINT_IP}
12-
port: ${CLUSTER_ENDPOINT_PORT}
11+
host: ""
12+
port: 6443

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

Lines changed: 2 additions & 2 deletions
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}
12-
port: ${CLUSTER_ENDPOINT_PORT}
11+
host: ""
12+
port: 6443

0 commit comments

Comments
 (0)