From: Adrian Villin Date: Mon, 26 May 2025 09:48:28 +0000 (+0200) Subject: hs-test: fix parallel test runs X-Git-Url: https://gerrit.fd.io/r/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F92%2F42892%2F5;p=vpp.git hs-test: fix parallel test runs - every suite has its own generated ports - registered every perf test as solo to avoid issues - fixed teardown skipping when PERSIST or DRYRUN is enabled Type: test Change-Id: Ie4b85c8000a2158d45e906949d15ae1cefb27d1b Signed-off-by: Adrian Villin --- diff --git a/extras/hs-test/echo_test.go b/extras/hs-test/echo_test.go index 3c59f95fe55..b753121f401 100644 --- a/extras/hs-test/echo_test.go +++ b/extras/hs-test/echo_test.go @@ -17,13 +17,13 @@ func EchoBuiltinTest(s *VethsSuite) { serverVpp := s.Containers.ServerVpp.VppInstance serverVpp.Vppctl("test echo server " + - " uri tcp://" + s.Interfaces.Server.Ip4AddressString() + "/1234") + " uri tcp://" + s.Interfaces.Server.Ip4AddressString() + "/" + s.Ports.Port1) clientVpp := s.Containers.ClientVpp.VppInstance o := clientVpp.Vppctl("test echo client nclients 100 bytes 1 verbose" + " syn-timeout 100 test-timeout 100" + - " uri tcp://" + s.Interfaces.Server.Ip4AddressString() + "/1234") + " uri tcp://" + s.Interfaces.Server.Ip4AddressString() + "/" + s.Ports.Port1) s.Log(o) s.AssertNotContains(o, "failed:") } @@ -33,12 +33,12 @@ func EchoBuiltinBandwidthTest(s *VethsSuite) { serverVpp := s.Containers.ServerVpp.VppInstance serverVpp.Vppctl("test echo server " + - " uri tcp://" + s.Interfaces.Server.Ip4AddressString() + "/1234") + " uri tcp://" + s.Interfaces.Server.Ip4AddressString() + "/" + s.Ports.Port1) clientVpp := s.Containers.ClientVpp.VppInstance o := clientVpp.Vppctl("test echo client nclients 4 bytes 8m throughput 16m" + - " uri tcp://" + s.Interfaces.Server.Ip4AddressString() + "/1234") + " uri tcp://" + s.Interfaces.Server.Ip4AddressString() + "/" + s.Ports.Port1) s.Log(o) s.AssertContains(o, "Test started") s.AssertContains(o, "Test finished") @@ -60,7 +60,7 @@ func EchoBuiltinBandwidthTest(s *VethsSuite) { func TcpWithLossTest(s *VethsSuite) { serverVpp := s.Containers.ServerVpp.VppInstance - serverVpp.Vppctl("test echo server uri tcp://%s/20022", + serverVpp.Vppctl("test echo server uri tcp://%s/"+s.Ports.Port1, s.Interfaces.Server.Ip4AddressString()) clientVpp := s.Containers.ClientVpp.VppInstance @@ -72,8 +72,8 @@ func TcpWithLossTest(s *VethsSuite) { clientVpp.Vppctl("nsim output-feature enable-disable host-" + s.Interfaces.Server.Name()) // Do echo test from client-vpp container - output := clientVpp.Vppctl("test echo client uri tcp://%s/20022 verbose echo-bytes bytes 50m", - s.Interfaces.Server.Ip4AddressString()) + output := clientVpp.Vppctl("test echo client uri tcp://%s/%s verbose echo-bytes bytes 50m", + s.Interfaces.Server.Ip4AddressString(), s.Ports.Port1) s.Log(output) s.AssertNotEqual(len(output), 0) s.AssertNotContains(output, "failed", output) @@ -82,8 +82,8 @@ func TcpWithLossTest(s *VethsSuite) { func TcpWithLoss6Test(s *Veths6Suite) { serverVpp := s.Containers.ServerVpp.VppInstance - serverVpp.Vppctl("test echo server uri tcp://%s/20022", - s.Interfaces.Server.Ip6AddressString()) + serverVpp.Vppctl("test echo server uri tcp://%s/%s", + s.Interfaces.Server.Ip6AddressString(), s.Ports.Port1) clientVpp := s.Containers.ClientVpp.VppInstance @@ -94,8 +94,8 @@ func TcpWithLoss6Test(s *Veths6Suite) { clientVpp.Vppctl("nsim output-feature enable-disable host-" + s.Interfaces.Server.Name()) // Do echo test from client-vpp container - output := clientVpp.Vppctl("test echo client uri tcp://%s/20022 verbose echo-bytes bytes 50m", - s.Interfaces.Server.Ip6AddressString()) + output := clientVpp.Vppctl("test echo client uri tcp://%s/%s verbose echo-bytes bytes 50m", + s.Interfaces.Server.Ip6AddressString(), s.Ports.Port1) s.Log(output) s.AssertNotEqual(len(output), 0) s.AssertNotContains(output, "failed", output) diff --git a/extras/hs-test/http2_test.go b/extras/hs-test/http2_test.go index 8bcca1611a0..3ee4e9f06d7 100644 --- a/extras/hs-test/http2_test.go +++ b/extras/hs-test/http2_test.go @@ -9,15 +9,16 @@ import ( ) func init() { - RegisterH2Tests(Http2TcpGetTest, Http2TcpPostTest, Http2MultiplexingTest, Http2MultiplexingMTTest, Http2TlsTest) + RegisterH2Tests(Http2TcpGetTest, Http2TcpPostTest, Http2MultiplexingTest, Http2TlsTest) + RegisterH2SoloTests(Http2MultiplexingMTTest) } func Http2TcpGetTest(s *H2Suite) { vpp := s.Containers.Vpp.VppInstance - serverAddress := s.VppAddr() - vpp.Vppctl("http cli server") + serverAddress := s.VppAddr() + ":" + s.Ports.Port1 + vpp.Vppctl("http cli server listener add uri tcp://" + serverAddress) s.Log(vpp.Vppctl("show session verbose 2")) - args := fmt.Sprintf("--max-time 10 --noproxy '*' --http2-prior-knowledge http://%s:80/show/version", serverAddress) + args := fmt.Sprintf("--max-time 10 --noproxy '*' --http2-prior-knowledge http://%s/show/version", serverAddress) writeOut, log := s.RunCurlContainer(s.Containers.Curl, args) s.Log(vpp.Vppctl("show session verbose 2")) s.AssertContains(log, "HTTP/2 200") @@ -29,7 +30,7 @@ func Http2TcpGetTest(s *H2Suite) { tcpSessionCleanupDone := false for nTries := 0; nTries < 30; nTries++ { o := vpp.Vppctl("show session verbose 2") - if !strings.Contains(o, "[T] "+serverAddress+":80->") { + if !strings.Contains(o, "[T] "+serverAddress+"->10.") { tcpSessionCleanupDone = true } if !strings.Contains(o, "[H2]") { @@ -40,31 +41,31 @@ func Http2TcpGetTest(s *H2Suite) { } time.Sleep(1 * time.Second) } - s.AssertEqual(true, tcpSessionCleanupDone, "TCP session not cleanup") - s.AssertEqual(true, httpStreamCleanupDone, "HTTP/2 stream not cleanup") + s.AssertEqual(true, tcpSessionCleanupDone, "TCP session not cleaned up") + s.AssertEqual(true, httpStreamCleanupDone, "HTTP/2 stream not cleaned up") /* test server app stop listen */ - vpp.Vppctl("http cli server listener del") + vpp.Vppctl("http cli server listener del uri tcp://" + serverAddress) o := vpp.Vppctl("show session verbose proto http") s.AssertNotContains(o, "LISTEN") } func Http2TcpPostTest(s *H2Suite) { vpp := s.Containers.Vpp.VppInstance - serverAddress := s.VppAddr() - s.Log(vpp.Vppctl("http static server uri tcp://" + serverAddress + "/80 url-handlers max-body-size 20m rx-buff-thresh 20m fifo-size 65k debug 2")) + serverAddress := s.VppAddr() + ":" + s.Ports.Port1 + s.Log(vpp.Vppctl("http static server uri tcp://" + serverAddress + " url-handlers max-body-size 20m rx-buff-thresh 20m fifo-size 65k debug 2")) s.Log(vpp.Vppctl("test-url-handler enable")) - args := fmt.Sprintf("--max-time 10 --noproxy '*' --data-binary @%s --http2-prior-knowledge http://%s:80/test3", CurlContainerTestFile, serverAddress) + args := fmt.Sprintf("--max-time 10 --noproxy '*' --data-binary @%s --http2-prior-knowledge http://%s/test3", CurlContainerTestFile, serverAddress) _, log := s.RunCurlContainer(s.Containers.Curl, args) s.AssertContains(log, "HTTP/2 200") } func Http2MultiplexingTest(s *H2Suite) { vpp := s.Containers.Vpp.VppInstance - serverAddress := s.VppAddr() - vpp.Vppctl("http tps uri tcp://0.0.0.0/80 no-zc") + serverAddress := s.VppAddr() + ":" + s.Ports.Port1 + vpp.Vppctl("http tps uri tcp://0.0.0.0/" + s.Ports.Port1 + " no-zc") - args := fmt.Sprintf("--log-file=%s -T10 -n21 -c1 -m100 http://%s:80/test_file_20M", s.H2loadLogFileName(s.Containers.H2load), serverAddress) + 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 s.Containers.H2load.Run() @@ -79,10 +80,10 @@ func Http2MultiplexingTest(s *H2Suite) { func Http2MultiplexingMTTest(s *H2Suite) { vpp := s.Containers.Vpp.VppInstance - serverAddress := s.VppAddr() - vpp.Vppctl("http tps uri tcp://0.0.0.0/80 no-zc") + serverAddress := s.VppAddr() + ":" + s.Ports.Port1 + vpp.Vppctl("http tps uri tcp://0.0.0.0/" + s.Ports.Port1 + " no-zc") - args := fmt.Sprintf("-T10 -n100 -c4 -r1 -m10 http://%s:80/test_file_20M", serverAddress) + args := fmt.Sprintf("-T10 -n100 -c4 -r1 -m10 http://%s/test_file_20M", serverAddress) s.Containers.H2load.ExtraRunningArgs = args s.Containers.H2load.Run() @@ -95,10 +96,10 @@ func Http2MultiplexingMTTest(s *H2Suite) { func Http2TlsTest(s *H2Suite) { vpp := s.Containers.Vpp.VppInstance - serverAddress := s.VppAddr() - s.Log(vpp.Vppctl("http static server uri tls://" + serverAddress + "/443 url-handlers debug")) + serverAddress := s.VppAddr() + ":" + s.Ports.Port1 + s.Log(vpp.Vppctl("http static server uri tls://" + serverAddress + " url-handlers debug")) - args := fmt.Sprintf("--max-time 10 --noproxy '*' -k https://%s:443/version.json", serverAddress) + args := fmt.Sprintf("--max-time 10 --noproxy '*' -k https://%s/version.json", serverAddress) writeOut, log := s.RunCurlContainer(s.Containers.Curl, args) s.Log(vpp.Vppctl("show session verbose 2")) s.AssertContains(log, "HTTP/2 200") diff --git a/extras/hs-test/http_test.go b/extras/hs-test/http_test.go index f0a6f07cb63..f85804e165e 100644 --- a/extras/hs-test/http_test.go +++ b/extras/hs-test/http_test.go @@ -41,7 +41,7 @@ func init() { RegisterNoTopoSoloTests(HttpStaticPromTest, HttpGetTpsTest, HttpGetTpsInterruptModeTest, PromConcurrentConnectionsTest, PromMemLeakTest, HttpClientPostMemLeakTest, HttpInvalidClientRequestMemLeakTest, HttpPostTpsTest, HttpPostTpsInterruptModeTest, PromConsecutiveConnectionsTest, HttpGetTpsTlsTest, HttpPostTpsTlsTest, HttpClientGetRepeatMTTest, HttpClientPtrGetRepeatMTTest) - RegisterNoTopo6Tests(HttpClientGetResponseBody6Test, HttpClientGetTlsResponseBody6Test) + RegisterNoTopo6SoloTests(HttpClientGetResponseBody6Test, HttpClientGetTlsResponseBody6Test) } const wwwRootPath = "/tmp/www_root" @@ -71,9 +71,9 @@ func HttpGetTpsInterruptModeTest(s *NoTopoSuite) { func HttpGetTpsTest(s *NoTopoSuite) { vpp := s.Containers.Vpp.VppInstance serverAddress := s.VppAddr() - url := "http://" + serverAddress + ":8080/test_file_10M" + url := "http://" + serverAddress + ":" + s.Ports.Http + "/test_file_10M" - vpp.Vppctl("http tps uri tcp://0.0.0.0/8080") + vpp.Vppctl("http tps uri tcp://0.0.0.0/" + s.Ports.Http) s.RunBenchmark("HTTP tps download 10M", 10, 0, httpDownloadBenchmark, url) } @@ -81,9 +81,9 @@ func HttpGetTpsTest(s *NoTopoSuite) { func HttpGetTpsTlsTest(s *NoTopoSuite) { vpp := s.Containers.Vpp.VppInstance serverAddress := s.VppAddr() - url := "https://" + serverAddress + ":8080/test_file_10M" + url := "https://" + serverAddress + ":" + s.Ports.Http + "/test_file_10M" - vpp.Vppctl("http tps uri tls://0.0.0.0/8080") + vpp.Vppctl("http tps uri tls://0.0.0.0/" + s.Ports.Http) s.RunBenchmark("HTTP tps download 10M", 10, 0, httpDownloadBenchmark, url) } @@ -114,9 +114,9 @@ func HttpPostTpsInterruptModeTest(s *NoTopoSuite) { func HttpPostTpsTest(s *NoTopoSuite) { vpp := s.Containers.Vpp.VppInstance serverAddress := s.VppAddr() - url := "http://" + serverAddress + ":8080/test_file_10M" + url := "http://" + serverAddress + ":" + s.Ports.Http + "/test_file_10M" - vpp.Vppctl("http tps uri tcp://0.0.0.0/8080") + vpp.Vppctl("http tps uri tcp://0.0.0.0/" + s.Ports.Http) s.RunBenchmark("HTTP tps upload 10M", 10, 0, httpUploadBenchmark, url) } @@ -124,9 +124,9 @@ func HttpPostTpsTest(s *NoTopoSuite) { func HttpPostTpsTlsTest(s *NoTopoSuite) { vpp := s.Containers.Vpp.VppInstance serverAddress := s.VppAddr() - url := "https://" + serverAddress + ":8080/test_file_10M" + url := "https://" + serverAddress + ":" + s.Ports.Http + "/test_file_10M" - vpp.Vppctl("http tps uri tls://0.0.0.0/8080") + vpp.Vppctl("http tps uri tls://0.0.0.0/" + s.Ports.Http) s.RunBenchmark("HTTP tps upload 10M", 10, 0, httpUploadBenchmark, url) } @@ -135,8 +135,8 @@ func HttpPersistentConnectionTest(s *NoTopoSuite) { // testing url handler app do not support multi-thread s.SkipIfMultiWorker() vpp := s.Containers.Vpp.VppInstance - serverAddress := s.VppAddr() - s.Log(vpp.Vppctl("http static server uri tcp://" + serverAddress + "/80 url-handlers")) + serverAddress := s.VppAddr() + ":" + s.Ports.Http + s.Log(vpp.Vppctl("http static server uri tcp://" + serverAddress + " url-handlers")) s.Log(vpp.Vppctl("test-url-handler enable")) transport := http.DefaultTransport @@ -150,7 +150,7 @@ func HttpPersistentConnectionTest(s *NoTopoSuite) { }} body := []byte("{\"sandwich\": {\"spam\": 2, \"eggs\": 1}}") - req, err := http.NewRequest("POST", "http://"+serverAddress+":80/test3", bytes.NewBuffer(body)) + req, err := http.NewRequest("POST", "http://"+serverAddress+"/test3", bytes.NewBuffer(body)) s.AssertNil(err, fmt.Sprint(err)) resp, err := client.Do(req) s.AssertNil(err, fmt.Sprint(err)) @@ -162,7 +162,7 @@ func HttpPersistentConnectionTest(s *NoTopoSuite) { s.Log(o1) s.AssertContains(o1, "established") - req, err = http.NewRequest("GET", "http://"+serverAddress+":80/test1", nil) + req, err = http.NewRequest("GET", "http://"+serverAddress+"/test1", nil) s.AssertNil(err, fmt.Sprint(err)) clientTrace := &httptrace.ClientTrace{ GotConn: func(info httptrace.GotConnInfo) { @@ -181,7 +181,7 @@ func HttpPersistentConnectionTest(s *NoTopoSuite) { s.AssertContains(o2, "established") s.AssertEqual(o1, o2) - req, err = http.NewRequest("GET", "http://"+serverAddress+":80/test2", nil) + req, err = http.NewRequest("GET", "http://"+serverAddress+"/test2", nil) s.AssertNil(err, fmt.Sprint(err)) req = req.WithContext(httptrace.WithClientTrace(req.Context(), clientTrace)) resp, err = client.Do(req) @@ -200,14 +200,14 @@ func HttpPipeliningTest(s *NoTopoSuite) { // testing url handler app do not support multi-thread s.SkipIfMultiWorker() vpp := s.Containers.Vpp.VppInstance - serverAddress := s.VppAddr() - s.Log(vpp.Vppctl("http static server uri tcp://" + serverAddress + "/80 url-handlers debug")) + serverAddress := s.VppAddr() + ":" + s.Ports.Http + s.Log(vpp.Vppctl("http static server uri tcp://" + serverAddress + " url-handlers debug")) s.Log(vpp.Vppctl("test-url-handler enable")) - req1 := "GET /test_delayed HTTP/1.1\r\nHost:" + serverAddress + ":80\r\nUser-Agent:test\r\n\r\n" - req2 := "GET /test1 HTTP/1.1\r\nHost:" + serverAddress + ":80\r\nUser-Agent:test\r\n\r\n" + req1 := "GET /test_delayed HTTP/1.1\r\nHost:" + serverAddress + "\r\nUser-Agent:test\r\n\r\n" + req2 := "GET /test1 HTTP/1.1\r\nHost:" + serverAddress + "\r\nUser-Agent:test\r\n\r\n" - conn, err := net.DialTimeout("tcp", serverAddress+":80", time.Second*30) + conn, err := net.DialTimeout("tcp", serverAddress, time.Second*30) s.AssertNil(err, fmt.Sprint(err)) defer conn.Close() err = conn.SetDeadline(time.Now().Add(time.Second * 15)) @@ -235,14 +235,14 @@ func HttpStaticPostTest(s *NoTopoSuite) { // testing url handler app do not support multi-thread s.SkipIfMultiWorker() vpp := s.Containers.Vpp.VppInstance - serverAddress := s.VppAddr() - s.Log(vpp.Vppctl("http static server uri tcp://" + serverAddress + "/80 url-handlers debug max-body-size 1m")) + serverAddress := s.VppAddr() + ":" + s.Ports.Http + s.Log(vpp.Vppctl("http static server uri tcp://" + serverAddress + " url-handlers debug max-body-size 1m")) s.Log(vpp.Vppctl("test-url-handler enable")) body := make([]byte, 131072) _, err := rand.Read(body) client := NewHttpClient(defaultHttpTimeout, false) - req, err := http.NewRequest("POST", "http://"+serverAddress+":80/test3", bytes.NewBuffer(body)) + req, err := http.NewRequest("POST", "http://"+serverAddress+"/test3", bytes.NewBuffer(body)) s.AssertNil(err, fmt.Sprint(err)) resp, err := client.Do(req) s.AssertNil(err, fmt.Sprint(err)) @@ -253,12 +253,13 @@ func HttpStaticPostTest(s *NoTopoSuite) { } func HttpCliTest(s *VethsSuite) { - s.Containers.ServerVpp.VppInstance.Vppctl("http cli server") + serverAddress := s.Interfaces.Server.Ip4AddressString() + ":" + s.Ports.Port1 - uri := "http://" + s.Interfaces.Server.Ip4AddressString() + "/80" + cliServerCmd := "http cli server uri http://" + serverAddress + s.Containers.ServerVpp.VppInstance.Vppctl(cliServerCmd) o := s.Containers.ClientVpp.VppInstance.Vppctl("http cli client" + - " uri " + uri + " query /show/vlib/graph") + " uri http://" + serverAddress + " query /show/vlib/graph") s.Log(o) s.AssertContains(o, "", " not found in the result!") @@ -268,7 +269,7 @@ func HttpCliTest(s *VethsSuite) { clientCleanupDone := false for nTries := 0; nTries < 30; nTries++ { o := s.Containers.ClientVpp.VppInstance.Vppctl("show session verbose 2") - if !strings.Contains(o, "->"+s.Interfaces.Server.Ip4AddressString()+":80") { + if !strings.Contains(o, "->"+serverAddress) { clientCleanupDone = true break } @@ -277,13 +278,13 @@ func HttpCliTest(s *VethsSuite) { s.AssertEqual(true, clientCleanupDone) /* test server app stop listen */ - s.Containers.ServerVpp.VppInstance.Vppctl("http cli server listener del") + s.Containers.ServerVpp.VppInstance.Vppctl(cliServerCmd + " listener del") o = s.Containers.ServerVpp.VppInstance.Vppctl("show session verbose proto http") s.AssertNotContains(o, "LISTEN") } func HttpCliTlsTest(s *VethsSuite) { - uri := "tls://" + s.Interfaces.Server.Ip4AddressString() + "/443" + uri := "tls://" + s.Interfaces.Server.Ip4AddressString() + "/" + s.Ports.Port1 s.Containers.ServerVpp.VppInstance.Vppctl("http cli server uri " + uri) @@ -312,9 +313,9 @@ func HttpCliConnectErrorTest(s *VethsSuite) { } func HttpClientTest(s *NoTopoSuite) { - serverAddress := s.HostAddr() + serverAddress := s.HostAddr() + ":" + s.Ports.Http server := ghttp.NewUnstartedServer() - l, err := net.Listen("tcp", serverAddress+":80") + l, err := net.Listen("tcp", serverAddress) s.AssertNil(err, fmt.Sprint(err)) server.HTTPTestServer.Listener = l server.AppendHandlers( @@ -327,7 +328,7 @@ func HttpClientTest(s *NoTopoSuite) { )) server.Start() defer server.Close() - uri := "http://" + serverAddress + "/80" + uri := "http://" + serverAddress vpp := s.Containers.Vpp.VppInstance o := vpp.Vppctl("http cli client uri " + uri + " query /test") @@ -384,9 +385,9 @@ func HttpClientInvalidHeaderNameTest(s *NoTopoSuite) { } func HttpClientErrRespTest(s *NoTopoSuite) { - serverAddress := s.HostAddr() + serverAddress := s.HostAddr() + ":" + s.Ports.Http server := ghttp.NewUnstartedServer() - l, err := net.Listen("tcp", serverAddress+":80") + l, err := net.Listen("tcp", serverAddress) s.AssertNil(err, fmt.Sprint(err)) server.HTTPTestServer.Listener = l server.AppendHandlers( @@ -397,7 +398,7 @@ func HttpClientErrRespTest(s *NoTopoSuite) { )) server.Start() defer server.Close() - uri := "http://" + serverAddress + "/80" + uri := "http://" + serverAddress vpp := s.Containers.Vpp.VppInstance o := vpp.Vppctl("http cli client uri " + uri + " query /test") @@ -406,11 +407,11 @@ func HttpClientErrRespTest(s *NoTopoSuite) { } func HttpClientPostFormTest(s *NoTopoSuite) { - serverAddress := s.HostAddr() + serverAddress := s.HostAddr() + ":" + s.Ports.Http body := "field1=value1&field2=value2" server := ghttp.NewUnstartedServer() - l, err := net.Listen("tcp", serverAddress+":80") + l, err := net.Listen("tcp", serverAddress) s.AssertNil(err, fmt.Sprint(err)) server.HTTPTestServer.Listener = l server.AppendHandlers( @@ -453,10 +454,9 @@ func HttpClientGetTlsNoRespBodyTest(s *NoTopoSuite) { func httpClientGet(s *NoTopoSuite, response string, size int, proto string) { var l net.Listener var err error - var port string vpp := s.Containers.Vpp.VppInstance server := ghttp.NewUnstartedServer() - serverAddress := s.HostAddr() + serverAddress := s.HostAddr() + ":" + s.Ports.Http if proto == "https" { certFile := "resources/cert/localhost.crt" @@ -465,11 +465,9 @@ func httpClientGet(s *NoTopoSuite, response string, size int, proto string) { s.AssertNil(err) tlsConfig := &tls.Config{Certificates: []tls.Certificate{cer}} server.HTTPTestServer.TLS = tlsConfig - port = "443" - l, err = tls.Listen("tcp", serverAddress+":443", tlsConfig) + l, err = tls.Listen("tcp", serverAddress, tlsConfig) } else { - port = "80" - l, err = net.Listen("tcp", serverAddress+":80") + l, err = net.Listen("tcp", serverAddress) } s.AssertNil(err, fmt.Sprint(err)) @@ -485,7 +483,7 @@ func httpClientGet(s *NoTopoSuite, response string, size int, proto string) { server.Start() defer server.Close() - uri := proto + "://" + serverAddress + ":" + port + uri := proto + "://" + serverAddress cmd := "http client use-ptr verbose header Hello:World header Test-H2:Test-K2 save-to response.txt uri " + uri o := vpp.Vppctl(cmd) @@ -505,12 +503,14 @@ func httpClientGet(s *NoTopoSuite, response string, size int, proto string) { s.AssertContains(file_contents, response) } +// registered as a solo test and not using generated ports func HttpClientGetResponseBody6Test(s *NoTopo6Suite) { response := "hello world" size := len(response) httpClientGet6(s, response, size, "http") } +// registered as a solo test and not using generated ports func HttpClientGetTlsResponseBody6Test(s *NoTopo6Suite) { response := "hello world" size := len(response) @@ -586,7 +586,7 @@ func HttpClientPostRepeatTest(s *NoTopoSuite) { func httpClientRepeat(s *NoTopoSuite, requestMethod string, clientArgs string) { vpp := s.Containers.Vpp.VppInstance logPath := s.Containers.NginxServer.GetContainerWorkDir() + "/" + s.Containers.NginxServer.Name + "-access.log" - serverAddress := s.Interfaces.Tap.Ip4AddressString() + serverAddress := s.Interfaces.Tap.Ip4AddressString() + ":" + s.Ports.NginxServer replyCountInt := 0 repeatAmount := 10000 durationInSec := 10 @@ -606,7 +606,7 @@ func httpClientRepeat(s *NoTopoSuite, requestMethod string, clientArgs string) { requestMethod += " file /tmp/test_file.txt" } - uri := "http://" + serverAddress + ":" + s.GetPortFromPpid() + "/index" + uri := "http://" + serverAddress + "/index" cmd := fmt.Sprintf("http client %s %s duration %d header Hello:World uri %s", requestMethod, clientArgs, durationInSec, uri) @@ -650,11 +650,11 @@ func httpClientRepeat(s *NoTopoSuite, requestMethod string, clientArgs string) { } func HttpClientGetTimeout(s *NoTopoSuite) { - serverAddress := s.HostAddr() + serverAddress := s.HostAddr() + ":" + s.Ports.Http vpp := s.Containers.Vpp.VppInstance server := ghttp.NewUnstartedServer() - l, err := net.Listen("tcp", serverAddress+":"+s.GetPortFromPpid()) + l, err := net.Listen("tcp", serverAddress) s.AssertNil(err, fmt.Sprint(err)) server.HTTPTestServer.Listener = l server.AppendHandlers( @@ -668,7 +668,7 @@ func HttpClientGetTimeout(s *NoTopoSuite) { )) server.Start() defer server.Close() - uri := "http://" + serverAddress + ":" + s.GetPortFromPpid() + "/timeout" + uri := "http://" + serverAddress + "/timeout" cmd := "http client verbose timeout 1 uri " + uri o := vpp.Vppctl(cmd) @@ -677,14 +677,14 @@ func HttpClientGetTimeout(s *NoTopoSuite) { } func httpClientPostFile(s *NoTopoSuite, usePtr bool, fileSize int) { - serverAddress := s.HostAddr() + serverAddress := s.HostAddr() + ":" + s.Ports.Http vpp := s.Containers.Vpp.VppInstance fileName := "/tmp/test_file.txt" s.Log(vpp.Container.Exec(false, "fallocate -l "+strconv.Itoa(fileSize)+" "+fileName)) s.Log(vpp.Container.Exec(false, "ls -la "+fileName)) server := ghttp.NewUnstartedServer() - l, err := net.Listen("tcp", serverAddress+":80") + l, err := net.Listen("tcp", serverAddress) s.AssertNil(err, fmt.Sprint(err)) server.HTTPTestServer.Listener = l server.AppendHandlers( @@ -720,12 +720,12 @@ func HttpClientPostFilePtrTest(s *NoTopoSuite) { func HttpStaticPromTest(s *NoTopoSuite) { query := "stats.prom" vpp := s.Containers.Vpp.VppInstance - serverAddress := s.VppAddr() - s.Log(vpp.Vppctl("http static server uri tcp://" + serverAddress + "/80 url-handlers")) + serverAddress := s.VppAddr() + ":" + s.Ports.Http + s.Log(vpp.Vppctl("http static server uri tcp://" + serverAddress + " url-handlers")) s.Log(vpp.Vppctl("prom enable")) time.Sleep(time.Second * 5) client := NewHttpClient(defaultHttpTimeout, false) - req, err := http.NewRequest("GET", "http://"+serverAddress+":80/"+query, nil) + req, err := http.NewRequest("GET", "http://"+serverAddress+"/"+query, nil) s.AssertNil(err, fmt.Sprint(err)) resp, err := client.Do(req) s.AssertNil(err, fmt.Sprint(err)) @@ -758,10 +758,10 @@ func promReqWg(s *NoTopoSuite, url string, wg *sync.WaitGroup) { func PromConcurrentConnectionsTest(s *NoTopoSuite) { vpp := s.Containers.Vpp.VppInstance - serverAddress := s.VppAddr() - url := "http://" + serverAddress + ":80/stats.prom" + serverAddress := s.VppAddr() + ":" + s.Ports.Http + url := "http://" + serverAddress + "/stats.prom" - s.Log(vpp.Vppctl("http static server uri tcp://" + serverAddress + "/80 url-handlers")) + s.Log(vpp.Vppctl("http static server uri tcp://" + serverAddress + " url-handlers")) s.Log(vpp.Vppctl("prom enable")) time.Sleep(time.Second * 5) @@ -776,10 +776,10 @@ func PromConcurrentConnectionsTest(s *NoTopoSuite) { func PromConsecutiveConnectionsTest(s *NoTopoSuite) { vpp := s.Containers.Vpp.VppInstance - serverAddress := s.VppAddr() - url := "http://" + serverAddress + ":80/stats.prom" + serverAddress := s.VppAddr() + ":" + s.Ports.Http + url := "http://" + serverAddress + "/stats.prom" - s.Log(vpp.Vppctl("http static server uri tcp://" + serverAddress + "/80 url-handlers")) + s.Log(vpp.Vppctl("http static server uri tcp://" + serverAddress + " url-handlers")) s.Log(vpp.Vppctl("prom enable")) time.Sleep(time.Second * 5) @@ -792,13 +792,13 @@ func PromMemLeakTest(s *NoTopoSuite) { s.SkipUnlessLeakCheck() vpp := s.Containers.Vpp.VppInstance - serverAddress := s.VppAddr() - url := "http://" + serverAddress + ":80/stats.prom" + serverAddress := s.VppAddr() + ":" + s.Ports.Http + url := "http://" + serverAddress + "/stats.prom" /* no goVPP less noise */ vpp.Disconnect() - s.Log(vpp.Vppctl("http static server uri tcp://" + serverAddress + "/80 url-handlers")) + s.Log(vpp.Vppctl("http static server uri tcp://" + serverAddress + " url-handlers")) s.Log(vpp.Vppctl("prom enable")) time.Sleep(time.Second * 3) @@ -832,9 +832,9 @@ func HttpClientGetMemLeakTest(s *VethsSuite) { /* no goVPP less noise */ clientVpp.Disconnect() - serverVpp.Vppctl("http cli server") + serverVpp.Vppctl("http cli server uri " + s.Interfaces.Server.Ip4AddressString() + "/" + s.Ports.Port1) - uri := "http://" + s.Interfaces.Server.Ip4AddressString() + "/80" + uri := "http://" + s.Interfaces.Server.Ip4AddressString() + "/" + s.Ports.Port1 /* warmup request (FIB) */ clientVpp.Vppctl("http cli client uri " + uri + " query /show/version") @@ -859,17 +859,17 @@ func HttpClientGetMemLeakTest(s *VethsSuite) { func HttpClientPostMemLeakTest(s *NoTopoSuite) { s.SkipUnlessLeakCheck() - serverAddress := s.HostAddr() + serverAddress := s.HostAddr() + ":" + s.Ports.Http body := "field1=value1&field2=value2" - uri := "http://" + serverAddress + "/80" + uri := "http://" + serverAddress vpp := s.Containers.Vpp.VppInstance /* no goVPP less noise */ vpp.Disconnect() server := ghttp.NewUnstartedServer() - l, err := net.Listen("tcp", serverAddress+":80") + l, err := net.Listen("tcp", serverAddress) s.AssertNil(err, fmt.Sprint(err)) server.HTTPTestServer.Listener = l server.AppendHandlers( @@ -909,7 +909,7 @@ func HttpInvalidClientRequestMemLeakTest(s *NoTopoSuite) { s.SkipUnlessLeakCheck() vpp := s.Containers.Vpp.VppInstance - serverAddress := s.VppAddr() + serverAddress := s.VppAddr() + ":" + s.Ports.Http /* no goVPP less noise */ vpp.Disconnect() @@ -917,7 +917,7 @@ func HttpInvalidClientRequestMemLeakTest(s *NoTopoSuite) { vpp.Vppctl("http cli server") /* warmup request (FIB) */ - _, err := TcpSendReceive(serverAddress+":80", "GET / HTTP/1.1\r\n") + _, err := TcpSendReceive(serverAddress, "GET / HTTP/1.1\r\n") s.AssertNil(err, fmt.Sprint(err)) /* let's give it some time to clean up sessions, so local port can be reused and we have less noise */ @@ -927,7 +927,7 @@ func HttpInvalidClientRequestMemLeakTest(s *NoTopoSuite) { traces1, err := vpp.GetMemoryTrace() s.AssertNil(err, fmt.Sprint(err)) - _, err = TcpSendReceive(serverAddress+":80", "GET / HTTP/1.1\r\n") + _, err = TcpSendReceive(serverAddress, "GET / HTTP/1.1\r\n") s.AssertNil(err, fmt.Sprint(err)) /* let's give it some time to clean up sessions */ @@ -941,9 +941,9 @@ func HttpInvalidClientRequestMemLeakTest(s *NoTopoSuite) { func runWrkPerf(s *NoTopoSuite) { nConnections := 1000 - serverAddress := s.VppAddr() + serverAddress := s.VppAddr() + ":" + s.Ports.Http - args := fmt.Sprintf("-c %d -t 2 -d 30s http://%s:80/64B", nConnections, serverAddress) + args := fmt.Sprintf("-c %d -t 2 -d 30s http://%s/64B", nConnections, serverAddress) s.Containers.Wrk.ExtraRunningArgs = args s.Containers.Wrk.Run() s.Log("Please wait for 30s, test is running.") @@ -954,19 +954,19 @@ func runWrkPerf(s *NoTopoSuite) { func HttpStaticFileHandlerWrkTest(s *NoTopoSuite) { vpp := s.Containers.Vpp.VppInstance - serverAddress := s.VppAddr() + serverAddress := s.VppAddr() + ":" + s.Ports.Http vpp.Container.Exec(false, "mkdir -p "+wwwRootPath) content := "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" err := vpp.Container.CreateFile(wwwRootPath+"/64B", content) s.AssertNil(err, fmt.Sprint(err)) - s.Log(vpp.Vppctl("http static server www-root " + wwwRootPath + " uri tcp://" + serverAddress + "/80 private-segment-size 256m")) + s.Log(vpp.Vppctl("http static server www-root " + wwwRootPath + " uri tcp://" + serverAddress + " private-segment-size 256m")) runWrkPerf(s) } func HttpStaticUrlHandlerWrkTest(s *NoTopoSuite) { vpp := s.Containers.Vpp.VppInstance - serverAddress := s.VppAddr() - s.Log(vpp.Vppctl("http static server uri tcp://" + serverAddress + "/80 url-handlers private-segment-size 256m")) + serverAddress := s.VppAddr() + ":" + s.Ports.Http + s.Log(vpp.Vppctl("http static server uri tcp://" + serverAddress + " url-handlers private-segment-size 256m")) s.Log(vpp.Vppctl("test-url-handler enable")) runWrkPerf(s) } @@ -997,11 +997,11 @@ func HttpStaticFileHandlerTestFunction(s *NoTopoSuite, max_age string) { s.AssertNil(err, fmt.Sprint(err)) err = vpp.Container.CreateFile(wwwRootPath+"/page.html", content2) s.AssertNil(err, fmt.Sprint(err)) - serverAddress := s.VppAddr() - s.Log(vpp.Vppctl("http static server www-root " + wwwRootPath + " uri tcp://" + serverAddress + "/80 debug cache-size 2m " + maxAgeFormatted)) + serverAddress := s.VppAddr() + ":" + s.Ports.Http + s.Log(vpp.Vppctl("http static server www-root " + wwwRootPath + " uri tcp://" + serverAddress + " debug cache-size 2m " + maxAgeFormatted)) client := NewHttpClient(defaultHttpTimeout, false) - req, err := http.NewRequest("GET", "http://"+serverAddress+":80/index.html", nil) + req, err := http.NewRequest("GET", "http://"+serverAddress+"/index.html", nil) s.AssertNil(err, fmt.Sprint(err)) resp, err := client.Do(req) s.AssertNil(err, fmt.Sprint(err)) @@ -1030,7 +1030,7 @@ func HttpStaticFileHandlerTestFunction(s *NoTopoSuite, max_age string) { s.AssertHttpContentLength(resp, int64(len([]rune(content)))) s.AssertHttpBody(resp, content) - req, err = http.NewRequest("GET", "http://"+serverAddress+":80/page.html", nil) + req, err = http.NewRequest("GET", "http://"+serverAddress+"/page.html", nil) s.AssertNil(err, fmt.Sprint(err)) resp, err = client.Do(req) s.AssertNil(err, fmt.Sprint(err)) @@ -1055,11 +1055,11 @@ func HttpStaticPathSanitizationTest(s *NoTopoSuite) { indexContent := "index" err = vpp.Container.CreateFile(wwwRootPath+"/index.html", indexContent) s.AssertNil(err, fmt.Sprint(err)) - serverAddress := s.VppAddr() - s.Log(vpp.Vppctl("http static server www-root " + wwwRootPath + " uri tcp://" + serverAddress + "/80 debug")) + serverAddress := s.VppAddr() + ":" + s.Ports.Http + s.Log(vpp.Vppctl("http static server www-root " + wwwRootPath + " uri tcp://" + serverAddress + " debug")) client := NewHttpClient(defaultHttpTimeout, false) - req, err := http.NewRequest("GET", "http://"+serverAddress+":80/../secret_folder/secret_file.txt", nil) + req, err := http.NewRequest("GET", "http://"+serverAddress+"/../secret_folder/secret_file.txt", nil) s.AssertNil(err, fmt.Sprint(err)) resp, err := client.Do(req) s.AssertNil(err, fmt.Sprint(err)) @@ -1070,7 +1070,7 @@ func HttpStaticPathSanitizationTest(s *NoTopoSuite) { s.AssertHttpHeaderNotPresent(resp, "Cache-Control") s.AssertHttpContentLength(resp, int64(0)) - req, err = http.NewRequest("GET", "http://"+serverAddress+":80//////fake/directory///../././//../../secret_folder/secret_file.txt", nil) + req, err = http.NewRequest("GET", "http://"+serverAddress+"//////fake/directory///../././//../../secret_folder/secret_file.txt", nil) s.AssertNil(err, fmt.Sprint(err)) resp, err = client.Do(req) s.AssertNil(err, fmt.Sprint(err)) @@ -1081,14 +1081,14 @@ func HttpStaticPathSanitizationTest(s *NoTopoSuite) { s.AssertHttpHeaderNotPresent(resp, "Cache-Control") s.AssertHttpContentLength(resp, int64(0)) - req, err = http.NewRequest("GET", "http://"+serverAddress+":80/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////", nil) + req, err = http.NewRequest("GET", "http://"+serverAddress+"/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////", nil) s.AssertNil(err, fmt.Sprint(err)) resp, err = client.Do(req) s.AssertNil(err, fmt.Sprint(err)) defer resp.Body.Close() s.Log(DumpHttpResp(resp, true)) s.AssertHttpStatus(resp, 301) - s.AssertHttpHeaderWithValue(resp, "Location", "http://"+serverAddress+"/index.html") + s.AssertHttpHeaderWithValue(resp, "Location", "http://"+s.VppAddr()+"/index.html") } func HttpStaticMovedTest(s *NoTopoSuite) { @@ -1097,10 +1097,10 @@ func HttpStaticMovedTest(s *NoTopoSuite) { err := vpp.Container.CreateFile(wwwRootPath+"/tmp.aaa/index.html", "

Hello

") s.AssertNil(err, fmt.Sprint(err)) serverAddress := s.VppAddr() - s.Log(vpp.Vppctl("http static server www-root " + wwwRootPath + " uri tcp://" + serverAddress + "/80 debug")) + s.Log(vpp.Vppctl("http static server www-root " + wwwRootPath + " uri tcp://" + serverAddress + "/" + s.Ports.Http + " debug")) client := NewHttpClient(defaultHttpTimeout, false) - req, err := http.NewRequest("GET", "http://"+serverAddress+":80/tmp.aaa", nil) + req, err := http.NewRequest("GET", "http://"+serverAddress+":"+s.Ports.Http+"/tmp.aaa", nil) s.AssertNil(err, fmt.Sprint(err)) resp, err := client.Do(req) s.AssertNil(err, fmt.Sprint(err)) @@ -1116,11 +1116,11 @@ func HttpStaticMovedTest(s *NoTopoSuite) { func HttpStaticNotFoundTest(s *NoTopoSuite) { vpp := s.Containers.Vpp.VppInstance vpp.Container.Exec(false, "mkdir -p "+wwwRootPath) - serverAddress := s.VppAddr() - s.Log(vpp.Vppctl("http static server www-root " + wwwRootPath + " uri tcp://" + serverAddress + "/80 debug")) + serverAddress := s.VppAddr() + ":" + s.Ports.Http + s.Log(vpp.Vppctl("http static server www-root " + wwwRootPath + " uri tcp://" + serverAddress + " debug")) client := NewHttpClient(defaultHttpTimeout, false) - req, err := http.NewRequest("GET", "http://"+serverAddress+":80/notfound.html", nil) + req, err := http.NewRequest("GET", "http://"+serverAddress+"/notfound.html", nil) s.AssertNil(err, fmt.Sprint(err)) resp, err := client.Do(req) s.AssertNil(err, fmt.Sprint(err)) @@ -1134,11 +1134,11 @@ func HttpStaticNotFoundTest(s *NoTopoSuite) { func HttpCliMethodNotAllowedTest(s *NoTopoSuite) { vpp := s.Containers.Vpp.VppInstance - serverAddress := s.VppAddr() - vpp.Vppctl("http cli server") + serverAddress := s.VppAddr() + ":" + s.Ports.Http + vpp.Vppctl("http cli server uri http://" + serverAddress) client := NewHttpClient(defaultHttpTimeout, false) - req, err := http.NewRequest("POST", "http://"+serverAddress+":80/test", nil) + req, err := http.NewRequest("POST", "http://"+serverAddress+"/test", nil) s.AssertNil(err, fmt.Sprint(err)) resp, err := client.Do(req) s.AssertNil(err, fmt.Sprint(err)) @@ -1152,11 +1152,11 @@ func HttpCliMethodNotAllowedTest(s *NoTopoSuite) { func HttpCliBadRequestTest(s *NoTopoSuite) { vpp := s.Containers.Vpp.VppInstance - serverAddress := s.VppAddr() - vpp.Vppctl("http cli server") + serverAddress := s.VppAddr() + ":" + s.Ports.Http + vpp.Vppctl("http cli server uri http://" + serverAddress) client := NewHttpClient(defaultHttpTimeout, false) - req, err := http.NewRequest("GET", "http://"+serverAddress+":80", nil) + req, err := http.NewRequest("GET", "http://"+serverAddress, nil) s.AssertNil(err, fmt.Sprint(err)) resp, err := client.Do(req) s.AssertNil(err, fmt.Sprint(err)) @@ -1188,11 +1188,11 @@ func HttpStaticHttp1OnlyTest(s *NoTopoSuite) { func HttpStaticBuildInUrlGetVersionTest(s *NoTopoSuite) { vpp := s.Containers.Vpp.VppInstance - serverAddress := s.VppAddr() - s.Log(vpp.Vppctl("http static server uri tls://" + serverAddress + "/80 url-handlers debug")) + serverAddress := s.VppAddr() + ":" + s.Ports.Http + s.Log(vpp.Vppctl("http static server uri tls://" + serverAddress + " url-handlers debug")) client := NewHttpClient(defaultHttpTimeout, false) - req, err := http.NewRequest("GET", "https://"+serverAddress+":80/version.json", nil) + req, err := http.NewRequest("GET", "https://"+serverAddress+"/version.json", nil) s.AssertNil(err, fmt.Sprint(err)) resp, err := client.Do(req) s.AssertNil(err, fmt.Sprint(err)) @@ -1213,11 +1213,11 @@ func HttpStaticBuildInUrlGetVersionTest(s *NoTopoSuite) { func HttpStaticBuildInUrlGetVersionVerboseTest(s *NoTopoSuite) { vpp := s.Containers.Vpp.VppInstance - serverAddress := s.VppAddr() - s.Log(vpp.Vppctl("http static server uri tcp://" + serverAddress + "/80 url-handlers debug")) + serverAddress := s.VppAddr() + ":" + s.Ports.Http + s.Log(vpp.Vppctl("http static server uri tcp://" + serverAddress + " url-handlers debug")) client := NewHttpClient(defaultHttpTimeout, false) - req, err := http.NewRequest("GET", "http://"+serverAddress+":80/version.json?verbose=true", nil) + req, err := http.NewRequest("GET", "http://"+serverAddress+"/version.json?verbose=true", nil) s.AssertNil(err, fmt.Sprint(err)) resp, err := client.Do(req) s.AssertNil(err, fmt.Sprint(err)) @@ -1237,11 +1237,11 @@ func HttpStaticBuildInUrlGetVersionVerboseTest(s *NoTopoSuite) { func HttpStaticBuildInUrlGetIfListTest(s *NoTopoSuite) { vpp := s.Containers.Vpp.VppInstance - serverAddress := s.VppAddr() - s.Log(vpp.Vppctl("http static server uri tcp://" + serverAddress + "/80 url-handlers debug")) + serverAddress := s.VppAddr() + ":" + s.Ports.Http + s.Log(vpp.Vppctl("http static server uri tcp://" + serverAddress + " url-handlers debug")) client := NewHttpClient(defaultHttpTimeout, false) - req, err := http.NewRequest("GET", "http://"+serverAddress+":80/interface_list.json", nil) + req, err := http.NewRequest("GET", "http://"+serverAddress+"/interface_list.json", nil) s.AssertNil(err, fmt.Sprint(err)) resp, err := client.Do(req) s.AssertNil(err, fmt.Sprint(err)) @@ -1257,11 +1257,11 @@ func HttpStaticBuildInUrlGetIfListTest(s *NoTopoSuite) { func HttpStaticBuildInUrlGetIfStatsTest(s *NoTopoSuite) { vpp := s.Containers.Vpp.VppInstance - serverAddress := s.VppAddr() - s.Log(vpp.Vppctl("http static server uri tcp://" + serverAddress + "/80 url-handlers debug")) + serverAddress := s.VppAddr() + ":" + s.Ports.Http + s.Log(vpp.Vppctl("http static server uri tcp://" + serverAddress + " url-handlers debug")) client := NewHttpClient(defaultHttpTimeout, false) - req, err := http.NewRequest("GET", "http://"+serverAddress+":80/interface_stats.json", nil) + req, err := http.NewRequest("GET", "http://"+serverAddress+"/interface_stats.json", nil) s.AssertNil(err, fmt.Sprint(err)) resp, err := client.Do(req) s.AssertNil(err, fmt.Sprint(err)) @@ -1285,13 +1285,13 @@ func validatePostInterfaceStats(s *NoTopoSuite, data string) { func HttpStaticBuildInUrlPostIfStatsTest(s *NoTopoSuite) { vpp := s.Containers.Vpp.VppInstance - serverAddress := s.VppAddr() - s.Log(vpp.Vppctl("http static server uri tcp://" + serverAddress + "/80 url-handlers debug")) + serverAddress := s.VppAddr() + ":" + s.Ports.Http + s.Log(vpp.Vppctl("http static server uri tcp://" + serverAddress + " url-handlers debug")) body := []byte(s.VppIfName()) client := NewHttpClient(defaultHttpTimeout, false) req, err := http.NewRequest("POST", - "http://"+serverAddress+":80/interface_stats.json", bytes.NewBuffer(body)) + "http://"+serverAddress+"/interface_stats.json", bytes.NewBuffer(body)) s.AssertNil(err, fmt.Sprint(err)) resp, err := client.Do(req) s.AssertNil(err, fmt.Sprint(err)) @@ -1306,12 +1306,12 @@ func HttpStaticBuildInUrlPostIfStatsTest(s *NoTopoSuite) { func HttpStaticMacTimeTest(s *NoTopoSuite) { vpp := s.Containers.Vpp.VppInstance - serverAddress := s.VppAddr() - s.Log(vpp.Vppctl("http static server uri tcp://" + serverAddress + "/80 url-handlers debug")) + serverAddress := s.VppAddr() + ":" + s.Ports.Http + s.Log(vpp.Vppctl("http static server uri tcp://" + serverAddress + " url-handlers debug")) s.Log(vpp.Vppctl("mactime enable-disable " + s.VppIfName())) client := NewHttpClient(defaultHttpTimeout, false) - req, err := http.NewRequest("GET", "http://"+serverAddress+":80/mactime.json", nil) + req, err := http.NewRequest("GET", "http://"+serverAddress+"/mactime.json", nil) s.AssertNil(err, fmt.Sprint(err)) resp, err := client.Do(req) s.AssertNil(err, fmt.Sprint(err)) @@ -1332,56 +1332,56 @@ func HttpStaticMacTimeTest(s *NoTopoSuite) { func HttpInvalidRequestLineTest(s *NoTopoSuite) { vpp := s.Containers.Vpp.VppInstance - serverAddress := s.VppAddr() - vpp.Vppctl("http cli server") + serverAddress := s.VppAddr() + ":" + s.Ports.Http + vpp.Vppctl("http cli server uri http://" + serverAddress) - resp, err := TcpSendReceive(serverAddress+":80", " GET / HTTP/1.1") + resp, err := TcpSendReceive(serverAddress, " GET / HTTP/1.1") s.AssertNil(err, fmt.Sprint(err)) s.AssertContains(resp, "HTTP/1.1 400 Bad Request", "invalid request line start not allowed") - resp, err = TcpSendReceive(serverAddress+":80", "\rGET / HTTP/1.1") + resp, err = TcpSendReceive(serverAddress, "\rGET / HTTP/1.1") s.AssertNil(err, fmt.Sprint(err)) s.AssertContains(resp, "HTTP/1.1 400 Bad Request", "invalid request line start not allowed") - resp, err = TcpSendReceive(serverAddress+":80", "\nGET / HTTP/1.1") + resp, err = TcpSendReceive(serverAddress, "\nGET / HTTP/1.1") s.AssertNil(err, fmt.Sprint(err)) s.AssertContains(resp, "HTTP/1.1 400 Bad Request", "invalid request line start not allowed") - resp, err = TcpSendReceive(serverAddress+":80", "GET / HTTP/1.1") + resp, err = TcpSendReceive(serverAddress, "GET / HTTP/1.1") s.AssertNil(err, fmt.Sprint(err)) s.AssertContains(resp, "HTTP/1.1 400 Bad Request", "invalid framing not allowed") - resp, err = TcpSendReceive(serverAddress+":80", "GET / HTTP/1.1\r\n") + resp, err = TcpSendReceive(serverAddress, "GET / HTTP/1.1\r\n") s.AssertNil(err, fmt.Sprint(err)) s.AssertContains(resp, "HTTP/1.1 400 Bad Request", "invalid framing not allowed") - resp, err = TcpSendReceive(serverAddress+":80", "GET /\r\n\r\n") + resp, err = TcpSendReceive(serverAddress, "GET /\r\n\r\n") s.AssertNil(err, fmt.Sprint(err)) s.AssertContains(resp, "HTTP/1.1 400 Bad Request", "HTTP-version must be present") - resp, err = TcpSendReceive(serverAddress+":80", "GET HTTP/1.1\r\n\r\n") + resp, err = TcpSendReceive(serverAddress, "GET HTTP/1.1\r\n\r\n") s.AssertNil(err, fmt.Sprint(err)) s.AssertContains(resp, "HTTP/1.1 400 Bad Request", "request-target must be present") - resp, err = TcpSendReceive(serverAddress+":80", "GET HTTP/1.1\r\n\r\n") + resp, err = TcpSendReceive(serverAddress, "GET HTTP/1.1\r\n\r\n") s.AssertNil(err, fmt.Sprint(err)) s.AssertContains(resp, "HTTP/1.1 400 Bad Request", "request-target must be present") - resp, err = TcpSendReceive(serverAddress+":80", "GET / HTTP/x\r\n\r\n") + resp, err = TcpSendReceive(serverAddress, "GET / HTTP/x\r\n\r\n") s.AssertNil(err, fmt.Sprint(err)) s.AssertContains(resp, "HTTP/1.1 400 Bad Request", "'HTTP/x' invalid http version not allowed") - resp, err = TcpSendReceive(serverAddress+":80", "GET / HTTP1.1\r\n\r\n") + resp, err = TcpSendReceive(serverAddress, "GET / HTTP1.1\r\n\r\n") s.AssertNil(err, fmt.Sprint(err)) s.AssertContains(resp, "HTTP/1.1 400 Bad Request", "'HTTP1.1' invalid http version not allowed") } func HttpRequestLineTest(s *NoTopoSuite) { vpp := s.Containers.Vpp.VppInstance - serverAddress := s.VppAddr() - vpp.Vppctl("http cli server") + serverAddress := s.VppAddr() + ":" + s.Ports.Http + vpp.Vppctl("http cli server uri http://" + serverAddress) - resp, err := TcpSendReceive(serverAddress+":80", "\r\nGET /show/version HTTP/1.1\r\nHost:"+serverAddress+":80\r\nUser-Agent:test\r\n\r\n") + resp, err := TcpSendReceive(serverAddress, "\r\nGET /show/version HTTP/1.1\r\nHost:"+serverAddress+"\r\nUser-Agent:test\r\n\r\n") s.AssertNil(err, fmt.Sprint(err)) s.AssertContains(resp, "HTTP/1.1 200 OK") s.AssertContains(resp, "", "html content not found") @@ -1389,78 +1389,78 @@ func HttpRequestLineTest(s *NoTopoSuite) { func HttpInvalidTargetSyntaxTest(s *NoTopoSuite) { vpp := s.Containers.Vpp.VppInstance - serverAddress := s.VppAddr() - s.Log(vpp.Vppctl("http static server uri tcp://" + serverAddress + "/80 url-handlers debug")) + serverAddress := s.VppAddr() + ":" + s.Ports.Http + s.Log(vpp.Vppctl("http static server uri tcp://" + serverAddress + " url-handlers debug")) - resp, err := TcpSendReceive(serverAddress+":80", "GET /interface|stats.json HTTP/1.1\r\n\r\n") + resp, err := TcpSendReceive(serverAddress, "GET /interface|stats.json HTTP/1.1\r\n\r\n") s.AssertNil(err, fmt.Sprint(err)) s.AssertContains(resp, "HTTP/1.1 400 Bad Request", "'|' not allowed in target path") - resp, err = TcpSendReceive(serverAddress+":80", "GET /interface#stats.json HTTP/1.1\r\n\r\n") + resp, err = TcpSendReceive(serverAddress, "GET /interface#stats.json HTTP/1.1\r\n\r\n") s.AssertNil(err, fmt.Sprint(err)) s.AssertContains(resp, "HTTP/1.1 400 Bad Request", "'#' not allowed in target path") - resp, err = TcpSendReceive(serverAddress+":80", "GET /interface%stats.json HTTP/1.1\r\n\r\n") + resp, err = TcpSendReceive(serverAddress, "GET /interface%stats.json HTTP/1.1\r\n\r\n") s.AssertNil(err, fmt.Sprint(err)) s.AssertContains(resp, "HTTP/1.1 400 Bad Request", "after '%' there must be two hex-digit characters in target path") - resp, err = TcpSendReceive(serverAddress+":80", "GET /interface%1stats.json HTTP/1.1\r\n\r\n") + resp, err = TcpSendReceive(serverAddress, "GET /interface%1stats.json HTTP/1.1\r\n\r\n") s.AssertNil(err, fmt.Sprint(err)) s.AssertContains(resp, "HTTP/1.1 400 Bad Request", "after '%' there must be two hex-digit characters in target path") - resp, err = TcpSendReceive(serverAddress+":80", "GET /interface%Bstats.json HTTP/1.1\r\n\r\n") + resp, err = TcpSendReceive(serverAddress, "GET /interface%Bstats.json HTTP/1.1\r\n\r\n") s.AssertNil(err, fmt.Sprint(err)) s.AssertContains(resp, "HTTP/1.1 400 Bad Request", "after '%' there must be two hex-digit characters in target path") - resp, err = TcpSendReceive(serverAddress+":80", "GET /interface%stats.json%B HTTP/1.1\r\n\r\n") + resp, err = TcpSendReceive(serverAddress, "GET /interface%stats.json%B HTTP/1.1\r\n\r\n") s.AssertNil(err, fmt.Sprint(err)) s.AssertContains(resp, "HTTP/1.1 400 Bad Request", "after '%' there must be two hex-digit characters in target path") - resp, err = TcpSendReceive(serverAddress+":80", "GET /version.json?verbose>true HTTP/1.1\r\n\r\n") + resp, err = TcpSendReceive(serverAddress, "GET /version.json?verbose>true HTTP/1.1\r\n\r\n") s.AssertNil(err, fmt.Sprint(err)) s.AssertContains(resp, "HTTP/1.1 400 Bad Request", "'>' not allowed in target query") - resp, err = TcpSendReceive(serverAddress+":80", "GET /version.json?verbose%true HTTP/1.1\r\n\r\n") + resp, err = TcpSendReceive(serverAddress, "GET /version.json?verbose%true HTTP/1.1\r\n\r\n") s.AssertNil(err, fmt.Sprint(err)) s.AssertContains(resp, "HTTP/1.1 400 Bad Request", "after '%' there must be two hex-digit characters in target query") - resp, err = TcpSendReceive(serverAddress+":80", "GET /version.json?verbose=%1 HTTP/1.1\r\n\r\n") + resp, err = TcpSendReceive(serverAddress, "GET /version.json?verbose=%1 HTTP/1.1\r\n\r\n") s.AssertNil(err, fmt.Sprint(err)) s.AssertContains(resp, "HTTP/1.1 400 Bad Request", "after '%' there must be two hex-digit characters in target query") - resp, err = TcpSendReceive(serverAddress+":80", "GET * HTTP/1.1\r\n\r\n") + resp, err = TcpSendReceive(serverAddress, "GET * HTTP/1.1\r\n\r\n") s.AssertNil(err, fmt.Sprint(err)) s.AssertContains(resp, "HTTP/1.1 400 Bad Request", "asterisk-form is only used for a server-wide OPTIONS request") - resp, err = TcpSendReceive(serverAddress+":80", "GET www.example.com:80 HTTP/1.1\r\n\r\n") + resp, err = TcpSendReceive(serverAddress, "GET www.example.com:80 HTTP/1.1\r\n\r\n") s.AssertNil(err, fmt.Sprint(err)) s.AssertContains(resp, "HTTP/1.1 400 Bad Request", "authority-form is only used for CONNECT requests") - resp, err = TcpSendReceive(serverAddress+":80", "CONNECT https://www.example.com/tunnel HTTP/1.1\r\n\r\n") + resp, err = TcpSendReceive(serverAddress, "CONNECT https://www.example.com/tunnel HTTP/1.1\r\n\r\n") s.AssertNil(err, fmt.Sprint(err)) s.AssertContains(resp, "HTTP/1.1 400 Bad Request", "CONNECT requests must use authority-form only") } func HttpInvalidContentLengthTest(s *NoTopoSuite) { vpp := s.Containers.Vpp.VppInstance - serverAddress := s.VppAddr() - vpp.Vppctl("http cli server") + serverAddress := s.VppAddr() + ":" + s.Ports.Http + vpp.Vppctl("http cli server uri http://" + serverAddress) - resp, err := TcpSendReceive(serverAddress+":80", "GET /show/version HTTP/1.1\r\nContent-Length:\r\n\r\n") + resp, err := TcpSendReceive(serverAddress, "GET /show/version HTTP/1.1\r\nContent-Length:\r\n\r\n") s.AssertNil(err, fmt.Sprint(err)) s.AssertContains(resp, "HTTP/1.1 400 Bad Request", "Content-Length value must be present") - resp, err = TcpSendReceive(serverAddress+":80", "GET /show/version HTTP/1.1\r\nContent-Length: \r\n\r\n") + resp, err = TcpSendReceive(serverAddress, "GET /show/version HTTP/1.1\r\nContent-Length: \r\n\r\n") s.AssertNil(err, fmt.Sprint(err)) s.AssertContains(resp, "HTTP/1.1 400 Bad Request", "Content-Length value must be present") - resp, err = TcpSendReceive(serverAddress+":80", "GET /show/version HTTP/1.1\r\nContent-Length: a\r\n\r\n") + resp, err = TcpSendReceive(serverAddress, "GET /show/version HTTP/1.1\r\nContent-Length: a\r\n\r\n") s.AssertNil(err, fmt.Sprint(err)) s.AssertContains(resp, "HTTP/1.1 400 Bad Request", "Content-Length value other than digit not allowed") @@ -1469,7 +1469,7 @@ func HttpInvalidContentLengthTest(s *NoTopoSuite) { func HttpContentLengthTest(s *NoTopoSuite) { vpp := s.Containers.Vpp.VppInstance serverAddress := s.VppAddr() - s.Log(vpp.Vppctl("http static server uri tcp://" + serverAddress + "/80 url-handlers debug max-body-size 12")) + s.Log(vpp.Vppctl("http static server uri tcp://" + serverAddress + ":80 url-handlers debug max-body-size 12")) ifName := s.VppIfName() resp, err := TcpSendReceive(serverAddress+":80", @@ -1490,10 +1490,10 @@ func HttpContentLengthTest(s *NoTopoSuite) { func HttpHeaderErrorConnectionDropTest(s *NoTopoSuite) { vpp := s.Containers.Vpp.VppInstance - serverAddress := s.VppAddr() - s.Log(vpp.Vppctl("http static server uri tcp://" + serverAddress + "/80 url-handlers debug max-body-size 12")) + serverAddress := s.VppAddr() + ":" + s.Ports.Http + s.Log(vpp.Vppctl("http static server uri tcp://" + serverAddress + " url-handlers debug max-body-size 12")) request := "POST /interface_stats.json HTTP/1.1\r\nContent-Length: 18234234\r\n\r\n" + s.VppIfName() - conn, err := net.DialTimeout("tcp", serverAddress+":80", time.Second*30) + conn, err := net.DialTimeout("tcp", serverAddress, time.Second*30) s.AssertNil(err, fmt.Sprint(err)) err = conn.SetDeadline(time.Now().Add(time.Second * 10)) s.AssertNil(err, fmt.Sprint(err)) @@ -1509,11 +1509,11 @@ func HttpHeaderErrorConnectionDropTest(s *NoTopoSuite) { } func HttpMethodNotImplementedTest(s *NoTopoSuite) { vpp := s.Containers.Vpp.VppInstance - serverAddress := s.VppAddr() - vpp.Vppctl("http cli server") + serverAddress := s.VppAddr() + ":" + s.Ports.Http + vpp.Vppctl("http cli server uri http://" + serverAddress) client := NewHttpClient(defaultHttpTimeout, false) - req, err := http.NewRequest("OPTIONS", "http://"+serverAddress+":80/show/version", nil) + req, err := http.NewRequest("OPTIONS", "http://"+serverAddress+"/show/version", nil) s.AssertNil(err, fmt.Sprint(err)) resp, err := client.Do(req) s.AssertNil(err, fmt.Sprint(err)) @@ -1526,21 +1526,21 @@ func HttpMethodNotImplementedTest(s *NoTopoSuite) { func HttpVersionNotSupportedTest(s *NoTopoSuite) { vpp := s.Containers.Vpp.VppInstance - serverAddress := s.VppAddr() - vpp.Vppctl("http cli server") + serverAddress := s.VppAddr() + ":" + s.Ports.Http + vpp.Vppctl("http cli server uri http://" + serverAddress) - resp, err := TcpSendReceive(serverAddress+":80", "GET / HTTP/2\r\n\r\n") + resp, err := TcpSendReceive(serverAddress, "GET / HTTP/2\r\n\r\n") s.AssertNil(err, fmt.Sprint(err)) s.AssertContains(resp, "HTTP/1.1 505 HTTP Version Not Supported") } func HttpUriDecodeTest(s *NoTopoSuite) { vpp := s.Containers.Vpp.VppInstance - serverAddress := s.VppAddr() - vpp.Vppctl("http cli server") + serverAddress := s.VppAddr() + ":" + s.Ports.Http + vpp.Vppctl("http cli server uri http://" + serverAddress) client := NewHttpClient(defaultHttpTimeout, false) - req, err := http.NewRequest("GET", "http://"+serverAddress+":80/sh%6fw%20versio%6E%20verbose", nil) + req, err := http.NewRequest("GET", "http://"+serverAddress+"/sh%6fw%20versio%6E%20verbose", nil) s.AssertNil(err, fmt.Sprint(err)) resp, err := client.Do(req) s.AssertNil(err, fmt.Sprint(err)) @@ -1556,60 +1556,60 @@ func HttpUriDecodeTest(s *NoTopoSuite) { func HttpAbsoluteFormUriTest(s *NoTopoSuite) { vpp := s.Containers.Vpp.VppInstance - serverAddress := s.VppAddr() - vpp.Vppctl("http cli server") + serverAddress := s.VppAddr() + ":" + s.Ports.Http + vpp.Vppctl("http cli server uri http://" + serverAddress) - resp, err := TcpSendReceive(serverAddress+":80", "GET http://"+serverAddress+"/show/version HTTP/1.1\r\n\r\n") + resp, err := TcpSendReceive(serverAddress, "GET http://"+serverAddress+"/show/version HTTP/1.1\r\n\r\n") s.AssertNil(err, fmt.Sprint(err)) s.AssertContains(resp, "HTTP/1.1 200 OK") - resp, err = TcpSendReceive(serverAddress+":80", "GET http://"+serverAddress+":80/show/version HTTP/1.1\r\n\r\n") + resp, err = TcpSendReceive(serverAddress, "GET http://"+serverAddress+":80/show/version HTTP/1.1\r\n\r\n") s.AssertNil(err, fmt.Sprint(err)) s.AssertContains(resp, "HTTP/1.1 200 OK") } func HttpInvalidAuthorityFormUriTest(s *NoTopoSuite) { vpp := s.Containers.Vpp.VppInstance - serverAddress := s.VppAddr() - vpp.Vppctl("test proxy server fifo-size 512k server-uri http://%s/8080", serverAddress) + serverAddress := s.VppAddr() + ":" + s.Ports.Http + vpp.Vppctl("test proxy server fifo-size 512k server-uri http://%s", serverAddress) - resp, err := TcpSendReceive(serverAddress+":8080", "CONNECT 1.2.3.4:80a HTTP/1.1\r\n\r\n") + resp, err := TcpSendReceive(serverAddress, "CONNECT 1.2.3.4:80a HTTP/1.1\r\n\r\n") s.AssertNil(err, fmt.Sprint(err)) s.AssertContains(resp, "HTTP/1.1 400 Bad Request") - resp, err = TcpSendReceive(serverAddress+":8080", "CONNECT 1.2.3.4:80000000 HTTP/1.1\r\n\r\n") + resp, err = TcpSendReceive(serverAddress, "CONNECT 1.2.3.4:80000000 HTTP/1.1\r\n\r\n") s.AssertNil(err, fmt.Sprint(err)) s.AssertContains(resp, "HTTP/1.1 400 Bad Request") - resp, err = TcpSendReceive(serverAddress+":8080", "CONNECT 1.2a3.4:80 HTTP/1.1\r\n\r\n") + resp, err = TcpSendReceive(serverAddress, "CONNECT 1.2a3.4:80 HTTP/1.1\r\n\r\n") s.AssertNil(err, fmt.Sprint(err)) s.AssertContains(resp, "HTTP/1.1 400 Bad Request") - resp, err = TcpSendReceive(serverAddress+":8080", "CONNECT 1.2.4:80 HTTP/1.1\r\n\r\n") + resp, err = TcpSendReceive(serverAddress, "CONNECT 1.2.4:80 HTTP/1.1\r\n\r\n") s.AssertNil(err, fmt.Sprint(err)) s.AssertContains(resp, "HTTP/1.1 400 Bad Request") - resp, err = TcpSendReceive(serverAddress+":8080", "CONNECT [dead:beef::1234:443 HTTP/1.1\r\n\r\n") + resp, err = TcpSendReceive(serverAddress, "CONNECT [dead:beef::1234:443 HTTP/1.1\r\n\r\n") s.AssertNil(err, fmt.Sprint(err)) s.AssertContains(resp, "HTTP/1.1 400 Bad Request") - resp, err = TcpSendReceive(serverAddress+":8080", "CONNECT [zyx:beef::1234]:443 HTTP/1.1\r\n\r\n") + resp, err = TcpSendReceive(serverAddress, "CONNECT [zyx:beef::1234]:443 HTTP/1.1\r\n\r\n") s.AssertNil(err, fmt.Sprint(err)) s.AssertContains(resp, "HTTP/1.1 400 Bad Request") - resp, err = TcpSendReceive(serverAddress+":8080", "CONNECT dead:beef::1234:443 HTTP/1.1\r\n\r\n") + resp, err = TcpSendReceive(serverAddress, "CONNECT dead:beef::1234:443 HTTP/1.1\r\n\r\n") s.AssertNil(err, fmt.Sprint(err)) s.AssertContains(resp, "HTTP/1.1 400 Bad Request") - resp, err = TcpSendReceive(serverAddress+":8080", "CONNECT example.org:443 HTTP/1.1\r\n\r\n") + resp, err = TcpSendReceive(serverAddress, "CONNECT example.org:443 HTTP/1.1\r\n\r\n") s.AssertNil(err, fmt.Sprint(err)) s.AssertContains(resp, "HTTP/1.1 400 Bad Request", "name resolution not supported") } func HttpHeadersTest(s *NoTopoSuite) { vpp := s.Containers.Vpp.VppInstance - serverAddress := s.VppAddr() - vpp.Vppctl("http cli server") + serverAddress := s.VppAddr() + ":" + s.Ports.Http + vpp.Vppctl("http cli server uri http://" + serverAddress) transport := http.DefaultTransport transport.(*http.Transport).Proxy = nil @@ -1619,7 +1619,7 @@ func HttpHeadersTest(s *NoTopoSuite) { Timeout: time.Second * 30, } - req, err := http.NewRequest("GET", "http://"+serverAddress+":80/show/version", nil) + req, err := http.NewRequest("GET", "http://"+serverAddress+"/show/version", nil) s.AssertNil(err, fmt.Sprint(err)) req.Header.Add("Accept", "text/xml") req.Header.Add("Accept-Language", "*") @@ -1635,7 +1635,7 @@ func HttpHeadersTest(s *NoTopoSuite) { s.AssertNil(err, fmt.Sprint(err)) s.AssertNotContains(string(data), "", "html content received instead of plain text") - req2, err := http.NewRequest("GET", "http://"+serverAddress+":80/show/version", nil) + req2, err := http.NewRequest("GET", "http://"+serverAddress+"/show/version", nil) s.AssertNil(err, fmt.Sprint(err)) req2.Header.Add("Accept", "text/html") resp2, err := client.Do(req2) @@ -1652,7 +1652,7 @@ func HttpHeadersTest(s *NoTopoSuite) { client.CloseIdleConnections() for nTries := 0; nTries < 10; nTries++ { o := vpp.Vppctl("show session verbose 2") - if !strings.Contains(o, serverAddress+":80->"+s.HostAddr()) { + if !strings.Contains(o, serverAddress+"->"+s.HostAddr()) { break } time.Sleep(1 * time.Second) @@ -1661,49 +1661,49 @@ func HttpHeadersTest(s *NoTopoSuite) { func HttpInvalidHeadersTest(s *NoTopoSuite) { vpp := s.Containers.Vpp.VppInstance - serverAddress := s.VppAddr() - vpp.Vppctl("http cli server") + serverAddress := s.VppAddr() + ":" + s.Ports.Http + vpp.Vppctl("http cli server uri http://" + serverAddress) - resp, err := TcpSendReceive(serverAddress+":80", "GET /show/version HTTP/1.1\r\nUser-Agent: test\r\n") + resp, err := TcpSendReceive(serverAddress, "GET /show/version HTTP/1.1\r\nUser-Agent: test\r\n") s.AssertNil(err, fmt.Sprint(err)) s.AssertContains(resp, "HTTP/1.1 400 Bad Request", "Header section must end with CRLF CRLF") - resp, err = TcpSendReceive(serverAddress+":80", "GET /show/version HTTP/1.1\r\nHost:"+serverAddress+":80\r\nUser@Agent:test\r\n\r\n") + resp, err = TcpSendReceive(serverAddress, "GET /show/version HTTP/1.1\r\nHost:"+serverAddress+":80\r\nUser@Agent:test\r\n\r\n") s.AssertNil(err, fmt.Sprint(err)) s.AssertContains(resp, "HTTP/1.1 400 Bad Request", "'@' not allowed in field name") - resp, err = TcpSendReceive(serverAddress+":80", "GET /show/version HTTP/1.1\r\nHost:"+serverAddress+":80\r\nUser-Agent\r\n\r\n") + resp, err = TcpSendReceive(serverAddress, "GET /show/version HTTP/1.1\r\nHost:"+serverAddress+":80\r\nUser-Agent\r\n\r\n") s.AssertNil(err, fmt.Sprint(err)) s.AssertContains(resp, "HTTP/1.1 400 Bad Request", "incomplete field line not allowed") - resp, err = TcpSendReceive(serverAddress+":80", "GET /show/version HTTP/1.1\r\nHost:"+serverAddress+":80\r\n: test\r\n\r\n") + resp, err = TcpSendReceive(serverAddress, "GET /show/version HTTP/1.1\r\nHost:"+serverAddress+":80\r\n: test\r\n\r\n") s.AssertNil(err, fmt.Sprint(err)) s.AssertContains(resp, "HTTP/1.1 400 Bad Request", "empty field name not allowed") - resp, err = TcpSendReceive(serverAddress+":80", "GET /show/version HTTP/1.1\r\nHost:"+serverAddress+":80\rUser-Agent:test\r\n\r\n") + resp, err = TcpSendReceive(serverAddress, "GET /show/version HTTP/1.1\r\nHost:"+serverAddress+":80\rUser-Agent:test\r\n\r\n") s.AssertNil(err, fmt.Sprint(err)) s.AssertContains(resp, "HTTP/1.1 400 Bad Request", "invalid field line end not allowed") - resp, err = TcpSendReceive(serverAddress+":80", "GET /show/version HTTP/1.1\r\nHost:"+serverAddress+":80\nUser-Agent:test\r\n\r\n") + resp, err = TcpSendReceive(serverAddress, "GET /show/version HTTP/1.1\r\nHost:"+serverAddress+":80\nUser-Agent:test\r\n\r\n") s.AssertNil(err, fmt.Sprint(err)) s.AssertContains(resp, "HTTP/1.1 400 Bad Request", "invalid field line end not allowed") - resp, err = TcpSendReceive(serverAddress+":80", "GET /show/version HTTP/1.1\r\nHost:"+serverAddress+":80\r\nUser-Agent:\r\n\r\n") + resp, err = TcpSendReceive(serverAddress, "GET /show/version HTTP/1.1\r\nHost:"+serverAddress+":80\r\nUser-Agent:\r\n\r\n") s.AssertNil(err, fmt.Sprint(err)) s.AssertContains(resp, "HTTP/1.1 400 Bad Request", "empty field value not allowed") - resp, err = TcpSendReceive(serverAddress+":80", "GET /show/version HTTP/1.1\r\nHost:"+serverAddress+":80\r\nUser-Agent: \r\n\r\n") + resp, err = TcpSendReceive(serverAddress, "GET /show/version HTTP/1.1\r\nHost:"+serverAddress+":80\r\nUser-Agent: \r\n\r\n") s.AssertNil(err, fmt.Sprint(err)) s.AssertContains(resp, "HTTP/1.1 400 Bad Request", "empty field value not allowed") } func HeaderServerTest(s *NoTopoSuite) { vpp := s.Containers.Vpp.VppInstance - serverAddress := s.VppAddr() - vpp.Vppctl("http cli server") + serverAddress := s.VppAddr() + ":" + s.Ports.Http + vpp.Vppctl("http cli server uri http://" + serverAddress) client := NewHttpClient(defaultHttpTimeout, false) - req, err := http.NewRequest("GET", "http://"+serverAddress+":80/show/version", nil) + req, err := http.NewRequest("GET", "http://"+serverAddress+"/show/version", nil) s.AssertNil(err, fmt.Sprint(err)) resp, err := client.Do(req) s.AssertNil(err, fmt.Sprint(err)) @@ -1716,11 +1716,11 @@ func HeaderServerTest(s *NoTopoSuite) { func HttpConnTimeoutTest(s *NoTopoSuite) { vpp := s.Containers.Vpp.VppInstance - serverAddress := s.VppAddr() - s.Log(vpp.Vppctl("http static server uri tcp://" + serverAddress + "/80 url-handlers debug keepalive-timeout 2")) + serverAddress := s.VppAddr() + ":" + s.Ports.Http + s.Log(vpp.Vppctl("http static server uri tcp://" + serverAddress + " url-handlers debug keepalive-timeout 2")) - req := "GET /version.json HTTP/1.1\r\nHost:" + serverAddress + ":80\r\nUser-Agent:test\r\n\r\n" - conn, err := net.DialTimeout("tcp", serverAddress+":80", time.Second*30) + req := "GET /version.json HTTP/1.1\r\nHost:" + serverAddress + "\r\nUser-Agent:test\r\n\r\n" + conn, err := net.DialTimeout("tcp", serverAddress, time.Second*30) s.AssertNil(err, fmt.Sprint(err)) defer conn.Close() err = conn.SetDeadline(time.Now().Add(time.Second * 30)) @@ -1746,8 +1746,8 @@ func HttpConnTimeoutTest(s *NoTopoSuite) { func HttpIgnoreH2UpgradeTest(s *NoTopoSuite) { vpp := s.Containers.Vpp.VppInstance - serverAddress := s.VppAddr() - s.Log(vpp.Vppctl("http static server uri tcp://" + serverAddress + "/80 url-handlers")) + serverAddress := s.VppAddr() + ":" + s.Ports.Http + s.Log(vpp.Vppctl("http static server uri tcp://" + serverAddress + " url-handlers")) transport := http.DefaultTransport transport.(*http.Transport).Proxy = nil @@ -1757,7 +1757,7 @@ func HttpIgnoreH2UpgradeTest(s *NoTopoSuite) { Timeout: time.Second * 30, } - req, err := http.NewRequest("GET", "http://"+serverAddress+":80/version.json", nil) + req, err := http.NewRequest("GET", "http://"+serverAddress+"/version.json", nil) s.AssertNil(err, fmt.Sprint(err)) req.Header.Add("Connection", "Upgrade") req.Header.Add("Upgrade", "HTTP/2.0") diff --git a/extras/hs-test/infra/common/suite_common.go b/extras/hs-test/infra/common/suite_common.go index 72173c6261a..163faa96115 100644 --- a/extras/hs-test/infra/common/suite_common.go +++ b/extras/hs-test/infra/common/suite_common.go @@ -59,14 +59,14 @@ func (s *HstCommon) SetupSuite() { func (s *HstCommon) TeardownTest() { if *IsPersistent || *DryRun { - return + s.Skip("Skipping test teardown") } s.Log("[* TEST TEARDOWN]") } func (s *HstCommon) TeardownSuite() { if *IsPersistent || *DryRun { - return + s.Skip("Skipping suite teardown") } s.Log("[* SUITE TEARDOWN]") } diff --git a/extras/hs-test/infra/hst_suite.go b/extras/hs-test/infra/hst_suite.go index 03eaff58d89..2fb05a48d8c 100644 --- a/extras/hs-test/infra/hst_suite.go +++ b/extras/hs-test/infra/hst_suite.go @@ -50,6 +50,7 @@ type HstSuite struct { CpuCount int Docker *client.Client CoverageRun bool + numOfNewPorts int } type colors struct { @@ -181,6 +182,8 @@ func (s *HstSuite) AddCpuContext(cpuCtx *CpuContext) { func (s *HstSuite) TeardownSuite() { s.HstCommon.TeardownSuite() + // allow ports to be reused by removing them from reservedPorts slice + reservedPorts = reservedPorts[:len(reservedPorts)-s.numOfNewPorts] defer s.LogFile.Close() defer s.Docker.Close() s.UnconfigureNetworkTopology() @@ -584,8 +587,8 @@ func (s *HstSuite) GetCurrentSuiteName() string { } // Returns last 3 digits of PID + Ginkgo process index as the 4th digit. If the port is in the 'reservedPorts' slice, -// increment port number by ten and check again. -func (s *HstSuite) GetPortFromPpid() string { +// increment port number by ten and check again. Generates a new port after each use. +func (s *HstSuite) GeneratePort() string { port := s.Ppid var err error var portInt int @@ -599,9 +602,17 @@ func (s *HstSuite) GetPortFromPpid() string { portInt += 10 port = fmt.Sprintf("%d", portInt) } + reservedPorts = append(reservedPorts, port) + s.numOfNewPorts++ return port } +func (s *HstSuite) GeneratePortAsInt() uint16 { + port, err := strconv.Atoi(s.GeneratePort()) + s.AssertNil(err) + return uint16(port) +} + /* RunBenchmark creates Gomega's experiment with the passed-in name and samples the passed-in callback repeatedly (samplesNum times), passing in suite context, experiment and your data. diff --git a/extras/hs-test/infra/suite_envoy_proxy.go b/extras/hs-test/infra/suite_envoy_proxy.go index 79d9372588e..7119b0ff1d9 100644 --- a/extras/hs-test/infra/suite_envoy_proxy.go +++ b/extras/hs-test/infra/suite_envoy_proxy.go @@ -18,8 +18,6 @@ import ( type EnvoyProxySuite struct { HstSuite - nginxPort uint16 - proxyPort uint16 maxTimeout int Interfaces struct { Server *NetInterface @@ -31,6 +29,11 @@ type EnvoyProxySuite struct { Vpp *Container Curl *Container } + Ports struct { + Nginx uint16 + Proxy uint16 + EnvoyAdmin uint16 + } } var envoyProxyTests = map[string][]func(s *EnvoyProxySuite){} @@ -60,6 +63,8 @@ func (s *EnvoyProxySuite) SetupSuite() { s.Containers.Vpp = s.GetContainerByName("vpp") s.Containers.EnvoyProxy = s.GetContainerByName("envoy-vcl") s.Containers.Curl = s.GetContainerByName("curl") + s.Ports.Nginx = s.GeneratePortAsInt() + s.Ports.Proxy = s.GeneratePortAsInt() } func (s *EnvoyProxySuite) SetupTest() { @@ -79,7 +84,6 @@ func (s *EnvoyProxySuite) SetupTest() { // nginx HTTP server s.AssertNil(s.Containers.NginxServerTransient.Create()) - s.nginxPort = 80 nginxSettings := struct { LogPrefix string Address string @@ -88,7 +92,7 @@ func (s *EnvoyProxySuite) SetupTest() { }{ LogPrefix: s.Containers.NginxServerTransient.Name, Address: s.Interfaces.Server.Ip4AddressString(), - Port: s.nginxPort, + Port: s.Ports.Nginx, Timeout: s.maxTimeout, } s.Containers.NginxServerTransient.CreateConfigFromTemplate( @@ -100,17 +104,20 @@ func (s *EnvoyProxySuite) SetupTest() { // Envoy s.AssertNil(s.Containers.EnvoyProxy.Create()) - s.proxyPort = 8080 envoySettings := struct { - LogPrefix string - ServerAddress string - ServerPort uint16 - ProxyPort uint16 + LogPrefix string + ServerAddress string + ServerPort uint16 + ProxyPort uint16 + ProxyAddr string + EnvoyAdminPort uint16 }{ - LogPrefix: s.Containers.EnvoyProxy.Name, - ServerAddress: s.Interfaces.Server.Ip4AddressString(), - ServerPort: s.nginxPort, - ProxyPort: s.proxyPort, + LogPrefix: s.Containers.EnvoyProxy.Name, + ServerAddress: s.Interfaces.Server.Ip4AddressString(), + ServerPort: s.Ports.Nginx, + ProxyPort: s.Ports.Proxy, + ProxyAddr: s.ProxyAddr(), + EnvoyAdminPort: s.Ports.EnvoyAdmin, } s.Containers.EnvoyProxy.CreateConfigFromTemplate( "/etc/envoy/envoy.yaml", @@ -134,7 +141,7 @@ func (s *EnvoyProxySuite) SetupTest() { if *DryRun { vpp.AppendToCliConfig(arp) s.LogStartedContainers() - s.Log("%s* Proxy IP used in tests: %s:%d%s", Colors.pur, s.ProxyAddr(), s.ProxyPort(), Colors.rst) + s.Log("%s* Proxy IP used in tests: %s:%d%s", Colors.pur, s.ProxyAddr(), s.Ports.Proxy, Colors.rst) s.Skip("Dry run mode = true") } @@ -151,10 +158,6 @@ func (s *EnvoyProxySuite) TeardownTest() { s.HstSuite.TeardownTest() } -func (s *EnvoyProxySuite) ProxyPort() uint16 { - return s.proxyPort -} - func (s *EnvoyProxySuite) ProxyAddr() string { return s.Interfaces.Client.Peer.Ip4AddressString() } diff --git a/extras/hs-test/infra/suite_h2.go b/extras/hs-test/infra/suite_h2.go index 04919ad784a..36fc29493ca 100644 --- a/extras/hs-test/infra/suite_h2.go +++ b/extras/hs-test/infra/suite_h2.go @@ -6,6 +6,7 @@ import ( "os" "reflect" "runtime" + "strconv" "strings" "time" @@ -20,6 +21,7 @@ import ( ) var h2Tests = map[string][]func(s *H2Suite){} +var h2SoloTests = map[string][]func(s *H2Suite){} type H2Suite struct { HstSuite @@ -31,11 +33,18 @@ type H2Suite struct { Curl *Container H2load *Container } + Ports struct { + Port1 string + Port1AsInt int + } } func RegisterH2Tests(tests ...func(s *H2Suite)) { h2Tests[GetTestFilename()] = tests } +func RegisterH2SoloTests(tests ...func(s *H2Suite)) { + h2SoloTests[GetTestFilename()] = tests +} func (s *H2Suite) SetupSuite() { s.HstSuite.SetupSuite() @@ -45,6 +54,10 @@ func (s *H2Suite) SetupSuite() { s.Containers.Vpp = s.GetContainerByName("vpp") s.Containers.Curl = s.GetContainerByName("curl") s.Containers.H2load = s.GetContainerByName("h2load") + s.Ports.Port1 = s.GeneratePort() + var err error + s.Ports.Port1AsInt, err = strconv.Atoi(s.Ports.Port1) + s.AssertNil(err) } func (s *H2Suite) SetupTest() { @@ -105,6 +118,36 @@ var _ = Describe("Http2Suite", Ordered, ContinueOnFailure, func() { } }) +// Marked as pending since http plugin is not build with http/2 enabled by default +var _ = Describe("Http2SoloSuite", Ordered, ContinueOnFailure, Serial, func() { + var s H2Suite + BeforeAll(func() { + s.SetupSuite() + }) + BeforeEach(func() { + s.SetupTest() + }) + AfterAll(func() { + s.TeardownSuite() + }) + AfterEach(func() { + s.TeardownTest() + }) + + for filename, tests := range h2SoloTests { + for _, test := range tests { + test := test + pc := reflect.ValueOf(test).Pointer() + funcValue := runtime.FuncForPC(pc) + testName := filename + "/" + strings.Split(funcValue.Name(), ".")[2] + It(testName, Label("SOLO"), func(ctx SpecContext) { + s.Log(testName + ": BEGIN") + test(&s) + }, SpecTimeout(TestTimeout)) + } + } +}) + type h2specTest struct { desc string } @@ -320,11 +363,11 @@ var _ = Describe("H2SpecSuite", Ordered, ContinueOnFailure, func() { s.Log(testName + ": BEGIN") vpp := s.Containers.Vpp.VppInstance serverAddress := s.VppAddr() - s.Log(vpp.Vppctl("http static server uri tls://" + serverAddress + "/443 url-handlers debug 2")) + s.Log(vpp.Vppctl("http static server uri tls://" + serverAddress + "/" + s.Ports.Port1 + " url-handlers debug 2")) s.Log(vpp.Vppctl("test-url-handler enable")) conf := &config.Config{ Host: serverAddress, - Port: 443, + Port: s.Ports.Port1AsInt, Path: "/test1", Timeout: time.Second * 5, MaxHeaderLen: 1024, diff --git a/extras/hs-test/infra/suite_iperf_linux.go b/extras/hs-test/infra/suite_iperf_linux.go index 10cedf73371..be41e5082a3 100644 --- a/extras/hs-test/infra/suite_iperf_linux.go +++ b/extras/hs-test/infra/suite_iperf_linux.go @@ -20,6 +20,9 @@ type IperfSuite struct { Server *Container Client *Container } + Ports struct { + Port1 string + } } var iperfTests = map[string][]func(s *IperfSuite){} @@ -41,6 +44,7 @@ func (s *IperfSuite) SetupSuite() { s.Interfaces.Server = s.GetInterfaceByName("hstsrv") s.Containers.Server = s.GetContainerByName("server") s.Containers.Client = s.GetContainerByName("client") + s.Ports.Port1 = s.GeneratePort() } var _ = Describe("IperfSuite", Ordered, ContinueOnFailure, func() { diff --git a/extras/hs-test/infra/suite_ldp.go b/extras/hs-test/infra/suite_ldp.go index bdc718e8978..1127f13fbc3 100644 --- a/extras/hs-test/infra/suite_ldp.go +++ b/extras/hs-test/infra/suite_ldp.go @@ -26,6 +26,9 @@ type LdpSuite struct { ServerApp *Container ClientApp *Container } + Ports struct { + Port1 string + } } func RegisterLdpTests(tests ...func(s *LdpSuite)) { @@ -46,6 +49,7 @@ func (s *LdpSuite) SetupSuite() { s.Containers.ClientVpp = s.GetContainerByName("client-vpp") s.Containers.ServerApp = s.GetContainerByName("server-app") s.Containers.ClientApp = s.GetContainerByName("client-app") + s.Ports.Port1 = s.GeneratePort() } func (s *LdpSuite) SetupTest() { diff --git a/extras/hs-test/infra/suite_nginx_proxy.go b/extras/hs-test/infra/suite_nginx_proxy.go index a259db36b58..8006e6fd4d7 100644 --- a/extras/hs-test/infra/suite_nginx_proxy.go +++ b/extras/hs-test/infra/suite_nginx_proxy.go @@ -15,7 +15,6 @@ var nginxProxySoloTests = map[string][]func(s *NginxProxySuite){} type NginxProxySuite struct { HstSuite - proxyPort uint16 maxTimeout int Interfaces struct { Server *NetInterface @@ -27,6 +26,12 @@ type NginxProxySuite struct { Vpp *Container Curl *Container } + Ports struct { + Proxy uint16 + Upstream1 string + Upstream2 string + Upstream3 string + } } func RegisterNginxProxyTests(tests ...func(s *NginxProxySuite)) { @@ -52,6 +57,10 @@ func (s *NginxProxySuite) SetupSuite() { s.Containers.NginxServerTransient = s.GetTransientContainerByName("nginx-server") s.Containers.Vpp = s.GetContainerByName("vpp") s.Containers.Curl = s.GetContainerByName("curl") + s.Ports.Proxy = s.GeneratePortAsInt() + s.Ports.Upstream1 = s.GeneratePort() + s.Ports.Upstream2 = s.GeneratePort() + s.Ports.Upstream3 = s.GeneratePort() } func (s *NginxProxySuite) SetupTest() { @@ -69,7 +78,6 @@ func (s *NginxProxySuite) SetupTest() { // nginx proxy s.AssertNil(s.Containers.NginxProxy.Create()) - s.proxyPort = 80 // nginx HTTP server s.AssertNil(s.Containers.NginxServerTransient.Create()) @@ -77,10 +85,16 @@ func (s *NginxProxySuite) SetupTest() { LogPrefix string Address string Timeout int + Upstream1 string + Upstream2 string + Upstream3 string }{ LogPrefix: s.Containers.NginxServerTransient.Name, Address: s.Interfaces.Server.Ip4AddressString(), Timeout: s.maxTimeout, + Upstream1: s.Ports.Upstream1, + Upstream2: s.Ports.Upstream2, + Upstream3: s.Ports.Upstream3, } s.Containers.NginxServerTransient.CreateConfigFromTemplate( "/nginx.conf", @@ -123,12 +137,18 @@ func (s *NginxProxySuite) CreateNginxProxyConfig(container *Container, multiThre Proxy string Server string Port uint16 + Upstream1 string + Upstream2 string + Upstream3 string }{ Workers: workers, LogPrefix: container.Name, Proxy: s.Interfaces.Client.Peer.Ip4AddressString(), Server: s.Interfaces.Server.Ip4AddressString(), - Port: s.proxyPort, + Port: s.Ports.Proxy, + Upstream1: s.Ports.Upstream1, + Upstream2: s.Ports.Upstream2, + Upstream3: s.Ports.Upstream3, } container.CreateConfigFromTemplate( "/nginx.conf", @@ -138,7 +158,7 @@ func (s *NginxProxySuite) CreateNginxProxyConfig(container *Container, multiThre } func (s *NginxProxySuite) ProxyPort() uint16 { - return s.proxyPort + return s.Ports.Proxy } func (s *NginxProxySuite) ProxyAddr() string { diff --git a/extras/hs-test/infra/suite_no_topo.go b/extras/hs-test/infra/suite_no_topo.go index dd77c157e60..2d96ac9cd2d 100644 --- a/extras/hs-test/infra/suite_no_topo.go +++ b/extras/hs-test/infra/suite_no_topo.go @@ -27,7 +27,11 @@ type NoTopoSuite struct { Curl *Container Ab *Container } - NginxServerPort string + Ports struct { + NginxServer string + NginxHttp3 string + Http string + } } func RegisterNoTopoTests(tests ...func(s *NoTopoSuite)) { @@ -49,6 +53,9 @@ func (s *NoTopoSuite) SetupSuite() { s.Containers.Wrk = s.GetContainerByName("wrk") s.Containers.Curl = s.GetContainerByName("curl") s.Containers.Ab = s.GetContainerByName("ab") + s.Ports.Http = s.GeneratePort() + s.Ports.NginxServer = s.GeneratePort() + s.Ports.NginxHttp3 = s.GeneratePort() } func (s *NoTopoSuite) SetupTest() { @@ -95,8 +102,10 @@ func (s *NoTopoSuite) CreateNginxConfig(container *Container, multiThreadWorkers } values := struct { Workers uint8 + Port string }{ Workers: workers, + Port: s.Ports.NginxServer, } container.CreateConfigFromTemplate( "/nginx.conf", @@ -108,7 +117,6 @@ func (s *NoTopoSuite) CreateNginxConfig(container *Container, multiThreadWorkers // Creates container and config. func (s *NoTopoSuite) CreateNginxServer() { s.AssertNil(s.Containers.NginxServer.Create()) - s.NginxServerPort = s.GetPortFromPpid() nginxSettings := struct { LogPrefix string Address string @@ -117,7 +125,7 @@ func (s *NoTopoSuite) CreateNginxServer() { }{ LogPrefix: s.Containers.NginxServer.Name, Address: s.Interfaces.Tap.Ip4AddressString(), - Port: s.NginxServerPort, + Port: s.Ports.NginxServer, Timeout: 600, } s.Containers.NginxServer.CreateConfigFromTemplate( @@ -166,8 +174,12 @@ func (s *NoTopoSuite) HostAddr() string { func (s *NoTopoSuite) CreateNginxHttp3Config(container *Container) { nginxSettings := struct { LogPrefix string + Address string + Port string }{ LogPrefix: container.Name, + Address: s.VppAddr(), + Port: s.Ports.NginxHttp3, } container.CreateConfigFromTemplate( "/nginx.conf", diff --git a/extras/hs-test/infra/suite_no_topo6.go b/extras/hs-test/infra/suite_no_topo6.go index ac617c8fcfd..8b67791597f 100644 --- a/extras/hs-test/infra/suite_no_topo6.go +++ b/extras/hs-test/infra/suite_no_topo6.go @@ -27,7 +27,10 @@ type NoTopo6Suite struct { Curl *Container Ab *Container } - NginxServerPort string + Ports struct { + NginxServer string + Http string + } } func RegisterNoTopo6Tests(tests ...func(s *NoTopo6Suite)) { @@ -49,6 +52,8 @@ func (s *NoTopo6Suite) SetupSuite() { s.Containers.Wrk = s.GetContainerByName("wrk") s.Containers.Curl = s.GetContainerByName("curl") s.Containers.Ab = s.GetContainerByName("ab") + s.Ports.Http = s.GeneratePort() + s.Ports.NginxServer = s.GeneratePort() } func (s *NoTopo6Suite) SetupTest() { @@ -95,8 +100,10 @@ func (s *NoTopo6Suite) CreateNginxConfig(container *Container, multiThreadWorker } values := struct { Workers uint8 + Port string }{ Workers: workers, + Port: s.Ports.NginxServer, } container.CreateConfigFromTemplate( "/nginx.conf", @@ -108,7 +115,6 @@ func (s *NoTopo6Suite) CreateNginxConfig(container *Container, multiThreadWorker // Creates container and config. func (s *NoTopo6Suite) CreateNginxServer() { s.AssertNil(s.Containers.NginxServer.Create()) - s.NginxServerPort = s.GetPortFromPpid() nginxSettings := struct { LogPrefix string Address string @@ -117,7 +123,7 @@ func (s *NoTopo6Suite) CreateNginxServer() { }{ LogPrefix: s.Containers.NginxServer.Name, Address: "[" + s.Interfaces.Tap.Ip6AddressString() + "]", - Port: s.NginxServerPort, + Port: s.Ports.NginxServer, Timeout: 600, } s.Containers.NginxServer.CreateConfigFromTemplate( diff --git a/extras/hs-test/infra/suite_veth.go b/extras/hs-test/infra/suite_veth.go index 4dc6b5993bf..2b7832e2880 100644 --- a/extras/hs-test/infra/suite_veth.go +++ b/extras/hs-test/infra/suite_veth.go @@ -26,6 +26,10 @@ type VethsSuite struct { ServerApp *Container ClientApp *Container } + Ports struct { + Port1 string + Port2 string + } } func RegisterVethTests(tests ...func(s *VethsSuite)) { @@ -46,6 +50,8 @@ func (s *VethsSuite) SetupSuite() { s.Containers.ClientVpp = s.GetContainerByName("client-vpp") s.Containers.ServerApp = s.GetContainerByName("server-app") s.Containers.ClientApp = s.GetContainerByName("client-app") + s.Ports.Port1 = s.GeneratePort() + s.Ports.Port2 = s.GeneratePort() } func (s *VethsSuite) SetupTest() { diff --git a/extras/hs-test/infra/suite_veth6.go b/extras/hs-test/infra/suite_veth6.go index 694972c406a..2e3fe98c3b2 100644 --- a/extras/hs-test/infra/suite_veth6.go +++ b/extras/hs-test/infra/suite_veth6.go @@ -26,6 +26,9 @@ type Veths6Suite struct { ServerApp *Container ClientApp *Container } + Ports struct { + Port1 string + } } func RegisterVeth6Tests(tests ...func(s *Veths6Suite)) { @@ -46,6 +49,7 @@ func (s *Veths6Suite) SetupSuite() { s.Containers.ClientVpp = s.GetContainerByName("client-vpp") s.Containers.ServerApp = s.GetContainerByName("server-app") s.Containers.ClientApp = s.GetContainerByName("client-app") + s.Ports.Port1 = s.GeneratePort() } func (s *Veths6Suite) SetupTest() { diff --git a/extras/hs-test/infra/suite_vpp_proxy.go b/extras/hs-test/infra/suite_vpp_proxy.go index b0881993d81..ec08a630d26 100644 --- a/extras/hs-test/infra/suite_vpp_proxy.go +++ b/extras/hs-test/infra/suite_vpp_proxy.go @@ -23,7 +23,6 @@ const ( type VppProxySuite struct { HstSuite - serverPort uint16 maxTimeout int Interfaces struct { Client *NetInterface @@ -36,6 +35,10 @@ type VppProxySuite struct { IperfS *Container IperfC *Container } + Ports struct { + Server uint16 + Proxy uint16 + } } var vppProxyTests = map[string][]func(s *VppProxySuite){} @@ -53,8 +56,9 @@ func (s *VppProxySuite) SetupSuite() { s.HstSuite.SetupSuite() s.LoadNetworkTopology("2taps") s.LoadContainerTopology("vppProxy") + s.Ports.Server = s.GeneratePortAsInt() + s.Ports.Proxy = s.GeneratePortAsInt() - s.serverPort = 80 if *IsVppDebug { s.maxTimeout = 600 } else { @@ -109,7 +113,7 @@ func (s *VppProxySuite) SetupNginxServer() { }{ LogPrefix: s.Containers.NginxServerTransient.Name, Address: s.Interfaces.Server.Ip4AddressString(), - Port: s.serverPort, + Port: s.Ports.Server, Timeout: s.maxTimeout, } s.Containers.NginxServerTransient.CreateConfigFromTemplate( @@ -120,10 +124,6 @@ func (s *VppProxySuite) SetupNginxServer() { s.AssertNil(s.Containers.NginxServerTransient.Start()) } -func (s *VppProxySuite) ServerPort() uint16 { - return s.serverPort -} - func (s *VppProxySuite) ServerAddr() string { return s.Interfaces.Server.Ip4AddressString() } @@ -198,7 +198,7 @@ func handleConn(conn net.Conn) { } func (s *VppProxySuite) StartEchoServer() *net.TCPListener { - listener, err := net.ListenTCP("tcp", &net.TCPAddr{IP: net.ParseIP(s.ServerAddr()), Port: int(s.ServerPort())}) + listener, err := net.ListenTCP("tcp", &net.TCPAddr{IP: net.ParseIP(s.ServerAddr()), Port: int(s.Ports.Server)}) s.AssertNil(err, fmt.Sprint(err)) go func() { for { @@ -209,7 +209,7 @@ func (s *VppProxySuite) StartEchoServer() *net.TCPListener { go handleConn(conn) } }() - s.Log("* started tcp echo server " + s.ServerAddr() + ":" + strconv.Itoa(int(s.ServerPort()))) + s.Log("* started tcp echo server " + s.ServerAddr() + ":" + strconv.Itoa(int(s.Ports.Server))) return listener } diff --git a/extras/hs-test/infra/suite_vpp_udp_proxy.go b/extras/hs-test/infra/suite_vpp_udp_proxy.go index b2157757087..d6f58ac86cc 100644 --- a/extras/hs-test/infra/suite_vpp_udp_proxy.go +++ b/extras/hs-test/infra/suite_vpp_udp_proxy.go @@ -15,8 +15,6 @@ import ( type VppUdpProxySuite struct { HstSuite - proxyPort int - serverPort int MaxTimeout time.Duration Interfaces struct { Client *NetInterface @@ -25,6 +23,10 @@ type VppUdpProxySuite struct { Containers struct { VppProxy *Container } + Ports struct { + Proxy int + Server int + } } var vppUdpProxyTests = map[string][]func(s *VppUdpProxySuite){} @@ -45,6 +47,8 @@ func (s *VppUdpProxySuite) SetupSuite() { s.Interfaces.Client = s.GetInterfaceByName("hstcln") s.Interfaces.Server = s.GetInterfaceByName("hstsrv") s.Containers.VppProxy = s.GetContainerByName("vpp") + s.Ports.Proxy = int(s.GeneratePortAsInt()) + s.Ports.Server = int(s.GeneratePortAsInt()) if *IsVppDebug { s.MaxTimeout = time.Second * 600 @@ -66,9 +70,6 @@ func (s *VppUdpProxySuite) SetupTest() { s.AssertNil(vpp.CreateTap(s.Interfaces.Client, false, 1, 1)) s.AssertNil(vpp.CreateTap(s.Interfaces.Server, false, 1, 2)) - s.proxyPort = 8080 - s.serverPort = 80 - arp := fmt.Sprintf("set ip neighbor %s %s %s", s.Interfaces.Server.Peer.Name(), s.Interfaces.Server.Ip4AddressString(), @@ -99,24 +100,16 @@ func (s *VppUdpProxySuite) VppProxyAddr() string { return s.Interfaces.Client.Peer.Ip4AddressString() } -func (s *VppUdpProxySuite) ProxyPort() int { - return s.proxyPort -} - func (s *VppUdpProxySuite) ServerAddr() string { return s.Interfaces.Server.Ip4AddressString() } -func (s *VppUdpProxySuite) ServerPort() int { - return s.serverPort -} - func (s *VppUdpProxySuite) ClientAddr() string { return s.Interfaces.Client.Ip4AddressString() } func (s *VppUdpProxySuite) StartEchoServer() *net.UDPConn { - conn, err := net.ListenUDP("udp", &net.UDPAddr{IP: net.ParseIP(s.ServerAddr()), Port: s.ServerPort()}) + conn, err := net.ListenUDP("udp", &net.UDPAddr{IP: net.ParseIP(s.ServerAddr()), Port: s.Ports.Server}) s.AssertNil(err, fmt.Sprint(err)) go func() { for { @@ -130,14 +123,14 @@ func (s *VppUdpProxySuite) StartEchoServer() *net.UDPConn { } } }() - s.Log("* started udp echo server " + s.ServerAddr() + ":" + strconv.Itoa(s.ServerPort())) + s.Log("* started udp echo server " + s.ServerAddr() + ":" + strconv.Itoa(s.Ports.Server)) return conn } func (s *VppUdpProxySuite) ClientSendReceive(toSend []byte, rcvBuffer []byte) (int, error) { proxiedConn, err := net.DialUDP("udp", &net.UDPAddr{IP: net.ParseIP(s.ClientAddr()), Port: 0}, - &net.UDPAddr{IP: net.ParseIP(s.VppProxyAddr()), Port: s.ProxyPort()}) + &net.UDPAddr{IP: net.ParseIP(s.VppProxyAddr()), Port: s.Ports.Proxy}) if err != nil { return 0, err } diff --git a/extras/hs-test/infra/utils.go b/extras/hs-test/infra/utils.go index 5285ba8b581..a4dec989e97 100644 --- a/extras/hs-test/infra/utils.go +++ b/extras/hs-test/infra/utils.go @@ -235,7 +235,7 @@ 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.GetPortFromPpid()) + cmd := exec.Command("iperf3", "-4", "-s", "-p", s.GeneratePort()) if env != nil { cmd.Env = env } @@ -259,7 +259,7 @@ func (s *HstSuite) StartIperfClientApp(ipAddress string, env []string, clnCh cha nTries := 0 for { - cmd := exec.Command("iperf3", "-c", ipAddress, "-u", "-l", "1460", "-b", "10g", "-p", s.GetPortFromPpid()) + cmd := exec.Command("iperf3", "-c", ipAddress, "-u", "-l", "1460", "-b", "10g", "-p", s.GeneratePort()) if env != nil { cmd.Env = env } diff --git a/extras/hs-test/iperf_linux_test.go b/extras/hs-test/iperf_linux_test.go index 27235727327..0505f644f31 100644 --- a/extras/hs-test/iperf_linux_test.go +++ b/extras/hs-test/iperf_linux_test.go @@ -9,7 +9,7 @@ import ( ) func init() { - RegisterIperfTests(IperfUdpLinuxTest) + RegisterIperfSoloTests(IperfUdpLinuxTest) } func IperfUdpLinuxTest(s *IperfSuite) { @@ -27,7 +27,7 @@ func IperfUdpLinuxTest(s *IperfSuite) { go func() { defer GinkgoRecover() - cmd := "iperf3 -4 -s -B " + serverIpAddress + " -p " + s.GetPortFromPpid() + cmd := "iperf3 -4 -s -B " + serverIpAddress + " -p " + s.Ports.Port1 s.StartServerApp(s.Containers.Server, "iperf3", cmd, srvCh, stopServerCh) }() err := <-srvCh @@ -37,7 +37,7 @@ func IperfUdpLinuxTest(s *IperfSuite) { go func() { defer GinkgoRecover() cmd := "iperf3 -c " + serverIpAddress + " -B " + clientIpAddress + - " -u -l 1460 -b 10g -J -p " + s.GetPortFromPpid() + " -u -l 1460 -b 10g -J -p " + s.Ports.Port1 s.StartClientApp(s.Containers.Client, cmd, clnCh, clnRes) }() s.AssertChannelClosed(time.Minute*3, clnCh) diff --git a/extras/hs-test/ldp_test.go b/extras/hs-test/ldp_test.go index 0943a16d0eb..b42edabc647 100644 --- a/extras/hs-test/ldp_test.go +++ b/extras/hs-test/ldp_test.go @@ -11,8 +11,9 @@ import ( ) func init() { - RegisterLdpTests(LdpIperfUdpTest, LdpIperfUdpVppInterruptModeTest, RedisBenchmarkTest, LdpIperfTlsTcpTest, LdpIperfTcpTest, LdpIperfTcpReorderTest, - LdpIperfReverseTcpReorderTest, LdpIperfUdpReorderTest, LdpIperfReverseUdpReorderTest) + RegisterSoloLdpTests(LdpIperfUdpTest, LdpIperfUdpVppInterruptModeTest, RedisBenchmarkTest, + LdpIperfTlsTcpTest, LdpIperfTcpTest, LdpIperfTcpReorderTest, LdpIperfReverseTcpReorderTest, + LdpIperfUdpReorderTest, LdpIperfReverseUdpReorderTest) } func LdpIperfUdpVppInterruptModeTest(s *LdpSuite) { @@ -96,7 +97,7 @@ func ldPreloadIperf(s *LdpSuite, extraClientArgs string) IPerfResult { go func() { defer GinkgoRecover() - cmd := "iperf3 -4 -s -p " + s.GetPortFromPpid() + " --logfile " + s.IperfLogFileName(s.Containers.ServerVpp) + cmd := "iperf3 -4 -s -p " + s.Ports.Port1 + " --logfile " + s.IperfLogFileName(s.Containers.ServerVpp) s.StartServerApp(s.Containers.ServerVpp, "iperf3", cmd, srvCh, stopServerCh) }() @@ -105,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.GetPortFromPpid() + " " + extraClientArgs + cmd := "iperf3 -c " + serverVethAddress + " -l 1460 -b 10g -J -p " + s.Ports.Port1 + " " + extraClientArgs s.StartClientApp(s.Containers.ClientVpp, cmd, clnCh, clnRes) }() diff --git a/extras/hs-test/nginx_test.go b/extras/hs-test/nginx_test.go index f5f10cc49d1..6a219e9568c 100644 --- a/extras/hs-test/nginx_test.go +++ b/extras/hs-test/nginx_test.go @@ -10,10 +10,10 @@ import ( ) func init() { - RegisterNoTopoTests(NginxHttp3Test, NginxAsServerTest, NginxPerfCpsTest, NginxPerfRpsTest, NginxPerfWrkTest, + RegisterNoTopoTests(NginxHttp3Test, NginxAsServerTest) + RegisterNoTopoSoloTests(NginxPerfRpsMultiThreadTest, NginxPerfCpsMultiThreadTest, NginxPerfCpsTest, NginxPerfRpsTest, NginxPerfWrkTest, NginxPerfCpsInterruptModeTest, NginxPerfRpsInterruptModeTest, NginxPerfWrkInterruptModeTest) - RegisterNoTopoSoloTests(NginxPerfRpsMultiThreadTest, NginxPerfCpsMultiThreadTest) - RegisterNoTopo6Tests(NginxPerfRps6Test) + RegisterNoTopo6SoloTests(NginxPerfRps6Test) } func NginxHttp3Test(s *NoTopoSuite) { @@ -28,7 +28,8 @@ func NginxHttp3Test(s *NoTopoSuite) { serverAddress := s.VppAddr() defer func() { os.Remove(query) }() - args := fmt.Sprintf("curl --noproxy '*' --local-port 55444 --http3-only -k https://%s:8443/%s", serverAddress, query) + args := fmt.Sprintf("curl --noproxy '*' --http3-only -k https://%s:%s/%s", + serverAddress, s.Ports.NginxHttp3, query) s.Containers.Curl.ExtraRunningArgs = args s.Containers.Curl.Run() body, stats := s.Containers.Curl.GetOutput() @@ -56,7 +57,7 @@ func NginxAsServerTest(s *NoTopoSuite) { defer func() { os.Remove(query) }() go func() { defer GinkgoRecover() - s.StartWget(finished, serverAddress, "80", query, "") + s.StartWget(finished, serverAddress, s.Ports.NginxServer, query, "") }() s.AssertNil(<-finished) } @@ -75,7 +76,7 @@ func runNginxPerf(s *NoTopoSuite, mode, ab_or_wrk string, multiThreadWorkers boo nRequests := 1000000 nClients := 1000 - serverAddress := s.VppAddr() + serverAddress := s.VppAddr() + ":" + s.Ports.NginxServer vpp := s.Containers.Vpp.VppInstance @@ -94,7 +95,7 @@ func runNginxPerf(s *NoTopoSuite, mode, ab_or_wrk string, multiThreadWorkers boo } // don't exit on socket receive errors args += " -r" - args += " http://" + serverAddress + ":80/64B.json" + args += " http://" + serverAddress + "/64B.json" s.Containers.Ab.ExtraRunningArgs = args s.Log("Test might take up to 2 minutes to finish. Please wait") s.Containers.Ab.Run() @@ -103,7 +104,7 @@ func runNginxPerf(s *NoTopoSuite, mode, ab_or_wrk string, multiThreadWorkers boo s.Log(rps) s.AssertContains(err, "Finished "+fmt.Sprint(nRequests)) } else { - args := fmt.Sprintf("-c %d -t 2 -d 30 http://%s:80/64B.json", nClients, + args := fmt.Sprintf("-c %d -t 2 -d 30 http://%s/64B.json", nClients, serverAddress) s.Containers.Wrk.ExtraRunningArgs = args s.Containers.Wrk.Run() @@ -153,7 +154,7 @@ func runNginxPerf6(s *NoTopo6Suite, mode, ab_or_wrk string, multiThreadWorkers b nRequests := 1000000 nClients := 1000 - serverAddress := "[" + s.VppAddr() + "]" + serverAddress := "[" + s.VppAddr() + "]:" + s.Ports.NginxServer vpp := s.Containers.Vpp.VppInstance s.Containers.Nginx.Create() @@ -171,7 +172,7 @@ func runNginxPerf6(s *NoTopo6Suite, mode, ab_or_wrk string, multiThreadWorkers b } // don't exit on socket receive errors args += " -r" - args += " http://" + serverAddress + ":80/64B.json" + args += " http://" + serverAddress + "/64B.json" s.Containers.Ab.ExtraRunningArgs = args s.Log("Test might take up to 2 minutes to finish. Please wait") s.Containers.Ab.Run() @@ -180,7 +181,7 @@ func runNginxPerf6(s *NoTopo6Suite, mode, ab_or_wrk string, multiThreadWorkers b s.Log(rps) s.AssertContains(err, "Finished "+fmt.Sprint(nRequests)) } else { - args := fmt.Sprintf("-c %d -t 2 -d 30 http://%s:80/64B.json", nClients, + args := fmt.Sprintf("-c %d -t 2 -d 30 http://%s/64B.json", nClients, serverAddress) s.Containers.Wrk.ExtraRunningArgs = args s.Containers.Wrk.Run() diff --git a/extras/hs-test/proxy_test.go b/extras/hs-test/proxy_test.go index e12b38e4084..0e82bf3117b 100644 --- a/extras/hs-test/proxy_test.go +++ b/extras/hs-test/proxy_test.go @@ -29,8 +29,7 @@ func init() { VppConnectUdpUnknownCapsuleTest, VppConnectUdpClientCloseTest, VppConnectUdpInvalidTargetTest) RegisterVppUdpProxySoloTests(VppProxyUdpMigrationMTTest, VppConnectUdpStressMTTest, VppConnectUdpStressTest) RegisterEnvoyProxyTests(EnvoyProxyHttpGetTcpTest, EnvoyProxyHttpPutTcpTest) - RegisterNginxProxyTests(NginxMirroringTest) - RegisterNginxProxySoloTests(MirrorMultiThreadTest) + RegisterNginxProxySoloTests(NginxMirroringTest, MirrorMultiThreadTest) } func configureVppProxy(s *VppProxySuite, proto string, proxyPort uint16) { @@ -40,7 +39,7 @@ func configureVppProxy(s *VppProxySuite, proto string, proxyPort uint16) { proto = "tcp" } if proto != "http" { - cmd += fmt.Sprintf(" client-uri %s://%s/%d", proto, s.ServerAddr(), s.ServerPort()) + cmd += fmt.Sprintf(" client-uri %s://%s/%d", proto, s.ServerAddr(), s.Ports.Server) } output := vppProxy.Vppctl(cmd) @@ -63,8 +62,6 @@ func vppProxyIperfMTTest(s *VppProxySuite, proto string) { s.Containers.IperfC.Run() s.Containers.IperfS.Run() vppProxy := s.Containers.VppProxy.VppInstance - proxyPort, err := strconv.Atoi(s.GetPortFromPpid()) - s.AssertNil(err) // tap interfaces are created on test setup with 1 rx-queue, // need to recreate them with 2 + consistent-qp @@ -74,9 +71,9 @@ func vppProxyIperfMTTest(s *VppProxySuite, proto string) { s.AssertNil(vppProxy.DeleteTap(s.Interfaces.Client)) s.AssertNil(vppProxy.CreateTap(s.Interfaces.Client, false, 2, uint32(s.Interfaces.Client.Peer.Index), Consistent_qp)) - configureVppProxy(s, "tcp", uint16(proxyPort)) + configureVppProxy(s, "tcp", s.Ports.Proxy) if proto == "udp" { - configureVppProxy(s, "udp", uint16(proxyPort)) + configureVppProxy(s, "udp", s.Ports.Proxy) proto = "-u" } else { proto = "" @@ -93,16 +90,16 @@ func vppProxyIperfMTTest(s *VppProxySuite, proto string) { go func() { defer GinkgoRecover() - cmd := fmt.Sprintf("iperf3 -4 -s -B %s -p %s --logfile %s", s.ServerAddr(), fmt.Sprint(s.ServerPort()), s.IperfLogFileName(s.Containers.IperfS)) + 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) }() - err = <-srvCh + err := <-srvCh s.AssertNil(err, fmt.Sprint(err)) go func() { defer GinkgoRecover() - cmd := fmt.Sprintf("iperf3 -c %s -P 4 -l 1460 -b 10g -J -p %d -B %s %s", s.VppProxyAddr(), proxyPort, s.ClientAddr(), proto) + 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) }() @@ -113,18 +110,16 @@ func vppProxyIperfMTTest(s *VppProxySuite, proto string) { } func VppProxyHttpGetTcpTest(s *VppProxySuite) { - var proxyPort uint16 = 8080 s.SetupNginxServer() - configureVppProxy(s, "tcp", proxyPort) - uri := fmt.Sprintf("http://%s:%d/httpTestFile", s.VppProxyAddr(), proxyPort) + configureVppProxy(s, "tcp", s.Ports.Proxy) + uri := fmt.Sprintf("http://%s:%d/httpTestFile", s.VppProxyAddr(), s.Ports.Proxy) s.CurlDownloadResource(uri) } func VppProxyHttpGetTlsTest(s *VppProxySuite) { - var proxyPort uint16 = 8080 s.SetupNginxServer() - configureVppProxy(s, "tls", proxyPort) - uri := fmt.Sprintf("https://%s:%d/httpTestFile", s.VppProxyAddr(), proxyPort) + configureVppProxy(s, "tls", s.Ports.Proxy) + uri := fmt.Sprintf("https://%s:%d/httpTestFile", s.VppProxyAddr(), s.Ports.Proxy) s.CurlDownloadResource(uri) } @@ -133,28 +128,26 @@ func VppProxyHttpPutTcpMTTest(s *VppProxySuite) { } func VppProxyHttpPutTcpTest(s *VppProxySuite) { - var proxyPort uint16 = 8080 s.SetupNginxServer() - configureVppProxy(s, "tcp", proxyPort) - uri := fmt.Sprintf("http://%s:%d/upload/testFile", s.VppProxyAddr(), proxyPort) + configureVppProxy(s, "tcp", s.Ports.Proxy) + uri := fmt.Sprintf("http://%s:%d/upload/testFile", s.VppProxyAddr(), s.Ports.Proxy) s.CurlUploadResource(uri, CurlContainerTestFile) } func VppProxyHttpPutTlsTest(s *VppProxySuite) { - var proxyPort uint16 = 8080 s.SetupNginxServer() - configureVppProxy(s, "tls", proxyPort) - uri := fmt.Sprintf("https://%s:%d/upload/testFile", s.VppProxyAddr(), proxyPort) + configureVppProxy(s, "tls", s.Ports.Proxy) + uri := fmt.Sprintf("https://%s:%d/upload/testFile", s.VppProxyAddr(), s.Ports.Proxy) s.CurlUploadResource(uri, CurlContainerTestFile) } func EnvoyProxyHttpGetTcpTest(s *EnvoyProxySuite) { - uri := fmt.Sprintf("http://%s:%d/httpTestFile", s.ProxyAddr(), s.ProxyPort()) + uri := fmt.Sprintf("http://%s:%d/httpTestFile", s.ProxyAddr(), s.Ports.Proxy) s.CurlDownloadResource(uri) } func EnvoyProxyHttpPutTcpTest(s *EnvoyProxySuite) { - uri := fmt.Sprintf("http://%s:%d/upload/testFile", s.ProxyAddr(), s.ProxyPort()) + uri := fmt.Sprintf("http://%s:%d/upload/testFile", s.ProxyAddr(), s.Ports.Proxy) s.CurlUploadResource(uri, CurlContainerTestFile) } @@ -162,6 +155,7 @@ func MirrorMultiThreadTest(s *NginxProxySuite) { nginxMirroring(s, true) } +// unstable, registered as solo func NginxMirroringTest(s *NginxProxySuite) { nginxMirroring(s, false) } @@ -173,38 +167,35 @@ func nginxMirroring(s *NginxProxySuite, multiThreadWorkers bool) { s.CreateNginxProxyConfig(s.Containers.NginxProxy, multiThreadWorkers) s.Containers.NginxProxy.Start() vpp.WaitForApp("nginx-", 5) - uri := fmt.Sprintf("http://%s:%d/httpTestFile", s.ProxyAddr(), s.ProxyPort()) + uri := fmt.Sprintf("http://%s:%d/httpTestFile", s.ProxyAddr(), s.Ports.Proxy) s.CurlDownloadResource(uri) } func VppConnectProxyGetTest(s *VppProxySuite) { - var proxyPort uint16 = 8080 s.SetupNginxServer() - configureVppProxy(s, "http", proxyPort) + configureVppProxy(s, "http", s.Ports.Proxy) - targetUri := fmt.Sprintf("http://%s:%d/httpTestFile", s.ServerAddr(), s.ServerPort()) - proxyUri := fmt.Sprintf("http://%s:%d", s.VppProxyAddr(), proxyPort) + targetUri := fmt.Sprintf("http://%s:%d/httpTestFile", s.ServerAddr(), s.Ports.Server) + proxyUri := fmt.Sprintf("http://%s:%d", s.VppProxyAddr(), s.Ports.Proxy) s.CurlDownloadResourceViaTunnel(targetUri, proxyUri) } func VppConnectProxyConnectionFailedMTTest(s *VppProxySuite) { - var proxyPort uint16 = 8080 s.SetupNginxServer() - configureVppProxy(s, "http", proxyPort) + configureVppProxy(s, "http", s.Ports.Proxy) - targetUri := fmt.Sprintf("http://%s:%d/httpTestFile", s.ServerAddr(), s.ServerPort()+1) - proxyUri := fmt.Sprintf("http://%s:%d", s.VppProxyAddr(), proxyPort) + targetUri := fmt.Sprintf("http://%s:%d/httpTestFile", s.ServerAddr(), s.Ports.Server+1) + proxyUri := fmt.Sprintf("http://%s:%d", s.VppProxyAddr(), s.Ports.Proxy) _, log := s.CurlRequestViaTunnel(targetUri, proxyUri) s.AssertContains(log, "HTTP/1.1 502 Bad Gateway") } func VppConnectProxyPutTest(s *VppProxySuite) { - var proxyPort uint16 = 8080 s.SetupNginxServer() - configureVppProxy(s, "http", proxyPort) + configureVppProxy(s, "http", s.Ports.Proxy) - proxyUri := fmt.Sprintf("http://%s:%d", s.VppProxyAddr(), proxyPort) - targetUri := fmt.Sprintf("http://%s:%d/upload/testFile", s.ServerAddr(), s.ServerPort()) + proxyUri := fmt.Sprintf("http://%s:%d", s.VppProxyAddr(), s.Ports.Proxy) + targetUri := fmt.Sprintf("http://%s:%d/upload/testFile", s.ServerAddr(), s.Ports.Server) s.CurlUploadResourceViaTunnel(targetUri, proxyUri, CurlContainerTestFile) } @@ -214,7 +205,7 @@ func vppConnectProxyStressLoad(s *VppProxySuite, proxyPort string) { wg sync.WaitGroup ) stop := make(chan struct{}) - targetUri := fmt.Sprintf("%s:%d", s.ServerAddr(), s.ServerPort()) + targetUri := fmt.Sprintf("%s:%d", s.ServerAddr(), s.Ports.Server) s.Log("Running 30s test @ " + targetUri) for i := 0; i < 1000; i++ { @@ -317,20 +308,18 @@ func vppConnectProxyStressLoad(s *VppProxySuite, proxyPort string) { } func VppConnectProxyStressTest(s *VppProxySuite) { - var proxyPort uint16 = 8080 remoteServerConn := s.StartEchoServer() defer remoteServerConn.Close() - configureVppProxy(s, "http", proxyPort) + configureVppProxy(s, "http", s.Ports.Proxy) // no goVPP less noise s.Containers.VppProxy.VppInstance.Disconnect() - vppConnectProxyStressLoad(s, strconv.Itoa(int(proxyPort))) + vppConnectProxyStressLoad(s, strconv.Itoa(int(s.Ports.Proxy))) } func VppConnectProxyStressMTTest(s *VppProxySuite) { - var proxyPort uint16 = 8080 remoteServerConn := s.StartEchoServer() defer remoteServerConn.Close() @@ -342,12 +331,12 @@ func VppConnectProxyStressMTTest(s *VppProxySuite) { s.AssertNil(vppProxy.DeleteTap(s.Interfaces.Client)) s.AssertNil(vppProxy.CreateTap(s.Interfaces.Client, false, 2, uint32(s.Interfaces.Client.Peer.Index), Consistent_qp)) - configureVppProxy(s, "http", proxyPort) + configureVppProxy(s, "http", s.Ports.Proxy) // no goVPP less noise vppProxy.Disconnect() - vppConnectProxyStressLoad(s, strconv.Itoa(int(proxyPort))) + vppConnectProxyStressLoad(s, strconv.Itoa(int(s.Ports.Proxy))) } func VppProxyUdpTest(s *VppUdpProxySuite) { @@ -355,8 +344,8 @@ func VppProxyUdpTest(s *VppUdpProxySuite) { defer remoteServerConn.Close() vppProxy := s.Containers.VppProxy.VppInstance - cmd := fmt.Sprintf("test proxy server fifo-size 512k server-uri udp://%s/%d", s.VppProxyAddr(), s.ProxyPort()) - cmd += fmt.Sprintf(" client-uri udp://%s/%d", s.ServerAddr(), s.ServerPort()) + cmd := fmt.Sprintf("test proxy server fifo-size 512k server-uri udp://%s/%d", s.VppProxyAddr(), s.Ports.Proxy) + cmd += fmt.Sprintf(" client-uri udp://%s/%d", s.ServerAddr(), s.Ports.Server) s.Log(vppProxy.Vppctl(cmd)) b := make([]byte, 1500) @@ -370,8 +359,8 @@ func VppProxyUdpMigrationMTTest(s *VppUdpProxySuite) { defer remoteServerConn.Close() vppProxy := s.Containers.VppProxy.VppInstance - cmd := fmt.Sprintf("test proxy server fifo-size 512k server-uri udp://%s/%d", s.VppProxyAddr(), s.ProxyPort()) - cmd += fmt.Sprintf(" client-uri udp://%s/%d", s.ServerAddr(), s.ServerPort()) + cmd := fmt.Sprintf("test proxy server fifo-size 512k server-uri udp://%s/%d", s.VppProxyAddr(), s.Ports.Proxy) + cmd += fmt.Sprintf(" client-uri udp://%s/%d", s.ServerAddr(), s.Ports.Server) s.Log(vppProxy.Vppctl(cmd)) b := make([]byte, 1500) @@ -392,11 +381,11 @@ func VppConnectUdpProxyTest(s *VppUdpProxySuite) { defer remoteServerConn.Close() vppProxy := s.Containers.VppProxy.VppInstance - cmd := fmt.Sprintf("test proxy server fifo-size 512k server-uri http://%s/%d", s.VppProxyAddr(), s.ProxyPort()) + cmd := fmt.Sprintf("test proxy server fifo-size 512k server-uri http://%s/%d", s.VppProxyAddr(), s.Ports.Proxy) s.Log(vppProxy.Vppctl(cmd)) - proxyAddress := fmt.Sprintf("%s:%d", s.VppProxyAddr(), s.ProxyPort()) - targetUri := fmt.Sprintf("http://%s:%d/.well-known/masque/udp/%s/%d/", s.VppProxyAddr(), s.ProxyPort(), s.ServerAddr(), s.ServerPort()) + proxyAddress := fmt.Sprintf("%s:%d", s.VppProxyAddr(), s.Ports.Proxy) + targetUri := fmt.Sprintf("http://%s:%d/.well-known/masque/udp/%s/%d/", s.VppProxyAddr(), s.Ports.Proxy, s.ServerAddr(), s.Ports.Server) c := s.NewConnectUdpClient(s.MaxTimeout, true) err := c.Dial(proxyAddress, targetUri) s.AssertNil(err, fmt.Sprint(err)) @@ -413,22 +402,22 @@ func VppConnectUdpProxyTest(s *VppUdpProxySuite) { func VppConnectUdpInvalidTargetTest(s *VppUdpProxySuite) { vppProxy := s.Containers.VppProxy.VppInstance - cmd := fmt.Sprintf("test proxy server fifo-size 512k server-uri http://%s/%d", s.VppProxyAddr(), s.ProxyPort()) + cmd := fmt.Sprintf("test proxy server fifo-size 512k server-uri http://%s/%d", s.VppProxyAddr(), s.Ports.Proxy) s.Log(vppProxy.Vppctl(cmd)) - proxyAddress := fmt.Sprintf("%s:%d", s.VppProxyAddr(), s.ProxyPort()) + proxyAddress := fmt.Sprintf("%s:%d", s.VppProxyAddr(), s.Ports.Proxy) - targetUri := fmt.Sprintf("http://%s:%d/.well-known/masque/udp/example.com/80/", s.VppProxyAddr(), s.ProxyPort()) + targetUri := fmt.Sprintf("http://%s:%d/.well-known/masque/udp/example.com/80/", s.VppProxyAddr(), s.Ports.Proxy) c := s.NewConnectUdpClient(s.MaxTimeout, true) err := c.Dial(proxyAddress, targetUri) s.AssertNotNil(err, "name resolution not supported") - targetUri = fmt.Sprintf("http://%s:%d/.well-known/masque/udp/1.2.3.4/800000000/", s.VppProxyAddr(), s.ProxyPort()) + targetUri = fmt.Sprintf("http://%s:%d/.well-known/masque/udp/1.2.3.4/800000000/", s.VppProxyAddr(), s.Ports.Proxy) c = s.NewConnectUdpClient(s.MaxTimeout, true) err = c.Dial(proxyAddress, targetUri) s.AssertNotNil(err, "invalid port number") - targetUri = fmt.Sprintf("http://%s:%d/masque/udp/1.2.3.4/80/", s.VppProxyAddr(), s.ProxyPort()) + targetUri = fmt.Sprintf("http://%s:%d/masque/udp/1.2.3.4/80/", s.VppProxyAddr(), s.Ports.Proxy) c = s.NewConnectUdpClient(s.MaxTimeout, true) err = c.Dial(proxyAddress, targetUri) s.AssertNotNil(err, "invalid prefix") @@ -439,11 +428,11 @@ func VppConnectUdpInvalidCapsuleTest(s *VppUdpProxySuite) { defer remoteServerConn.Close() vppProxy := s.Containers.VppProxy.VppInstance - cmd := fmt.Sprintf("test proxy server fifo-size 512k server-uri http://%s/%d", s.VppProxyAddr(), s.ProxyPort()) + cmd := fmt.Sprintf("test proxy server fifo-size 512k server-uri http://%s/%d", s.VppProxyAddr(), s.Ports.Proxy) s.Log(vppProxy.Vppctl(cmd)) - proxyAddress := fmt.Sprintf("%s:%d", s.VppProxyAddr(), s.ProxyPort()) - targetUri := fmt.Sprintf("http://%s:%d/.well-known/masque/udp/%s/%d/", s.VppProxyAddr(), s.ProxyPort(), s.ServerAddr(), s.ServerPort()) + proxyAddress := fmt.Sprintf("%s:%d", s.VppProxyAddr(), s.Ports.Proxy) + targetUri := fmt.Sprintf("http://%s:%d/.well-known/masque/udp/%s/%d/", s.VppProxyAddr(), s.Ports.Proxy, s.ServerAddr(), s.Ports.Server) c := s.NewConnectUdpClient(s.MaxTimeout, true) err := c.Dial(proxyAddress, targetUri) s.AssertNil(err, fmt.Sprint(err)) @@ -469,11 +458,11 @@ func VppConnectUdpUnknownCapsuleTest(s *VppUdpProxySuite) { defer remoteServerConn.Close() vppProxy := s.Containers.VppProxy.VppInstance - cmd := fmt.Sprintf("test proxy server fifo-size 512k server-uri http://%s/%d", s.VppProxyAddr(), s.ProxyPort()) + cmd := fmt.Sprintf("test proxy server fifo-size 512k server-uri http://%s/%d", s.VppProxyAddr(), s.Ports.Proxy) s.Log(vppProxy.Vppctl(cmd)) - proxyAddress := fmt.Sprintf("%s:%d", s.VppProxyAddr(), s.ProxyPort()) - targetUri := fmt.Sprintf("http://%s:%d/.well-known/masque/udp/%s/%d/", s.VppProxyAddr(), s.ProxyPort(), s.ServerAddr(), s.ServerPort()) + proxyAddress := fmt.Sprintf("%s:%d", s.VppProxyAddr(), s.Ports.Proxy) + targetUri := fmt.Sprintf("http://%s:%d/.well-known/masque/udp/%s/%d/", s.VppProxyAddr(), s.Ports.Proxy, s.ServerAddr(), s.Ports.Server) c := s.NewConnectUdpClient(s.MaxTimeout, true) err := c.Dial(proxyAddress, targetUri) s.AssertNil(err, fmt.Sprint(err)) @@ -498,18 +487,18 @@ func VppConnectUdpClientCloseTest(s *VppUdpProxySuite) { defer remoteServerConn.Close() vppProxy := s.Containers.VppProxy.VppInstance - cmd := fmt.Sprintf("test proxy server fifo-size 512k server-uri http://%s/%d", s.VppProxyAddr(), s.ProxyPort()) + cmd := fmt.Sprintf("test proxy server fifo-size 512k server-uri http://%s/%d", s.VppProxyAddr(), s.Ports.Proxy) s.Log(vppProxy.Vppctl(cmd)) - proxyAddress := fmt.Sprintf("%s:%d", s.VppProxyAddr(), s.ProxyPort()) - targetUri := fmt.Sprintf("http://%s:%d/.well-known/masque/udp/%s/%d/", s.VppProxyAddr(), s.ProxyPort(), s.ServerAddr(), s.ServerPort()) + proxyAddress := fmt.Sprintf("%s:%d", s.VppProxyAddr(), s.Ports.Proxy) + targetUri := fmt.Sprintf("http://%s:%d/.well-known/masque/udp/%s/%d/", s.VppProxyAddr(), s.Ports.Proxy, s.ServerAddr(), s.Ports.Server) c := s.NewConnectUdpClient(s.MaxTimeout, true) err := c.Dial(proxyAddress, targetUri) s.AssertNil(err, fmt.Sprint(err)) err = c.Close() s.AssertNil(err, fmt.Sprint(err)) - proxyClientConn := fmt.Sprintf("[T] %s:%d->%s", s.VppProxyAddr(), s.ProxyPort(), s.ClientAddr()) + proxyClientConn := fmt.Sprintf("[T] %s:%d->%s", s.VppProxyAddr(), s.Ports.Proxy, s.ClientAddr()) proxyTargetConn := fmt.Sprintf("[U] %s:", s.Interfaces.Server.Peer.Ip4AddressString()) for nTries := 0; nTries < 10; nTries++ { o := vppProxy.Vppctl("show session verbose 2") @@ -530,8 +519,8 @@ func vppConnectUdpStressLoad(s *VppUdpProxySuite) { wg sync.WaitGroup ) - proxyAddress := fmt.Sprintf("%s:%d", s.VppProxyAddr(), s.ProxyPort()) - targetUri := fmt.Sprintf("http://%s/.well-known/masque/udp/%s/%d/", proxyAddress, s.ServerAddr(), s.ServerPort()) + proxyAddress := fmt.Sprintf("%s:%d", s.VppProxyAddr(), s.Ports.Proxy) + targetUri := fmt.Sprintf("http://%s/.well-known/masque/udp/%s/%d/", proxyAddress, s.ServerAddr(), s.Ports.Server) // warm-up warmUp := s.NewConnectUdpClient(s.MaxTimeout, false) @@ -629,7 +618,7 @@ func VppConnectUdpStressTest(s *VppUdpProxySuite) { defer remoteServerConn.Close() vppProxy := s.Containers.VppProxy.VppInstance - cmd := fmt.Sprintf("test proxy server fifo-size 512k server-uri http://%s/%d", s.VppProxyAddr(), s.ProxyPort()) + cmd := fmt.Sprintf("test proxy server fifo-size 512k server-uri http://%s/%d", s.VppProxyAddr(), s.Ports.Proxy) s.Log(vppProxy.Vppctl(cmd)) // no goVPP less noise @@ -644,7 +633,7 @@ func VppConnectUdpStressMTTest(s *VppUdpProxySuite) { vppProxy := s.Containers.VppProxy.VppInstance vppProxy.Disconnect() - cmd := fmt.Sprintf("test proxy server fifo-size 512k server-uri http://%s/%d", s.VppProxyAddr(), s.ProxyPort()) + cmd := fmt.Sprintf("test proxy server fifo-size 512k server-uri http://%s/%d", s.VppProxyAddr(), s.Ports.Proxy) s.Log(vppProxy.Vppctl(cmd)) // no goVPP less noise diff --git a/extras/hs-test/raw_session_test.go b/extras/hs-test/raw_session_test.go index b93b27ab56b..196e1837b2d 100644 --- a/extras/hs-test/raw_session_test.go +++ b/extras/hs-test/raw_session_test.go @@ -22,7 +22,7 @@ func VppEchoTcpTest(s *VethsSuite) { func testVppEcho(s *VethsSuite, proto string) { serverVethAddress := s.Interfaces.Server.Ip4AddressString() - uri := proto + "://" + serverVethAddress + "/12344" + uri := proto + "://" + serverVethAddress + "/" + s.Ports.Port1 serverCommand := "vpp_echo server TX=RX" + " socket-name " + s.Containers.ServerApp.GetContainerWorkDir() + "/var/run/app_ns_sockets/default" + diff --git a/extras/hs-test/resources/envoy/proxy.yaml b/extras/hs-test/resources/envoy/proxy.yaml index 67eb6909ed2..62e728b2d41 100644 --- a/extras/hs-test/resources/envoy/proxy.yaml +++ b/extras/hs-test/resources/envoy/proxy.yaml @@ -1,14 +1,14 @@ admin: address: socket_address: - address: 0.0.0.0 - port_value: 8081 + address: {{.ServerAddress}} + port_value: {{.EnvoyAdminPort}} static_resources: listeners: - address: socket_address: protocol: TCP - address: 0.0.0.0 + address: {{.ProxyAddr}} port_value: {{.ProxyPort}} filter_chains: - filters: diff --git a/extras/hs-test/resources/nginx/nginx.conf b/extras/hs-test/resources/nginx/nginx.conf index 04f5f2bd1f8..7eac45c927f 100644 --- a/extras/hs-test/resources/nginx/nginx.conf +++ b/extras/hs-test/resources/nginx/nginx.conf @@ -15,8 +15,8 @@ http { keepalive_requests 1000000; sendfile on; server { - listen 80; - listen [::]:80; + listen {{.Port}}; + listen [::]:{{.Port}}; root /usr/share/nginx; index index.html index.htm; location /return_ok diff --git a/extras/hs-test/resources/nginx/nginx_http3.conf b/extras/hs-test/resources/nginx/nginx_http3.conf index e048b17044b..814568842b9 100644 --- a/extras/hs-test/resources/nginx/nginx_http3.conf +++ b/extras/hs-test/resources/nginx/nginx_http3.conf @@ -18,7 +18,7 @@ http { keepalive_timeout 300s; sendfile on; server { - listen 0.0.0.0:8443 quic; + listen {{.Address}}:{{.Port}} quic; root /usr/share/nginx; ssl_certificate /etc/nginx/ssl/localhost.crt; ssl_certificate_key /etc/nginx/ssl/localhost.key; diff --git a/extras/hs-test/resources/nginx/nginx_proxy_mirroring.conf b/extras/hs-test/resources/nginx/nginx_proxy_mirroring.conf index d834a27288a..9e0f276b02a 100644 --- a/extras/hs-test/resources/nginx/nginx_proxy_mirroring.conf +++ b/extras/hs-test/resources/nginx/nginx_proxy_mirroring.conf @@ -31,15 +31,15 @@ http { gzip on; upstream bk { - server {{.Server}}:8091; + server {{.Server}}:{{.Upstream1}}; keepalive 30000; } upstream bk1 { - server {{.Server}}:8092; + server {{.Server}}:{{.Upstream2}}; keepalive 30000; } upstream bk2 { - server {{.Server}}:8093; + server {{.Server}}:{{.Upstream3}}; keepalive 30000; } diff --git a/extras/hs-test/resources/nginx/nginx_server_mirroring.conf b/extras/hs-test/resources/nginx/nginx_server_mirroring.conf index 921eb2eefd5..3c28dbfeec8 100644 --- a/extras/hs-test/resources/nginx/nginx_server_mirroring.conf +++ b/extras/hs-test/resources/nginx/nginx_server_mirroring.conf @@ -18,9 +18,9 @@ http { sendfile on; server { access_log /tmp/nginx/{{.LogPrefix}}-access.log; - listen 8091; - listen 8092; - listen 8093; + listen {{.Address}}:{{.Upstream1}}; + listen {{.Address}}:{{.Upstream2}}; + listen {{.Address}}:{{.Upstream3}}; root /usr/share/nginx; index index.html index.htm; location /64B { diff --git a/extras/hs-test/tls_test.go b/extras/hs-test/tls_test.go index 4265f3612e1..7689ef67c07 100644 --- a/extras/hs-test/tls_test.go +++ b/extras/hs-test/tls_test.go @@ -9,9 +9,9 @@ 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:123")) + s.Log(s.Containers.ServerVpp.VppInstance.Vppctl("test alpn server alpn-proto1 2 uri tls://0.0.0.0:" + s.Ports.Port1)) - uri := "tls://" + s.Interfaces.Server.Ip4AddressString() + ":123" + uri := "tls://" + s.Interfaces.Server.Ip4AddressString() + ":" + s.Ports.Port1 o := s.Containers.ClientVpp.VppInstance.Vppctl("test alpn client alpn-proto1 2 uri " + uri) s.Log(o) s.AssertNotContains(o, "connect failed") @@ -21,9 +21,9 @@ 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:123")) + 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)) - uri := "tls://" + s.Interfaces.Server.Ip4AddressString() + ":123" + uri := "tls://" + s.Interfaces.Server.Ip4AddressString() + ":" + s.Ports.Port1 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 +33,9 @@ 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:123")) + 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)) - uri := "tls://" + s.Interfaces.Server.Ip4AddressString() + ":123" + uri := "tls://" + s.Interfaces.Server.Ip4AddressString() + ":" + s.Ports.Port1 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 +45,9 @@ 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:123")) + 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)) - uri := "tls://" + s.Interfaces.Server.Ip4AddressString() + ":123" + uri := "tls://" + s.Interfaces.Server.Ip4AddressString() + ":" + s.Ports.Port1 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 +57,9 @@ func TlsAlpnMismatchTest(s *VethsSuite) { } func TlsAlpnEmptyServerListTest(s *VethsSuite) { - s.Log(s.Containers.ServerVpp.VppInstance.Vppctl("test alpn server uri tls://0.0.0.0:123")) + s.Log(s.Containers.ServerVpp.VppInstance.Vppctl("test alpn server uri tls://0.0.0.0:" + s.Ports.Port1)) - uri := "tls://" + s.Interfaces.Server.Ip4AddressString() + ":123" + uri := "tls://" + s.Interfaces.Server.Ip4AddressString() + ":" + s.Ports.Port1 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 +69,9 @@ 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:123")) + 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)) - uri := "tls://" + s.Interfaces.Server.Ip4AddressString() + ":123" + uri := "tls://" + s.Interfaces.Server.Ip4AddressString() + ":" + s.Ports.Port1 o := s.Containers.ClientVpp.VppInstance.Vppctl("test alpn client uri " + uri) s.Log(o) s.AssertNotContains(o, "connect failed") diff --git a/extras/hs-test/vcl_test.go b/extras/hs-test/vcl_test.go index bc557a90508..5fa331288b1 100644 --- a/extras/hs-test/vcl_test.go +++ b/extras/hs-test/vcl_test.go @@ -39,15 +39,14 @@ func XEchoVclClientTcpTest(s *VethsSuite) { } func testXEchoVclClient(s *VethsSuite, proto string) { - port := "12345" serverVpp := s.Containers.ServerVpp.VppInstance - serverVpp.Vppctl("test echo server uri %s://%s/%s fifo-size 64k", proto, s.Interfaces.Server.Ip4AddressString(), port) + serverVpp.Vppctl("test echo server uri %s://%s/%s fifo-size 64k", proto, s.Interfaces.Server.Ip4AddressString(), s.Ports.Port1) echoClnContainer := s.GetTransientContainerByName("client-app") echoClnContainer.CreateFile("/vcl.conf", getVclConfig(echoClnContainer)) - testClientCommand := "vcl_test_client -N 100 -p " + proto + " " + s.Interfaces.Server.Ip4AddressString() + " " + port + testClientCommand := "vcl_test_client -N 100 -p " + proto + " " + s.Interfaces.Server.Ip4AddressString() + " " + s.Ports.Port1 s.Log(testClientCommand) echoClnContainer.AddEnvVar("VCL_CONFIG", "/vcl.conf") o, err := echoClnContainer.Exec(true, testClientCommand) @@ -65,38 +64,36 @@ func XEchoVclServerTcpTest(s *VethsSuite) { } func testXEchoVclServer(s *VethsSuite, proto string) { - port := "12345" srvVppCont := s.Containers.ServerVpp srvAppCont := s.Containers.ServerApp srvAppCont.CreateFile("/vcl.conf", getVclConfig(srvVppCont)) srvAppCont.AddEnvVar("VCL_CONFIG", "/vcl.conf") - vclSrvCmd := fmt.Sprintf("vcl_test_server -p %s %s", proto, port) + vclSrvCmd := fmt.Sprintf("vcl_test_server -p %s %s", proto, 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, port) + o := clientVpp.Vppctl("test echo client uri %s://%s/%s fifo-size 64k verbose bytes 2m", proto, serverVethAddress, s.Ports.Port1) s.Log(o) s.AssertContains(o, "Test finished at") } func testVclEcho(s *VethsSuite, proto string) { - port := "12345" srvVppCont := s.Containers.ServerVpp srvAppCont := s.Containers.ServerApp srvAppCont.CreateFile("/vcl.conf", getVclConfig(srvVppCont)) srvAppCont.AddEnvVar("VCL_CONFIG", "/vcl.conf") - srvAppCont.ExecServer(true, "vcl_test_server -p "+proto+" "+port) + srvAppCont.ExecServer(true, "vcl_test_server -p "+proto+" "+s.Ports.Port1) serverVethAddress := s.Interfaces.Server.Ip4AddressString() echoClnContainer := s.GetTransientContainerByName("client-app") echoClnContainer.CreateFile("/vcl.conf", getVclConfig(echoClnContainer)) - testClientCommand := "vcl_test_client -p " + proto + " " + serverVethAddress + " " + port + testClientCommand := "vcl_test_client -p " + proto + " " + serverVethAddress + " " + s.Ports.Port1 echoClnContainer.AddEnvVar("VCL_CONFIG", "/vcl.conf") o, err := echoClnContainer.Exec(true, testClientCommand) s.AssertNil(err) @@ -127,7 +124,7 @@ func testRetryAttach(s *VethsSuite, proto string) { echoSrvContainer.CreateFile("/vcl.conf", getVclConfig(echoSrvContainer)) echoSrvContainer.AddEnvVar("VCL_CONFIG", "/vcl.conf") - echoSrvContainer.ExecServer(true, "vcl_test_server -p "+proto+" 12346") + echoSrvContainer.ExecServer(true, "vcl_test_server -p "+proto+" "+s.Ports.Port1) 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.") @@ -137,7 +134,7 @@ func testRetryAttach(s *VethsSuite, proto string) { echoClnContainer := s.GetTransientContainerByName("client-app") echoClnContainer.CreateFile("/vcl.conf", getVclConfig(echoClnContainer)) - testClientCommand := "vcl_test_client -U -p " + proto + " " + serverVethAddress + " 12346" + testClientCommand := "vcl_test_client -U -p " + proto + " " + serverVethAddress + " " + s.Ports.Port1 echoClnContainer.AddEnvVar("VCL_CONFIG", "/vcl.conf") o, err := echoClnContainer.Exec(true, testClientCommand) s.AssertNil(err)