Skip to content

Commit

Permalink
Fix.
Browse files Browse the repository at this point in the history
Signed-off-by: Nashwan Azhari <nazhari@cloudbasesolutions.com>
  • Loading branch information
aznashwan committed Nov 1, 2023
1 parent 11e969b commit 5cfe36f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
17 changes: 10 additions & 7 deletions test/utilities/connectivity_testing.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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")

Expand Down Expand Up @@ -284,7 +286,6 @@ func CreateGatewayEp(networkId string, ipAddress string, ipv6Adress string) erro
}
}


return nil
}

Expand Down Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions test/utilities/plugin_testing.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 5cfe36f

Please sign in to comment.