Skip to content

Commit

Permalink
[IPv6] Fix after rebasing
Browse files Browse the repository at this point in the history
* format code
* fix TestPodTrafficShaping
* fix TestIPv6RoutesAndNeighbors
  • Loading branch information
lzhecheng committed Nov 11, 2020
1 parent 41a0abc commit b265cb6
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 10 deletions.
27 changes: 18 additions & 9 deletions test/e2e/bandwidth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,19 +154,28 @@ func TestPodTrafficShaping(t *testing.T) {
t.Fatalf("Error when creating the perftest server Pod: %v", err)
}
defer deletePodWrapper(t, data, serverPodName)
podBIP, err := data.podWaitForIP(defaultTimeout, serverPodName, testNamespace)
podIPs, err := data.podWaitForIPs(defaultTimeout, serverPodName, testNamespace)
if err != nil {
t.Fatalf("Error when getting the perftest server Pod's IP: %v", err)
}
stdout, _, err := data.runCommandFromPod(testNamespace, clientPodName, "perftool", []string{"bash", "-c", fmt.Sprintf("iperf3 -c %s -f m -O 1|grep sender|awk '{print $7}'", podBIP)})
if err != nil {
t.Fatalf("Error when running iperf3 client: %v", err)

runIperf := func(cmd []string) {
stdout, _, err := data.runCommandFromPod(testNamespace, clientPodName, "perftool", cmd)
if err != nil {
t.Fatalf("Error when running iperf3 client: %v", err)
}
stdout = strings.TrimSpace(stdout)
actualBandwidth, _ := strconv.ParseFloat(strings.TrimSpace(stdout), 64)
t.Logf("Actual bandwidth: %v Mbits/sec", actualBandwidth)
// Allow a certain deviation.
assert.InEpsilon(t, actualBandwidth, tt.expectedBandwidth, 0.1)
}
if podIPs.ipv4 != nil {
runIperf([]string{"bash", "-c", fmt.Sprintf("iperf3 -c %s -f m -O 1|grep sender|awk '{print $7}'", podIPs.ipv4.String())})
}
if podIPs.ipv6 != nil {
runIperf([]string{"bash", "-c", fmt.Sprintf("iperf3 -6 -c %s -f m -O 1|grep sender|awk '{print $7}'", podIPs.ipv6.String())})
}
stdout = strings.TrimSpace(stdout)
actualBandwidth, _ := strconv.ParseFloat(strings.TrimSpace(stdout), 64)
t.Logf("Actual bandwidth: %v Mbits/sec", actualBandwidth)
// Allow a certain deviation.
assert.InEpsilon(t, actualBandwidth, tt.expectedBandwidth, 0.1)
})
}
}
2 changes: 1 addition & 1 deletion test/integration/agent/route_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@ func TestIPv6RoutesAndNeighbors(t *testing.T) {
gwLink := createDummyGW(t)
defer netlink.LinkDel(gwLink)

routeClient, err := route.NewClient(serviceCIDR, config.TrafficEncapModeEncap, false)
routeClient, err := route.NewClient(serviceCIDR, &config.NetworkConfig{TrafficEncapMode: config.TrafficEncapModeEncap}, false)
assert.Nil(t, err)
_, ipv6Subnet, _ := net.ParseCIDR("fd74:ca9b:172:19::/64")
gwIPv6 := net.ParseIP("fd74:ca9b:172:19::1")
Expand Down

0 comments on commit b265cb6

Please sign in to comment.