hs-test: improvements and cleanup 94/42894/9
authorAdrian Villin <[email protected]>
Wed, 28 May 2025 14:47:49 +0000 (16:47 +0200)
committerFlorin Coras <[email protected]>
Wed, 4 Jun 2025 18:17:06 +0000 (18:17 +0000)
- removed remaining 0.0.0.0 binds
- ip address files are now removed on suite teardown
 (parallel testing should now be more reliable)
- removed unused Iperf helper functions

Type: test

Change-Id: I3af630b11a2713b3d5d2828ba6efbabfad571e1e
Signed-off-by: Adrian Villin <[email protected]>
extras/hs-test/http2_test.go
extras/hs-test/http_test.go
extras/hs-test/infra/hst_suite.go
extras/hs-test/infra/suite_envoy_proxy.go
extras/hs-test/infra/utils.go
extras/hs-test/ldp_test.go
extras/hs-test/tls_test.go
extras/hs-test/vcl_test.go

index 3ee4e9f..dc2d210 100644 (file)
@@ -63,7 +63,7 @@ func Http2TcpPostTest(s *H2Suite) {
 func Http2MultiplexingTest(s *H2Suite) {
        vpp := s.Containers.Vpp.VppInstance
        serverAddress := s.VppAddr() + ":" + s.Ports.Port1
-       vpp.Vppctl("http tps uri tcp://0.0.0.0/" + s.Ports.Port1 + " no-zc")
+       vpp.Vppctl("http tps uri tcp://" + serverAddress + " no-zc")
 
        args := fmt.Sprintf("--log-file=%s -T10 -n21 -c1 -m100 http://%s/test_file_20M", s.H2loadLogFileName(s.Containers.H2load), serverAddress)
        s.Containers.H2load.ExtraRunningArgs = args
@@ -81,7 +81,7 @@ func Http2MultiplexingTest(s *H2Suite) {
 func Http2MultiplexingMTTest(s *H2Suite) {
        vpp := s.Containers.Vpp.VppInstance
        serverAddress := s.VppAddr() + ":" + s.Ports.Port1
-       vpp.Vppctl("http tps uri tcp://0.0.0.0/" + s.Ports.Port1 + " no-zc")
+       vpp.Vppctl("http tps uri tcp://" + serverAddress + " no-zc")
 
        args := fmt.Sprintf("-T10 -n100 -c4 -r1 -m10 http://%s/test_file_20M", serverAddress)
        s.Containers.H2load.ExtraRunningArgs = args
index bbc14ed..84f0b79 100644 (file)
@@ -70,20 +70,20 @@ func HttpGetTpsInterruptModeTest(s *NoTopoSuite) {
 
 func HttpGetTpsTest(s *NoTopoSuite) {
        vpp := s.Containers.Vpp.VppInstance
-       serverAddress := s.VppAddr()
-       url := "http://" + serverAddress + ":" + s.Ports.Http + "/test_file_10M"
+       serverAddress := s.VppAddr() + ":" + s.Ports.Http
+       url := "http://" + serverAddress + "/test_file_10M"
 
-       vpp.Vppctl("http tps uri tcp://0.0.0.0/" + s.Ports.Http)
+       vpp.Vppctl("http tps uri tcp://%s", serverAddress)
 
        s.RunBenchmark("HTTP tps download 10M", 10, 0, httpDownloadBenchmark, url)
 }
 
 func HttpGetTpsTlsTest(s *NoTopoSuite) {
        vpp := s.Containers.Vpp.VppInstance
-       serverAddress := s.VppAddr()
-       url := "https://" + serverAddress + ":" + s.Ports.Http + "/test_file_10M"
+       serverAddress := s.VppAddr() + ":" + s.Ports.Http
+       url := "https://" + serverAddress + "/test_file_10M"
 
-       vpp.Vppctl("http tps uri tls://0.0.0.0/" + s.Ports.Http)
+       vpp.Vppctl("http tps uri tls://%s", serverAddress)
 
        s.RunBenchmark("HTTP tps download 10M", 10, 0, httpDownloadBenchmark, url)
 }
@@ -113,20 +113,20 @@ func HttpPostTpsInterruptModeTest(s *NoTopoSuite) {
 
 func HttpPostTpsTest(s *NoTopoSuite) {
        vpp := s.Containers.Vpp.VppInstance
-       serverAddress := s.VppAddr()
-       url := "http://" + serverAddress + ":" + s.Ports.Http + "/test_file_10M"
+       serverAddress := s.VppAddr() + ":" + s.Ports.Http
+       url := "http://" + serverAddress + "/test_file_10M"
 
-       vpp.Vppctl("http tps uri tcp://0.0.0.0/" + s.Ports.Http)
+       vpp.Vppctl("http tps uri tcp://%s", serverAddress)
 
        s.RunBenchmark("HTTP tps upload 10M", 10, 0, httpUploadBenchmark, url)
 }
 
 func HttpPostTpsTlsTest(s *NoTopoSuite) {
        vpp := s.Containers.Vpp.VppInstance
-       serverAddress := s.VppAddr()
-       url := "https://" + serverAddress + ":" + s.Ports.Http + "/test_file_10M"
+       serverAddress := s.VppAddr() + ":" + s.Ports.Http
+       url := "https://" + serverAddress + "/test_file_10M"
 
-       vpp.Vppctl("http tps uri tls://0.0.0.0/" + s.Ports.Http)
+       vpp.Vppctl("http tps uri tls://%s", serverAddress)
 
        s.RunBenchmark("HTTP tps upload 10M", 10, 0, httpUploadBenchmark, url)
 }
index 4e82272..e9d0dac 100644 (file)
@@ -66,6 +66,7 @@ var Colors = colors{
 
 // ../../src/vnet/udp/udp_local.h:foreach_udp4_dst_port
 var reservedPorts = []string{
+       "22",
        "53",
        "67",
        "68",
@@ -184,6 +185,13 @@ func (s *HstSuite) TeardownSuite() {
        s.HstCommon.TeardownSuite()
        // allow ports to be reused by removing them from reservedPorts slice
        reservedPorts = reservedPorts[:len(reservedPorts)-s.numOfNewPorts]
+       if s.Ip4AddrAllocator != nil {
+               s.Ip4AddrAllocator.DeleteIpAddresses()
+       }
+
+       if s.Ip6AddrAllocator != nil {
+               s.Ip6AddrAllocator.DeleteIpAddresses()
+       }
        defer s.LogFile.Close()
        defer s.Docker.Close()
        s.UnconfigureNetworkTopology()
@@ -194,14 +202,6 @@ func (s *HstSuite) TeardownTest() {
        coreDump := s.WaitForCoreDump()
        s.ResetContainers()
 
-       if s.Ip4AddrAllocator != nil {
-               s.Ip4AddrAllocator.DeleteIpAddresses()
-       }
-
-       if s.Ip6AddrAllocator != nil {
-               s.Ip6AddrAllocator.DeleteIpAddresses()
-       }
-
        if coreDump {
                Fail("VPP crashed")
        }
@@ -587,6 +587,7 @@ func (s *HstSuite) GeneratePort() string {
                port += "0"
        }
        port = port[len(port)-3:] + s.ProcessIndex
+       port = strings.TrimLeft(port, "0")
        for slices.Contains(reservedPorts, port) {
                portInt, err = strconv.Atoi(port)
                s.AssertNil(err)
index aac4588..a099d2c 100644 (file)
@@ -149,6 +149,8 @@ func (s *EnvoyProxySuite) SetupTest() {
        s.Containers.Vpp.VppInstance.Vppctl(arp)
        s.AssertNil(s.Containers.NginxServerTransient.Start())
        s.AssertNil(s.Containers.EnvoyProxy.Start())
+       // give envoy some time to start
+       time.Sleep(time.Second * 2)
 }
 
 func (s *EnvoyProxySuite) TeardownTest() {
index a4dec98..8be7fb5 100644 (file)
@@ -234,53 +234,6 @@ func (s *HstSuite) CollectH2loadLogs(h2loadContainer *Container) {
        }
 }
 
-func (s *HstSuite) StartIperfServerApp(running chan error, done chan struct{}, env []string) {
-       cmd := exec.Command("iperf3", "-4", "-s", "-p", s.GeneratePort())
-       if env != nil {
-               cmd.Env = env
-       }
-       s.Log(cmd)
-       err := cmd.Start()
-       if err != nil {
-               msg := fmt.Errorf("failed to start iperf server: %v", err)
-               running <- msg
-               return
-       }
-       running <- nil
-       <-done
-       cmd.Process.Kill()
-}
-
-func (s *HstSuite) StartIperfClientApp(ipAddress string, env []string, clnCh chan error, clnRes chan string) {
-       defer func() {
-               clnCh <- nil
-       }()
-
-       nTries := 0
-
-       for {
-               cmd := exec.Command("iperf3", "-c", ipAddress, "-u", "-l", "1460", "-b", "10g", "-p", s.GeneratePort())
-               if env != nil {
-                       cmd.Env = env
-               }
-               s.Log(cmd)
-               o, err := cmd.CombinedOutput()
-               if err != nil {
-                       if nTries > 5 {
-                               clnRes <- ""
-                               clnCh <- fmt.Errorf("failed to start client app '%s'.\n%s", err, o)
-                               return
-                       }
-                       time.Sleep(1 * time.Second)
-                       nTries++
-                       continue
-               } else {
-                       clnRes <- fmt.Sprintf("Client output: %s", o)
-               }
-               break
-       }
-}
-
 func (s *HstSuite) StartHttpServer(running chan struct{}, done chan struct{}, addressPort, netNs string) {
        cmd := newCommand([]string{"./http_server", addressPort, s.Ppid, s.ProcessIndex}, netNs)
        err := cmd.Start()
index c30bc27..951d58c 100644 (file)
@@ -97,7 +97,7 @@ func ldPreloadIperf(s *LdpSuite, extraClientArgs string) IPerfResult {
 
        go func() {
                defer GinkgoRecover()
-               cmd := "sh -c \"iperf3 -4 -s -p " + s.Ports.Port1 + " > " + s.IperfLogFileName(s.Containers.ServerApp) + " 2>&1\""
+               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)
        }()
 
@@ -106,7 +106,7 @@ func ldPreloadIperf(s *LdpSuite, extraClientArgs string) IPerfResult {
 
        go func() {
                defer GinkgoRecover()
-               cmd := "iperf3 -c " + serverVethAddress + " -l 1460 -b 10g -J -p " + s.Ports.Port1 + " " + extraClientArgs
+               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)
        }()
 
index 7689ef6..050bd3b 100644 (file)
@@ -9,9 +9,10 @@ func init() {
 }
 
 func TlsAlpMatchTest(s *VethsSuite) {
-       s.Log(s.Containers.ServerVpp.VppInstance.Vppctl("test alpn server alpn-proto1 2 uri tls://0.0.0.0:" + s.Ports.Port1))
+       serverAddress := s.Interfaces.Server.Ip4AddressString() + ":" + s.Ports.Port1
+       s.Log(s.Containers.ServerVpp.VppInstance.Vppctl("test alpn server alpn-proto1 2 uri tls://" + serverAddress))
 
-       uri := "tls://" + s.Interfaces.Server.Ip4AddressString() + ":" + s.Ports.Port1
+       uri := "tls://" + serverAddress
        o := s.Containers.ClientVpp.VppInstance.Vppctl("test alpn client alpn-proto1 2 uri " + uri)
        s.Log(o)
        s.AssertNotContains(o, "connect failed")
@@ -21,9 +22,10 @@ func TlsAlpMatchTest(s *VethsSuite) {
 }
 
 func TlsAlpnOverlapMatchTest(s *VethsSuite) {
-       s.Log(s.Containers.ServerVpp.VppInstance.Vppctl("test alpn server alpn-proto1 2 alpn-proto2 1 uri tls://0.0.0.0:" + s.Ports.Port1))
+       serverAddress := s.Interfaces.Server.Ip4AddressString() + ":" + s.Ports.Port1
+       s.Log(s.Containers.ServerVpp.VppInstance.Vppctl("test alpn server alpn-proto1 2 alpn-proto2 1 uri tls://" + serverAddress))
 
-       uri := "tls://" + s.Interfaces.Server.Ip4AddressString() + ":" + s.Ports.Port1
+       uri := "tls://" + serverAddress
        o := s.Containers.ClientVpp.VppInstance.Vppctl("test alpn client alpn-proto1 3 alpn-proto2 2 uri " + uri)
        s.Log(o)
        s.AssertNotContains(o, "connect failed")
@@ -33,9 +35,10 @@ func TlsAlpnOverlapMatchTest(s *VethsSuite) {
 }
 
 func TlsAlpnServerPriorityMatchTest(s *VethsSuite) {
-       s.Log(s.Containers.ServerVpp.VppInstance.Vppctl("test alpn server alpn-proto1 2 alpn-proto2 1 uri tls://0.0.0.0:" + s.Ports.Port1))
+       serverAddress := s.Interfaces.Server.Ip4AddressString() + ":" + s.Ports.Port1
+       s.Log(s.Containers.ServerVpp.VppInstance.Vppctl("test alpn server alpn-proto1 2 alpn-proto2 1 uri tls://" + serverAddress))
 
-       uri := "tls://" + s.Interfaces.Server.Ip4AddressString() + ":" + s.Ports.Port1
+       uri := "tls://" + serverAddress
        o := s.Containers.ClientVpp.VppInstance.Vppctl("test alpn client alpn-proto1 1 alpn-proto2 2 uri " + uri)
        s.Log(o)
        s.AssertNotContains(o, "connect failed")
@@ -45,9 +48,10 @@ func TlsAlpnServerPriorityMatchTest(s *VethsSuite) {
 }
 
 func TlsAlpnMismatchTest(s *VethsSuite) {
-       s.Log(s.Containers.ServerVpp.VppInstance.Vppctl("test alpn server alpn-proto1 2 alpn-proto2 1 uri tls://0.0.0.0:" + s.Ports.Port1))
+       serverAddress := s.Interfaces.Server.Ip4AddressString() + ":" + s.Ports.Port1
+       s.Log(s.Containers.ServerVpp.VppInstance.Vppctl("test alpn server alpn-proto1 2 alpn-proto2 1 uri tls://" + serverAddress))
 
-       uri := "tls://" + s.Interfaces.Server.Ip4AddressString() + ":" + s.Ports.Port1
+       uri := "tls://" + serverAddress
        o := s.Containers.ClientVpp.VppInstance.Vppctl("test alpn client alpn-proto1 3 alpn-proto2 4 uri " + uri)
        s.Log(o)
        s.AssertNotContains(o, "timeout")
@@ -57,9 +61,10 @@ func TlsAlpnMismatchTest(s *VethsSuite) {
 }
 
 func TlsAlpnEmptyServerListTest(s *VethsSuite) {
-       s.Log(s.Containers.ServerVpp.VppInstance.Vppctl("test alpn server uri tls://0.0.0.0:" + s.Ports.Port1))
+       serverAddress := s.Interfaces.Server.Ip4AddressString() + ":" + s.Ports.Port1
+       s.Log(s.Containers.ServerVpp.VppInstance.Vppctl("test alpn server uri tls://" + serverAddress))
 
-       uri := "tls://" + s.Interfaces.Server.Ip4AddressString() + ":" + s.Ports.Port1
+       uri := "tls://" + serverAddress
        o := s.Containers.ClientVpp.VppInstance.Vppctl("test alpn client alpn-proto1 1 alpn-proto2 2 uri " + uri)
        s.Log(o)
        s.AssertNotContains(o, "connect failed")
@@ -69,9 +74,10 @@ func TlsAlpnEmptyServerListTest(s *VethsSuite) {
 }
 
 func TlsAlpnEmptyClientListTest(s *VethsSuite) {
-       s.Log(s.Containers.ServerVpp.VppInstance.Vppctl("test alpn server alpn-proto1 2 alpn-proto2 1 uri tls://0.0.0.0:" + s.Ports.Port1))
+       serverAddress := s.Interfaces.Server.Ip4AddressString() + ":" + s.Ports.Port1
+       s.Log(s.Containers.ServerVpp.VppInstance.Vppctl("test alpn server alpn-proto1 2 alpn-proto2 1 uri tls://" + serverAddress))
 
-       uri := "tls://" + s.Interfaces.Server.Ip4AddressString() + ":" + s.Ports.Port1
+       uri := "tls://" + serverAddress
        o := s.Containers.ClientVpp.VppInstance.Vppctl("test alpn client uri " + uri)
        s.Log(o)
        s.AssertNotContains(o, "connect failed")
index 5fa3312..e00937b 100644 (file)
@@ -9,7 +9,8 @@ import (
 
 func init() {
        RegisterVethTests(XEchoVclClientUdpTest, XEchoVclClientTcpTest, XEchoVclServerUdpTest,
-               XEchoVclServerTcpTest, VclEchoTcpTest, VclEchoUdpTest, VclHttpPostTest, VclRetryAttachTest)
+               XEchoVclServerTcpTest, VclEchoTcpTest, VclEchoUdpTest, VclHttpPostTest)
+       RegisterSoloVethTests(VclRetryAttachTest)
 }
 
 func getVclConfig(c *Container, ns_id_optional ...string) string {
@@ -66,14 +67,13 @@ func XEchoVclServerTcpTest(s *VethsSuite) {
 func testXEchoVclServer(s *VethsSuite, proto string) {
        srvVppCont := s.Containers.ServerVpp
        srvAppCont := s.Containers.ServerApp
+       serverVethAddress := s.Interfaces.Server.Ip4AddressString()
 
        srvAppCont.CreateFile("/vcl.conf", getVclConfig(srvVppCont))
        srvAppCont.AddEnvVar("VCL_CONFIG", "/vcl.conf")
-       vclSrvCmd := fmt.Sprintf("vcl_test_server -p %s %s", proto, s.Ports.Port1)
+       vclSrvCmd := fmt.Sprintf("vcl_test_server -p %s -B %s %s", proto, serverVethAddress, s.Ports.Port1)
        srvAppCont.ExecServer(true, vclSrvCmd)
 
-       serverVethAddress := s.Interfaces.Server.Ip4AddressString()
-
        clientVpp := s.Containers.ClientVpp.VppInstance
        o := clientVpp.Vppctl("test echo client uri %s://%s/%s fifo-size 64k verbose bytes 2m", proto, serverVethAddress, s.Ports.Port1)
        s.Log(o)
@@ -83,12 +83,12 @@ func testXEchoVclServer(s *VethsSuite, proto string) {
 func testVclEcho(s *VethsSuite, proto string) {
        srvVppCont := s.Containers.ServerVpp
        srvAppCont := s.Containers.ServerApp
+       serverVethAddress := s.Interfaces.Server.Ip4AddressString()
 
        srvAppCont.CreateFile("/vcl.conf", getVclConfig(srvVppCont))
        srvAppCont.AddEnvVar("VCL_CONFIG", "/vcl.conf")
-       srvAppCont.ExecServer(true, "vcl_test_server -p "+proto+" "+s.Ports.Port1)
-
-       serverVethAddress := s.Interfaces.Server.Ip4AddressString()
+       vclSrvCmd := fmt.Sprintf("vcl_test_server -p %s -B %s %s", proto, serverVethAddress, s.Ports.Port1)
+       srvAppCont.ExecServer(true, vclSrvCmd)
 
        echoClnContainer := s.GetTransientContainerByName("client-app")
        echoClnContainer.CreateFile("/vcl.conf", getVclConfig(echoClnContainer))
@@ -112,25 +112,25 @@ func VclHttpPostTest(s *VethsSuite) {
        testVclEcho(s, "http")
 }
 
+// solo because binding server to an IP makes the test fail in the CI
 func VclRetryAttachTest(s *VethsSuite) {
        testRetryAttach(s, "tcp")
 }
 
 func testRetryAttach(s *VethsSuite, proto string) {
        srvVppContainer := s.GetTransientContainerByName("server-vpp")
-
        echoSrvContainer := s.Containers.ServerApp
+       serverVethAddress := s.Interfaces.Server.Ip4AddressString()
 
        echoSrvContainer.CreateFile("/vcl.conf", getVclConfig(echoSrvContainer))
-
        echoSrvContainer.AddEnvVar("VCL_CONFIG", "/vcl.conf")
-       echoSrvContainer.ExecServer(true, "vcl_test_server -p "+proto+" "+s.Ports.Port1)
+
+       vclSrvCmd := fmt.Sprintf("vcl_test_server -p %s %s", proto, s.Ports.Port1)
+       echoSrvContainer.ExecServer(true, vclSrvCmd)
 
        s.Log("This whole test case can take around 3 minutes to run. Please be patient.")
        s.Log("... Running first echo client test, before disconnect.")
 
-       serverVethAddress := s.Interfaces.Server.Ip4AddressString()
-
        echoClnContainer := s.GetTransientContainerByName("client-app")
        echoClnContainer.CreateFile("/vcl.conf", getVclConfig(echoClnContainer))
 
@@ -143,8 +143,7 @@ func testRetryAttach(s *VethsSuite, proto string) {
 
        // Stop server-vpp-instance, start it again and then run vcl-test-client once more
        srvVppContainer.VppInstance.Disconnect()
-       stopVppCommand := "/bin/bash -c 'ps -C vpp_main -o pid= | xargs kill -9'"
-       srvVppContainer.Exec(false, stopVppCommand)
+       srvVppContainer.VppInstance.Stop()
 
        s.SetupServerVpp()
 
@@ -153,7 +152,7 @@ func testRetryAttach(s *VethsSuite, proto string) {
 
        s.Log("... Running second echo client test, after disconnect and re-attachment.")
        o, err = echoClnContainer.Exec(true, testClientCommand)
-       s.AssertNil(err)
        s.Log(o)
+       s.AssertNil(err, o)
        s.Log("Done.")
 }