@@ -60,7 +60,6 @@ func TestNewAndDeleteNetworkImplHnsV2(t *testing.T) {
6060 }
6161
6262 err = nm .deleteNetworkImplHnsV2 (network )
63-
6463 if err != nil {
6564 fmt .Printf ("+%v" , err )
6665 t .Fatal (err )
@@ -95,7 +94,6 @@ func TestSuccesfulNetworkCreationWhenAlreadyExists(t *testing.T) {
9594 }
9695
9796 _ , err = nm .newNetworkImplHnsV2 (nwInfo , extInterface )
98-
9997 if err != nil {
10098 fmt .Printf ("+%v" , err )
10199 t .Fatal (err )
@@ -468,7 +466,6 @@ func TestNewAndDeleteNetworkImplHnsV2ForDelegated(t *testing.T) {
468466 }
469467
470468 err = nm .deleteNetworkImpl (network , cns .NodeNetworkInterfaceFrontendNIC )
471-
472469 if err != nil {
473470 fmt .Printf ("+%v" , err )
474471 t .Fatal (err )
@@ -522,6 +519,47 @@ func TestTransparentNetworkCreationForDelegated(t *testing.T) {
522519 }
523520}
524521
522+ // Test Configure HNC network for infraNIC ensuring the hcn network type is always l2 bridge
523+ func TestConfigureHCNNetworkInfraNIC (t * testing.T ) {
524+ expectedHcnNetworkType := hcn .L2Bridge
525+
526+ nm := & networkManager {
527+ ExternalInterfaces : map [string ]* externalInterface {},
528+ }
529+
530+ extIf := externalInterface {
531+ Name : "eth0" ,
532+ }
533+
534+ nwInfo := & EndpointInfo {
535+ AdapterName : "eth0" ,
536+ NetworkID : "d3e97a83-ba4c-45d5-ba88-dc56757ece28" ,
537+ MasterIfName : "eth0" ,
538+ NICType : cns .InfraNIC ,
539+ IfIndex : 1 ,
540+ EndpointID : "753d3fb6-e9b3-49e2-a109-2acc5dda61f1" ,
541+ ContainerID : "545055c2-1462-42c8-b222-e75d0b291632" ,
542+ NetNsPath : "fakeNameSpace" ,
543+ IfName : "eth0" ,
544+ Data : make (map [string ]interface {}),
545+ EndpointDNS : DNSInfo {
546+ Suffix : "10.0.0.0" ,
547+ Servers : []string {"10.0.0.1, 10.0.0.2" },
548+ Options : nil ,
549+ },
550+ HNSNetworkID : "853d3fb6-e9b3-49e2-a109-2acc5dda61f1" ,
551+ }
552+
553+ hostComputeNetwork , err := nm .configureHcnNetwork (nwInfo , & extIf )
554+ if err != nil {
555+ t .Fatalf ("Failed to configure hcn network for infraNIC interface due to: %v" , err )
556+ }
557+
558+ if hostComputeNetwork .Type != expectedHcnNetworkType {
559+ t .Fatalf ("Host network mode is not configured as %v mode when interface NIC type is infraNIC" , expectedHcnNetworkType )
560+ }
561+ }
562+
525563// Test Configure HCN Network for Swiftv2 DelegatedNIC HostComputeNetwork fields
526564func TestConfigureHCNNetworkSwiftv2DelegatedNIC (t * testing.T ) {
527565 expectedSwiftv2NetworkMode := hcn .Transparent
0 commit comments