From: Adrian Villin Date: Tue, 7 Oct 2025 13:09:41 +0000 (-0400) Subject: hs-test: run iperf server as daemon X-Git-Url: https://gerrit.fd.io/r/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F65%2F43765%2F2;p=vpp.git hs-test: run iperf server as daemon Type: test Change-Id: I325accfa89a6ae7cf69b29cd9a471fc859696999 Signed-off-by: Adrian Villin --- diff --git a/test-c/hs-test/iperf_linux_test.go b/test-c/hs-test/iperf_linux_test.go index 0505f644f31..be2ee64eee5 100644 --- a/test-c/hs-test/iperf_linux_test.go +++ b/test-c/hs-test/iperf_linux_test.go @@ -2,10 +2,8 @@ package main import ( "fmt" - "time" . "fd.io/hs-test/infra" - . "github.com/onsi/ginkgo/v2" ) func init() { @@ -16,33 +14,18 @@ func IperfUdpLinuxTest(s *IperfSuite) { 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) } diff --git a/test-c/hs-test/ldp_test.go b/test-c/hs-test/ldp_test.go index 94abafc9fb1..737e9b54c80 100644 --- a/test-c/hs-test/ldp_test.go +++ b/test-c/hs-test/ldp_test.go @@ -90,33 +90,17 @@ func LdpIperfUdpTest(s *LdpSuite) { 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 diff --git a/test-c/hs-test/proxy_test.go b/test-c/hs-test/proxy_test.go index 5d9fc389392..53d2ae4e93f 100644 --- a/test-c/hs-test/proxy_test.go +++ b/test-c/hs-test/proxy_test.go @@ -70,32 +70,19 @@ func vppProxyIperfMWTest(s *VppProxySuite, proto string) { 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) } @@ -803,21 +790,10 @@ func VppConnectProxyIperfTcpTest(s *MasqueSuite) { 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() { @@ -834,24 +810,13 @@ func VppConnectProxyIperfUdpTest(s *MasqueSuite) { // 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() { @@ -878,7 +843,7 @@ func VppConnectProxyIperfUdpMWTest(s *MasqueSuite) { 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