mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
iperf benchmark: Use container networking links rather than default bridge.
This fixes `iperf` getting stuck on some versions of Docker, and mirrors the way other multi-container tests do networking. PiperOrigin-RevId: 468049041
This commit is contained in:
committed by
gVisor bot
parent
919a20f179
commit
4b7922fa0b
@@ -15,8 +15,10 @@ package network
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"os"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"gvisor.dev/gvisor/pkg/test/dockerutil"
|
||||
"gvisor.dev/gvisor/pkg/test/testutil"
|
||||
@@ -80,20 +82,8 @@ func BenchmarkIperf(b *testing.B) {
|
||||
}, "iperf", "-s"); err != nil {
|
||||
b.Fatalf("failed to start server with: %v", err)
|
||||
}
|
||||
|
||||
ip, err := serverMachine.IPAddress()
|
||||
if err != nil {
|
||||
b.Fatalf("failed to find server ip: %v", err)
|
||||
}
|
||||
|
||||
servingPort, err := server.FindPort(ctx, port)
|
||||
if err != nil {
|
||||
b.Fatalf("failed to find port %d: %v", port, err)
|
||||
}
|
||||
|
||||
// Make sure the server is up and serving before we run.
|
||||
if err := harness.WaitUntilServing(ctx, clientMachine, ip, servingPort); err != nil {
|
||||
b.Fatalf("failed to wait for server: %v", err)
|
||||
if out, err := server.WaitForOutput(ctx, fmt.Sprintf("Server listening on TCP port %d", port), 10*time.Second); err != nil {
|
||||
b.Fatalf("failed to wait for iperf server: %v %s", err, out)
|
||||
}
|
||||
|
||||
iperf := tools.Iperf{
|
||||
@@ -104,7 +94,8 @@ func BenchmarkIperf(b *testing.B) {
|
||||
b.ResetTimer()
|
||||
out, err := client.Run(ctx, dockerutil.RunOpts{
|
||||
Image: "benchmarks/iperf",
|
||||
}, iperf.MakeCmd(ip, servingPort)...)
|
||||
Links: []string{server.MakeLink("iperfsrv")},
|
||||
}, iperf.MakeCmd("iperfsrv", port)...)
|
||||
if err != nil {
|
||||
b.Fatalf("failed to run client: %v", err)
|
||||
}
|
||||
|
||||
@@ -16,7 +16,6 @@ package tools
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"testing"
|
||||
@@ -30,14 +29,14 @@ type Iperf struct {
|
||||
}
|
||||
|
||||
// MakeCmd returns a iperf client command.
|
||||
func (i *Iperf) MakeCmd(ip net.IP, port int) []string {
|
||||
func (i *Iperf) MakeCmd(host string, port int) []string {
|
||||
return []string{
|
||||
"iperf",
|
||||
"--format", "K", // Output in KBytes.
|
||||
"--realtime", // Measured in realtime.
|
||||
"--num", fmt.Sprintf("%dK", i.Num), // Number of bytes to send in KB.
|
||||
"--length", fmt.Sprintf("%d", length),
|
||||
"--client", ip.String(),
|
||||
"--client", host,
|
||||
"--port", fmt.Sprintf("%d", port),
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user