import (
"fmt"
- "time"
. "fd.io/hs-test/infra"
- . "github.com/onsi/ginkgo/v2"
)
func init() {
serverIpAddress := s.Interfaces.Server.Ip4AddressString()
clientIpAddress := s.Interfaces.Client.Ip4AddressString()
- clnCh := make(chan error)
- stopServerCh := make(chan struct{})
- srvCh := make(chan error, 1)
- clnRes := make(chan []byte, 1)
-
- defer func() {
- stopServerCh <- struct{}{}
- }()
-
- go func() {
- defer GinkgoRecover()
- cmd := "iperf3 -4 -s -B " + serverIpAddress + " -p " + s.Ports.Port1
- s.StartServerApp(s.Containers.Server, "iperf3", cmd, srvCh, stopServerCh)
- }()
- err := <-srvCh
- s.AssertNil(err, fmt.Sprint(err))
+ cmd := fmt.Sprintf("iperf3 -4 -s -1 -D -B %s -p %s --logfile %s",
+ serverIpAddress, s.Ports.Port1, s.IperfLogFileName(s.Containers.Server))
+ o, err := s.Containers.Server.Exec(false, cmd)
+ s.AssertNil(err, o)
s.Log("server running")
- go func() {
- defer GinkgoRecover()
- cmd := "iperf3 -c " + serverIpAddress + " -B " + clientIpAddress +
- " -u -l 1460 -b 10g -J -p " + s.Ports.Port1
- s.StartClientApp(s.Containers.Client, cmd, clnCh, clnRes)
- }()
- s.AssertChannelClosed(time.Minute*3, clnCh)
- output := <-clnRes
- result := s.ParseJsonIperfOutput(output)
+ cmd = "iperf3 -c " + serverIpAddress + " -B " + clientIpAddress +
+ " -u -l 1460 -b 10g -J -p " + s.Ports.Port1
+ o, err = s.Containers.Client.Exec(false, cmd)
+
+ s.AssertNil(err, o)
+ result := s.ParseJsonIperfOutput([]byte(o))
s.LogJsonIperfOutput(result)
s.AssertIperfMinTransfer(result, 400)
}
func ldPreloadIperf(s *LdpSuite, extraClientArgs string) IPerfResult {
serverVethAddress := s.Interfaces.Server.Ip4AddressString()
- stopServerCh := make(chan struct{}, 1)
- srvCh := make(chan error, 1)
- clnCh := make(chan error)
- clnRes := make(chan []byte, 1)
- defer func() {
- stopServerCh <- struct{}{}
- }()
+ cmd := fmt.Sprintf("sh -c \"iperf3 -4 -s -1 -D -B %s -p %s --logfile %s\"",
+ serverVethAddress, s.Ports.Port1, s.IperfLogFileName(s.Containers.ServerApp))
+ o, err := s.Containers.ServerApp.Exec(true, cmd)
+ s.AssertNil(err, o)
- go func() {
- defer GinkgoRecover()
- cmd := fmt.Sprintf("sh -c \"iperf3 -4 -s -B %s -p %s > %s 2>&1\"", serverVethAddress, s.Ports.Port1, s.IperfLogFileName(s.Containers.ServerApp))
- s.StartServerApp(s.Containers.ServerApp, "iperf3", cmd, srvCh, stopServerCh)
- }()
-
- err := <-srvCh
- s.AssertNil(err, fmt.Sprint(err))
-
- go func() {
- defer GinkgoRecover()
- cmd := fmt.Sprintf("iperf3 -c %s -B %s -l 1460 -b 10g -J -p %s %s", serverVethAddress, s.Interfaces.Client.Ip4AddressString(), s.Ports.Port1, extraClientArgs)
- s.StartClientApp(s.Containers.ClientApp, cmd, clnCh, clnRes)
- }()
+ cmd = fmt.Sprintf("iperf3 -c %s -B %s -l 1460 -b 10g -J -p %s %s", serverVethAddress, s.Interfaces.Client.Ip4AddressString(), s.Ports.Port1, extraClientArgs)
+ o, err = s.Containers.ClientApp.Exec(true, cmd)
- s.AssertChannelClosed(time.Minute*4, clnCh)
- output := <-clnRes
- result := s.ParseJsonIperfOutput(output)
+ s.AssertNil(err, o)
+ result := s.ParseJsonIperfOutput([]byte(o))
s.LogJsonIperfOutput(result)
return result
proto = ""
}
- stopServerCh := make(chan struct{}, 1)
- srvCh := make(chan error, 1)
- clnCh := make(chan error)
- clnRes := make(chan []byte, 1)
+ cmd := fmt.Sprintf("iperf3 -4 -s -1 -D -B %s -p %s --logfile %s",
+ s.ServerAddr(), fmt.Sprint(s.Ports.Server), s.IperfLogFileName(s.Containers.IperfS))
+ o, err := s.Containers.IperfS.Exec(true, cmd)
- defer func() {
- stopServerCh <- struct{}{}
- }()
-
- go func() {
- defer GinkgoRecover()
- cmd := fmt.Sprintf("iperf3 -4 -s -B %s -p %s --logfile %s", s.ServerAddr(), fmt.Sprint(s.Ports.Server), s.IperfLogFileName(s.Containers.IperfS))
- s.StartServerApp(s.Containers.IperfS, "iperf3", cmd, srvCh, stopServerCh)
- }()
+ s.AssertNil(err, o)
- err := <-srvCh
- s.AssertNil(err, fmt.Sprint(err))
+ cmd = fmt.Sprintf("iperf3 -c %s -P 4 -l 1460 -b 10g -J -p %d -B %s %s",
+ s.VppProxyAddr(), s.Ports.Proxy, s.ClientAddr(), proto)
- go func() {
- defer GinkgoRecover()
- cmd := fmt.Sprintf("iperf3 -c %s -P 4 -l 1460 -b 10g -J -p %d -B %s %s", s.VppProxyAddr(), s.Ports.Proxy, s.ClientAddr(), proto)
- s.StartClientApp(s.Containers.IperfC, cmd, clnCh, clnRes)
- }()
+ o, err = s.Containers.IperfC.Exec(true, cmd)
- s.AssertChannelClosed(time.Minute*4, clnCh)
- result := s.ParseJsonIperfOutput(<-clnRes)
+ s.AssertNil(err, o)
+ result := s.ParseJsonIperfOutput([]byte(o))
s.LogJsonIperfOutput(result)
s.AssertIperfMinTransfer(result, 200)
}
s.ProxyClientConnect("tcp", s.Ports.Nginx)
clientVpp := s.Containers.VppClient.VppInstance
- stopServerCh := make(chan struct{})
- srvCh := make(chan error, 1)
-
- defer func() {
- stopServerCh <- struct{}{}
- }()
-
- go func() {
- defer GinkgoRecover()
- c := "iperf3 -s -B " + s.NginxAddr() + " -p " + s.Ports.Nginx
- s.StartServerApp(s.Containers.IperfServer, "iperf3", c, srvCh, stopServerCh)
- }()
- err := <-srvCh
- s.AssertNil(err, fmt.Sprint(err))
- s.Log("server running")
+ c := fmt.Sprintf("iperf3 -s -1 -D -B %s -p %s --logfile %s",
+ s.NginxAddr(), s.Ports.Nginx, s.IperfLogFileName(s.Containers.IperfServer))
+ o, err := s.Containers.IperfServer.Exec(true, c)
+ s.AssertNil(err, o)
finished := make(chan error, 1)
go func() {
// test listen all, we are running solo anyway
s.ProxyClientConnect("udp", "0")
clientVpp := s.Containers.VppClient.VppInstance
- cmd := fmt.Sprintf("http connect proxy client listener add listener tcp://0.0.0.0:0")
+ cmd := "http connect proxy client listener add listener tcp://0.0.0.0:0"
s.Log(clientVpp.Vppctl(cmd))
- stopServerCh := make(chan struct{})
- srvCh := make(chan error, 1)
-
- defer func() {
- stopServerCh <- struct{}{}
- }()
-
- go func() {
- defer GinkgoRecover()
- c := "iperf3 -s -B " + s.NginxAddr() + " -p " + s.Ports.Nginx
- s.StartServerApp(s.Containers.IperfServer, "iperf3", c, srvCh, stopServerCh)
- }()
- err := <-srvCh
- s.AssertNil(err, fmt.Sprint(err))
- s.Log("server running")
+ c := fmt.Sprintf("iperf3 -s -1 -D -B %s -p %s --logfile %s",
+ s.NginxAddr(), s.Ports.Nginx, s.IperfLogFileName(s.Containers.IperfServer))
+ o, err := s.Containers.IperfServer.Exec(true, c)
+ s.AssertNil(err, o)
finished := make(chan error, 1)
go func() {
VppConnectProxyIperfUdpTest(s)
clientVpp := s.Containers.VppClient.VppInstance
closed := false
- for nTries := 0; nTries < 60; nTries++ {
+ for range 60 {
o := clientVpp.Vppctl("show http connect proxy client sessions")
if !strings.Contains(o, "] tcp ") {
closed = true