Skip to content

Commit 7e0b088

Browse files
committed
Fix logical error in affinity group and subdomain tests
1 parent 159812b commit 7e0b088

File tree

3 files changed

+19
-9
lines changed

3 files changed

+19
-9
lines changed

test/e2e/affinity_group.go

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +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-
executeTest(ctx, input, namespace, specName, clusterResources, "anti")
65+
affinityIds = executeTest(ctx, input, namespace, specName, clusterResources, "anti")
6666
})
6767

6868
AfterEach(func() {
@@ -73,6 +73,7 @@ func AffinityGroupSpec(ctx context.Context, inputGetter func() CommonSpecInput)
7373
if err != nil {
7474
Fail(err.Error())
7575
}
76+
By("PASSED!")
7677
})
7778
}
7879

@@ -97,9 +98,5 @@ func executeTest(ctx context.Context, input CommonSpecInput, namespace *corev1.N
9798
WaitForMachineDeployments: input.E2EConfig.GetIntervals(specName, "wait-worker-nodes"),
9899
}, clusterResources)
99100

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

test/e2e/common.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,10 @@ func DestroyOneMachine(clusterName string, machineType string) {
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,7 +254,9 @@ 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 {
255261
Fail("Failed to list machines: " + err.Error())
256262
}

test/e2e/subdomain.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ func SubdomainSpec(ctx context.Context, inputGetter func() CommonSpecInput) {
3939
namespace *corev1.Namespace
4040
cancelWatches context.CancelFunc
4141
clusterResources *clusterctl.ApplyClusterTemplateAndWaitResult
42+
affinityIds []string
4243
)
4344

4445
BeforeEach(func() {
@@ -77,11 +78,17 @@ func SubdomainSpec(ctx context.Context, inputGetter func() CommonSpecInput) {
7778
WaitForMachineDeployments: input.E2EConfig.GetIntervals(specName, "wait-worker-nodes"),
7879
}, clusterResources)
7980

80-
By("PASSED!")
81+
affinityIds = CheckAffinityGroup(clusterResources.Cluster.Name, "pro")
8182
})
8283

8384
AfterEach(func() {
8485
// Dumps all the resources in the spec namespace, then cleanups the cluster object and the spec namespace itself.
8586
dumpSpecResourcesAndCleanup(ctx, specName, input.BootstrapClusterProxy, input.ArtifactFolder, namespace, cancelWatches, clusterResources.Cluster, input.E2EConfig.GetIntervals, input.SkipCleanup)
87+
88+
err := CheckAffinityGroupsDeleted(affinityIds)
89+
if err != nil {
90+
Fail(err.Error())
91+
}
92+
By("PASSED!")
8693
})
8794
}

0 commit comments

Comments
 (0)