@@ -592,3 +592,75 @@ func TestTransparentNetworkCreationForDelegated(t *testing.T) {
592592 t .Fatal ("network creation does not return error" )
593593 }
594594}
595+
596+ // Test Configure HCN Network for Swiftv2 DelegatedNIC HostComputeNetwork fields
597+ func TestConfigureHCNNetworkSwiftv2DelegatedNIC (t * testing.T ) {
598+ expectedSwiftv2NetworkMode := hcn .Transparent
599+ expectedSwifv2NetworkFlags := hcn .EnableNonPersistent | hcn .DisableHostPort
600+
601+ nm := & networkManager {
602+ ExternalInterfaces : map [string ]* externalInterface {},
603+ }
604+
605+ extIf := externalInterface {
606+ Name : "eth1" ,
607+ }
608+
609+ nwInfo := & EndpointInfo {
610+ AdapterName : "eth1" ,
611+ NetworkID : "d3e97a83-ba4c-45d5-ba88-dc56757ece28" ,
612+ MasterIfName : "eth1" ,
613+ Mode : "bridge" ,
614+ NICType : cns .NodeNetworkInterfaceFrontendNIC ,
615+ }
616+
617+ hostComputeNetwork , err := nm .configureHcnNetwork (nwInfo , & extIf )
618+ if err != nil {
619+ t .Fatalf ("Failed to configure hcn network for delegatedVMNIC interface due to: %v" , err )
620+ }
621+
622+ if hostComputeNetwork .Type != expectedSwiftv2NetworkMode {
623+ t .Fatalf ("host network mode is not configured as %v mode when interface NIC type is delegatedVMNIC" , expectedSwiftv2NetworkMode )
624+ }
625+
626+ // make sure network type is transparent and flags is 1032
627+ if hostComputeNetwork .Flags != expectedSwifv2NetworkFlags {
628+ t .Fatalf ("host network flags is not configured as %v when interface NIC type is delegatedVMNIC" , expectedSwifv2NetworkFlags )
629+ }
630+ }
631+
632+ // Test Configure HCN Network for Swiftv2 AccelnetNIC HostComputeNetwork fields
633+ func TestConfigureHCNNetworkSwiftv2AccelnetNIC (t * testing.T ) {
634+ expectedSwiftv2NetworkMode := hcn .Transparent
635+ expectedSwifv2NetworkFlags := hcn .EnableNonPersistent | hcn .DisableHostPort | hcn .EnableIov
636+
637+ nm := & networkManager {
638+ ExternalInterfaces : map [string ]* externalInterface {},
639+ }
640+
641+ extIf := externalInterface {
642+ Name : "eth1" ,
643+ }
644+
645+ nwInfo := & EndpointInfo {
646+ AdapterName : "eth1" ,
647+ NetworkID : "d3e97a83-ba4c-45d5-ba88-dc56757ece28" ,
648+ MasterIfName : "eth1" ,
649+ Mode : "bridge" ,
650+ NICType : cns .NodeNetworkInterfaceAccelnetFrontendNIC ,
651+ }
652+
653+ hostComputeNetwork , err := nm .configureHcnNetwork (nwInfo , & extIf )
654+ if err != nil {
655+ t .Fatalf ("Failed to configure hcn network for accelnetNIC interface due to: %v" , err )
656+ }
657+
658+ if hostComputeNetwork .Type != expectedSwiftv2NetworkMode {
659+ t .Fatalf ("host network mode is not configured as %v mode when interface NIC type is accelnetNIC" , expectedSwiftv2NetworkMode )
660+ }
661+
662+ // make sure network type is transparent and flags is 9224
663+ if hostComputeNetwork .Flags != expectedSwifv2NetworkFlags {
664+ t .Fatalf ("host network flags is not configured as %v when interface NIC type is accelnetNIC" , expectedSwifv2NetworkFlags )
665+ }
666+ }
0 commit comments