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
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
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)
}
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)
}
// ../../src/vnet/udp/udp_local.h:foreach_udp4_dst_port
var reservedPorts = []string{
+ "22",
"53",
"67",
"68",
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()
coreDump := s.WaitForCoreDump()
s.ResetContainers()
- if s.Ip4AddrAllocator != nil {
- s.Ip4AddrAllocator.DeleteIpAddresses()
- }
-
- if s.Ip6AddrAllocator != nil {
- s.Ip6AddrAllocator.DeleteIpAddresses()
- }
-
if coreDump {
Fail("VPP crashed")
}
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)
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() {
}
}
-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()
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)
}()
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)
}()
}
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")
}
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")
}
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")
}
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")
}
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")
}
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")
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 {
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)
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))
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))
// 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()
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.")
}