@@ -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