diff --git a/test/utilities/connectivity_testing.go b/test/utilities/connectivity_testing.go index 94bc091..06776bd 100644 --- a/test/utilities/connectivity_testing.go +++ b/test/utilities/connectivity_testing.go @@ -189,7 +189,7 @@ func GetNetAdapterPolicy() *hcn.NetworkPolicy { } return &netAdapterPolicy } -func CreateGatewayEp(networkId string, ipAddress string, ipv6Adress string) error { +func CreateGatewayEp(t *testing.T, networkId string, ipAddress string, ipv6Adress string) error { gwEp := hcn.HostComputeEndpoint{ SchemaVersion: hcn.SchemaVersion{ Major: 2, @@ -253,7 +253,9 @@ func CreateGatewayEp(networkId string, ipAddress string, ipv6Adress string) erro if gatwayInterfaceName == "" { gatwayInterfaceName = DefaultGatewayInterfaceName } - vEthernetName := fmt.Sprintf(`"vEthernet (%s)"`, gatwayInterfaceName) + vEthernetName := fmt.Sprintf(`"vEthernet (%s)"`, strings.Trim(gatwayInterfaceName, `"'`)) + t.Logf("Setting up gateway endpoint %q on interface: %q", vNicName, vEthernetName) + os.Setenv("vEthernet", vEthernetName) defer os.Unsetenv("vEthernet") @@ -284,7 +286,6 @@ func CreateGatewayEp(networkId string, ipAddress string, ipv6Adress string) erro } } - return nil } @@ -322,15 +323,17 @@ func MakeTestStruct( epPolicies := []hcn.EndpointPolicy{} addArgs := []cni.KVP{} foundIf, hostIp, hostIpv6, err := GetDefaultInterface(testDualStack) + if err != nil { + t.Errorf("unable to find interface %s. Testing failed", Interface) + return nil + } + if !testDualStack { t.Logf("Interface Found: [%v] with ip [%v]", foundIf, hostIp) } else { t.Logf("Interface Found: [%v] with ipv4 [%v] ipv6 [%v]", foundIf, hostIp, hostIpv6) } - if err != nil { - t.Errorf("unable to find interface %s. Testing failed", Interface) - return nil - } + if epPols { epPolicies = getDefaultEndpointPolicies(hostIp.String(), testDualStack) addArgs = getDefaultAddArgs(hostIp.String(), testDualStack) diff --git a/test/utilities/plugin_testing.go b/test/utilities/plugin_testing.go index 9599f59..af6c887 100644 --- a/test/utilities/plugin_testing.go +++ b/test/utilities/plugin_testing.go @@ -63,9 +63,9 @@ func (pt *PluginUnitTest) Setup(t *testing.T) error { } if pt.DualStack { - err = CreateGatewayEp(pt.Network.Id, conf.AdditionalRoutes[0].GW.String(), conf.AdditionalRoutes[1].GW.String()) + err = CreateGatewayEp(t, pt.Network.Id, conf.AdditionalRoutes[0].GW.String(), conf.AdditionalRoutes[1].GW.String()) } else { - err = CreateGatewayEp(pt.Network.Id, conf.Ipam.Routes[0].GW.String(), "") + err = CreateGatewayEp(t, pt.Network.Id, conf.Ipam.Routes[0].GW.String(), "") } if err != nil {