Skip to content

Commit 0f6c9b2

Browse files
Added Network checks
1 parent 71667a7 commit 0f6c9b2

File tree

2 files changed

+29
-4
lines changed

2 files changed

+29
-4
lines changed

test/e2e/config/cloudstack.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ providers:
102102
- sourcePath: "../data/infrastructure-cloudstack/v1beta3/cluster-template-kubernetes-version-upgrade-before.yaml"
103103
- sourcePath: "../data/infrastructure-cloudstack/v1beta3/cluster-template-kubernetes-version-upgrade-after.yaml"
104104
- sourcePath: "../data/infrastructure-cloudstack/v1beta3/cluster-template-k8s-cks.yaml"
105-
- sourcePath: "../data/infrastructure-cloudstack/v1beta3/cluster-template-multiple-templates.yaml"
105+
- sourcePath: "../data/infrastructure-cloudstack/v1beta3/cluster-template-multiple-networks.yaml"
106106
- sourcePath: "../data/shared/v1beta1_provider/metadata.yaml"
107107
versions:
108108
- name: v1.0.0

test/e2e/multiple_networks.go

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ func MultipleNetworksSpec(ctx context.Context, inputGetter func() CommonSpecInpu
128128
Expect(len(cluster.Virtualmachines)).Should(Equal(2), "Expected 2 VMs in the cluster, found %d", len(cluster.Virtualmachines))
129129

130130
By("Verifying that each VM has two NICs")
131-
CheckIfNodesHaveTwoNICs(cluster)
131+
CheckIfNodesHaveTwoNICs(cluster, input)
132132

133133
By("PASSED!")
134134
})
@@ -139,11 +139,36 @@ func MultipleNetworksSpec(ctx context.Context, inputGetter func() CommonSpecInpu
139139
})
140140
}
141141

142-
func CheckIfNodesHaveTwoNICs(cluster *cloudstack.KubernetesCluster) {
142+
func CheckIfNodesHaveTwoNICs(cluster *cloudstack.KubernetesCluster, input CommonSpecInput) {
143+
requiredNetworks := map[string]bool{
144+
input.E2EConfig.GetVariable("CLOUDSTACK_NETWORK_NAME"): false,
145+
input.E2EConfig.GetVariable("CLOUDSTACK_NEW_NETWORK_NAME"): false,
146+
}
147+
143148
for _, vm := range cluster.Virtualmachines {
144149
if len(vm.Nic) < 2 {
145150
Fail(fmt.Sprintf("VM %q has fewer than 2 NICs. Found: %d", vm.Name, len(vm.Nic)))
146151
}
147-
By(fmt.Sprintf("VM %q has %d NICs", vm.Name, len(vm.Nic)))
152+
153+
found := make(map[string]bool)
154+
for _, nic := range vm.Nic {
155+
found[nic.Networkname] = true
156+
}
157+
158+
for req := range requiredNetworks {
159+
if !found[req] {
160+
Fail(fmt.Sprintf("VM %q is missing required network %q", vm.Name, req))
161+
}
162+
}
163+
164+
By(fmt.Sprintf("VM %q has required NICs: %v", vm.Name, keys(found)))
165+
}
166+
}
167+
168+
func keys(m map[string]bool) []string {
169+
var list []string
170+
for k := range m {
171+
list = append(list, k)
148172
}
173+
return list
149174
}

0 commit comments

Comments
 (0)