@@ -272,18 +272,26 @@ var _ = Describe("Multi Homing", feature.MultiHoming, func() {
272272 )
273273
274274 const (
275- clientPodName = "client-pod"
276- clientIPOffset = 100
277- serverIPOffset = 102
278- port = 9000
279- workerOneNodeName = "ovn-worker"
280- workerTwoNodeName = "ovn-worker2"
275+ clientPodName = "client-pod"
276+ clientIPOffset = 100
277+ serverIPOffset = 102
278+ port = 9000
281279 )
282280
283281 ginkgo .DescribeTable ("attached to a localnet network mapped to breth0" ,
284282
285- func (netConfigParams networkAttachmentConfigParams , clientPodConfig , serverPodConfig podConfiguration ) {
286-
283+ func (netConfigParams networkAttachmentConfigParams , clientPodConfig , serverPodConfig podConfiguration , isCollocatedPods bool ) {
284+ By ("Get two scheduable nodes and ensure client and server are located on distinct Nodes" )
285+ nodes , err := e2enode .GetBoundedReadySchedulableNodes (context .Background (), f .ClientSet , 2 )
286+ framework .ExpectNoError (err , "2 scheduable nodes are required" )
287+ Expect (len (nodes .Items )).To (BeNumerically (">=" , 1 ), "cluster should have at least 2 nodes" )
288+ if isCollocatedPods {
289+ clientPodConfig .nodeSelector = map [string ]string {nodeHostnameKey : nodes .Items [0 ].GetName ()}
290+ serverPodConfig .nodeSelector = map [string ]string {nodeHostnameKey : nodes .Items [0 ].GetName ()}
291+ } else {
292+ clientPodConfig .nodeSelector = map [string ]string {nodeHostnameKey : nodes .Items [0 ].GetName ()}
293+ serverPodConfig .nodeSelector = map [string ]string {nodeHostnameKey : nodes .Items [1 ].GetName ()}
294+ }
287295 netConfig := newNetworkAttachmentConfig (networkAttachmentConfigParams {
288296 name : secondaryNetworkName ,
289297 namespace : f .Namespace .Name ,
@@ -307,7 +315,7 @@ var _ = Describe("Multi Homing", feature.MultiHoming, func() {
307315
308316 nad := generateNAD (netConfig )
309317 By (fmt .Sprintf ("creating the attachment configuration: %v\n " , nad ))
310- _ , err : = nadClient .NetworkAttachmentDefinitions (f .Namespace .Name ).Create (
318+ _ , err = nadClient .NetworkAttachmentDefinitions (f .Namespace .Name ).Create (
311319 context .Background (),
312320 nad ,
313321 metav1.CreateOptions {},
@@ -369,7 +377,6 @@ var _ = Describe("Multi Homing", feature.MultiHoming, func() {
369377 },
370378 podConfiguration { // client on default network
371379 name : clientPodName ,
372- nodeSelector : map [string ]string {nodeHostnameKey : workerOneNodeName },
373380 isPrivileged : true ,
374381 },
375382 podConfiguration { // server attached to localnet secondary network
@@ -378,9 +385,9 @@ var _ = Describe("Multi Homing", feature.MultiHoming, func() {
378385 }},
379386 name : podName ,
380387 containerCmd : httpServerContainerCmd (port ),
381- nodeSelector : map [string ]string {nodeHostnameKey : workerTwoNodeName },
382388 needsIPRequestFromHostSubnet : true , // will override attachments above with an IPRequest
383389 },
390+ false , // scheduled on distinct Nodes
384391 Label ("BUG" , "OCPBUGS-43004" ),
385392 ),
386393 ginkgo .Entry (
@@ -391,7 +398,6 @@ var _ = Describe("Multi Homing", feature.MultiHoming, func() {
391398 },
392399 podConfiguration { // client on default network
393400 name : clientPodName + "-same-node" ,
394- nodeSelector : map [string ]string {nodeHostnameKey : workerTwoNodeName },
395401 isPrivileged : true ,
396402 },
397403 podConfiguration { // server attached to localnet secondary network
@@ -400,9 +406,9 @@ var _ = Describe("Multi Homing", feature.MultiHoming, func() {
400406 }},
401407 name : podName ,
402408 containerCmd : httpServerContainerCmd (port ),
403- nodeSelector : map [string ]string {nodeHostnameKey : workerTwoNodeName },
404409 needsIPRequestFromHostSubnet : true ,
405410 },
411+ true , // collocated on same Node
406412 Label ("BUG" , "OCPBUGS-43004" ),
407413 ),
408414 ginkgo .Entry (
@@ -416,16 +422,15 @@ var _ = Describe("Multi Homing", feature.MultiHoming, func() {
416422 Name : secondaryNetworkName ,
417423 }},
418424 name : clientPodName ,
419- nodeSelector : map [string ]string {nodeHostnameKey : workerOneNodeName },
420425 isPrivileged : true ,
421426 needsIPRequestFromHostSubnet : true ,
422427 },
423428 podConfiguration { // server on default network, pod is host-networked
424429 name : podName ,
425430 containerCmd : httpServerContainerCmd (port ),
426- nodeSelector : map [string ]string {nodeHostnameKey : workerTwoNodeName },
427431 hostNetwork : true ,
428432 },
433+ false , // not collocated on same node
429434 Label ("STORY" , "SDN-5345" ),
430435 ),
431436 ginkgo .Entry (
@@ -439,30 +444,27 @@ var _ = Describe("Multi Homing", feature.MultiHoming, func() {
439444 Name : secondaryNetworkName ,
440445 }},
441446 name : clientPodName ,
442- nodeSelector : map [string ]string {nodeHostnameKey : workerTwoNodeName },
443447 isPrivileged : true ,
444448 needsIPRequestFromHostSubnet : true ,
445449 },
446450 podConfiguration { // server on default network, pod is host-networked
447451 name : podName ,
448452 containerCmd : httpServerContainerCmd (port ),
449- nodeSelector : map [string ]string {nodeHostnameKey : workerTwoNodeName },
450453 hostNetwork : true ,
451454 },
455+ true , // collocated on same node
452456 Label ("STORY" , "SDN-5345" ),
453457 ),
454458 )
455459 })
456460
457461 Context ("multiple pods connected to the same OVN-K secondary network" , func () {
458462 const (
459- workerOneNodeName = "ovn-worker"
460- workerTwoNodeName = "ovn-worker2"
461- clientPodName = "client-pod"
462- nodeHostnameKey = "kubernetes.io/hostname"
463- port = 9000
464- clientIP = "192.168.200.10/24"
465- staticServerIP = "192.168.200.20/24"
463+ clientPodName = "client-pod"
464+ nodeHostnameKey = "kubernetes.io/hostname"
465+ port = 9000
466+ clientIP = "192.168.200.10/24"
467+ staticServerIP = "192.168.200.20/24"
466468 )
467469
468470 ginkgo .It ("eventually configures pods that were added to an already existing network before the nad" , func () {
@@ -567,6 +569,7 @@ var _ = Describe("Multi Homing", feature.MultiHoming, func() {
567569 By ("Get two scheduable nodes and schedule client and server to be on distinct Nodes" )
568570 nodes , err := e2enode .GetBoundedReadySchedulableNodes (context .Background (), f .ClientSet , 2 )
569571 framework .ExpectNoError (err , "2 scheduable nodes are required" )
572+ Expect (len (nodes .Items )).To (BeNumerically (">=" , 1 ), "cluster should have at least 2 nodes" )
570573 clientPodConfig .nodeSelector = map [string ]string {nodeHostnameKey : nodes .Items [0 ].GetName ()}
571574 serverPodConfig .nodeSelector = map [string ]string {nodeHostnameKey : nodes .Items [1 ].GetName ()}
572575
0 commit comments