@@ -128,7 +128,7 @@ func MultipleNetworksSpec(ctx context.Context, inputGetter func() CommonSpecInpu
128
128
Expect (len (cluster .Virtualmachines )).Should (Equal (2 ), "Expected 2 VMs in the cluster, found %d" , len (cluster .Virtualmachines ))
129
129
130
130
By ("Verifying that each VM has two NICs" )
131
- CheckIfNodesHaveTwoNICs (cluster )
131
+ CheckIfNodesHaveTwoNICs (cluster , input )
132
132
133
133
By ("PASSED!" )
134
134
})
@@ -139,11 +139,36 @@ func MultipleNetworksSpec(ctx context.Context, inputGetter func() CommonSpecInpu
139
139
})
140
140
}
141
141
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
+
143
148
for _ , vm := range cluster .Virtualmachines {
144
149
if len (vm .Nic ) < 2 {
145
150
Fail (fmt .Sprintf ("VM %q has fewer than 2 NICs. Found: %d" , vm .Name , len (vm .Nic )))
146
151
}
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 )
148
172
}
173
+ return list
149
174
}
0 commit comments