hs-test: proxy testing improvements 86/41586/2
authorMatus Fabian <[email protected]>
Fri, 20 Sep 2024 11:25:39 +0000 (13:25 +0200)
committerFlorin Coras <[email protected]>
Fri, 20 Sep 2024 16:06:17 +0000 (16:06 +0000)
- nginx and curl timeouts are extended if debug flag is set
- added write-out for curl (outputs extra info after transfer is done)

Type: test

Change-Id: I3f6c336a14cd00b9ae8669d2fa26e00709162100
Signed-off-by: Matus Fabian <[email protected]>
extras/hs-test/docker/Dockerfile.curl
extras/hs-test/infra/suite_envoy_proxy.go
extras/hs-test/infra/suite_nginx_proxy.go
extras/hs-test/infra/suite_vpp_proxy.go
extras/hs-test/resources/curl/write_out_download [new file with mode: 0644]
extras/hs-test/resources/curl/write_out_download_connect [new file with mode: 0644]
extras/hs-test/resources/curl/write_out_upload [new file with mode: 0644]
extras/hs-test/resources/curl/write_out_upload_connect [new file with mode: 0644]
extras/hs-test/resources/nginx/nginx_server.conf

index fe9b4d9..cbb0bbe 100644 (file)
@@ -7,6 +7,7 @@ RUN apt-get update \
  && rm -rf /var/lib/apt/lists/*
 
 COPY script/build_curl.sh /build_curl.sh
+COPY resources/curl/* /tmp/
 RUN fallocate -l 10MB /tmp/testFile
 RUN apt-get update && apt-get install wget
 RUN /build_curl.sh
index 52f94bc..8071521 100644 (file)
@@ -20,8 +20,9 @@ const (
 
 type EnvoyProxySuite struct {
        HstSuite
-       nginxPort uint16
-       proxyPort uint16
+       nginxPort  uint16
+       proxyPort  uint16
+       maxTimeout int
 }
 
 var envoyProxyTests = map[string][]func(s *EnvoyProxySuite){}
@@ -39,6 +40,12 @@ func (s *EnvoyProxySuite) SetupSuite() {
        s.HstSuite.SetupSuite()
        s.LoadNetworkTopology("2taps")
        s.LoadContainerTopology("envoyProxy")
+
+       if *IsVppDebug {
+               s.maxTimeout = 600
+       } else {
+               s.maxTimeout = 60
+       }
 }
 
 func (s *EnvoyProxySuite) SetupTest() {
@@ -71,10 +78,12 @@ func (s *EnvoyProxySuite) SetupTest() {
                LogPrefix string
                Address   string
                Port      uint16
+               Timeout   int
        }{
                LogPrefix: nginxContainer.Name,
                Address:   serverInterface.Ip4AddressString(),
                Port:      s.nginxPort,
+               Timeout:   s.maxTimeout,
        }
        nginxContainer.CreateConfig(
                "/nginx.conf",
@@ -130,16 +139,18 @@ func (s *EnvoyProxySuite) ProxyAddr() string {
 }
 
 func (s *EnvoyProxySuite) CurlDownloadResource(uri string) {
-       args := fmt.Sprintf("--insecure --noproxy '*' --remote-name --output-dir /tmp %s", uri)
-       _, log := s.RunCurlContainer(args)
-       s.AssertNotContains(log, "Recv failure")
-       s.AssertContains(log, "HTTP/1.1 200")
+       args := fmt.Sprintf("-w @/tmp/write_out_download --max-time %d --insecure --noproxy '*' --remote-name --output-dir /tmp %s", s.maxTimeout, uri)
+       writeOut, log := s.RunCurlContainer(args)
+       s.AssertContains(writeOut, "GET response code: 200")
+       s.AssertNotContains(log, "bytes remaining to read")
+       s.AssertNotContains(log, "Operation timed out")
 }
 
 func (s *EnvoyProxySuite) CurlUploadResource(uri, file string) {
-       args := fmt.Sprintf("--insecure --noproxy '*' -T %s %s", file, uri)
-       _, log := s.RunCurlContainer(args)
-       s.AssertContains(log, "HTTP/1.1 201")
+       args := fmt.Sprintf("-w @/tmp/write_out_upload --max-time %d --insecure --noproxy '*' -T %s %s", s.maxTimeout, file, uri)
+       writeOut, log := s.RunCurlContainer(args)
+       s.AssertContains(writeOut, "PUT response code: 201")
+       s.AssertNotContains(log, "Operation timed out")
 }
 
 var _ = Describe("EnvoyProxySuite", Ordered, ContinueOnFailure, func() {
index e43787d..75215cf 100644 (file)
@@ -22,7 +22,8 @@ var nginxProxySoloTests = map[string][]func(s *NginxProxySuite){}
 
 type NginxProxySuite struct {
        HstSuite
-       proxyPort uint16
+       proxyPort  uint16
+       maxTimeout int
 }
 
 func RegisterNginxProxyTests(tests ...func(s *NginxProxySuite)) {
@@ -36,6 +37,12 @@ func (s *NginxProxySuite) SetupSuite() {
        s.HstSuite.SetupSuite()
        s.LoadNetworkTopology("2taps")
        s.LoadContainerTopology("nginxProxy")
+
+       if *IsVppDebug {
+               s.maxTimeout = 600
+       } else {
+               s.maxTimeout = 60
+       }
 }
 
 func (s *NginxProxySuite) SetupTest() {
@@ -85,9 +92,11 @@ func (s *NginxProxySuite) SetupTest() {
        nginxSettings := struct {
                LogPrefix string
                Address   string
+               Timeout   int
        }{
                LogPrefix: nginxServerContainer.Name,
                Address:   serverInterface.Ip4AddressString(),
+               Timeout:   s.maxTimeout,
        }
        nginxServerContainer.CreateConfig(
                "/nginx.conf",
@@ -116,10 +125,11 @@ func (s *NginxProxySuite) ProxyAddr() string {
 }
 
 func (s *NginxProxySuite) CurlDownloadResource(uri string) {
-       args := fmt.Sprintf("--insecure --noproxy '*' --remote-name --output-dir /tmp %s", uri)
-       _, log := s.RunCurlContainer(args)
-       s.AssertNotContains(log, "Recv failure")
-       s.AssertContains(log, "HTTP/1.1 200")
+       args := fmt.Sprintf("-w @/tmp/write_out_download --max-time %d --insecure --noproxy '*' --remote-name --output-dir /tmp %s", s.maxTimeout, uri)
+       writeOut, log := s.RunCurlContainer(args)
+       s.AssertContains(writeOut, "GET response code: 200")
+       s.AssertNotContains(log, "bytes remaining to read")
+       s.AssertNotContains(log, "Operation timed out")
 }
 
 var _ = Describe("NginxProxySuite", Ordered, ContinueOnFailure, func() {
index a13897e..21e81e0 100644 (file)
@@ -23,7 +23,8 @@ const (
 
 type VppProxySuite struct {
        HstSuite
-       nginxPort uint16
+       nginxPort  uint16
+       maxTimeout int
 }
 
 var vppProxyTests = map[string][]func(s *VppProxySuite){}
@@ -41,6 +42,12 @@ func (s *VppProxySuite) SetupSuite() {
        s.HstSuite.SetupSuite()
        s.LoadNetworkTopology("2taps")
        s.LoadContainerTopology("vppProxy")
+
+       if *IsVppDebug {
+               s.maxTimeout = 600
+       } else {
+               s.maxTimeout = 60
+       }
 }
 
 func (s *VppProxySuite) SetupTest() {
@@ -64,10 +71,12 @@ func (s *VppProxySuite) SetupTest() {
                LogPrefix string
                Address   string
                Port      uint16
+               Timeout   int
        }{
                LogPrefix: nginxContainer.Name,
                Address:   serverInterface.Ip4AddressString(),
                Port:      s.nginxPort,
+               Timeout:   s.maxTimeout,
        }
        nginxContainer.CreateConfig(
                "/nginx.conf",
@@ -78,7 +87,10 @@ func (s *VppProxySuite) SetupTest() {
 }
 
 func (s *VppProxySuite) TearDownTest() {
+       vpp := s.GetContainerByName(VppProxyContainerName).VppInstance
        if CurrentSpecReport().Failed() {
+               s.Log(vpp.Vppctl("show session verbose 2"))
+               s.Log(vpp.Vppctl("show error"))
                s.CollectNginxLogs(NginxServerContainerName)
        }
        s.HstSuite.TearDownTest()
@@ -103,40 +115,41 @@ func (s *VppProxySuite) CurlRequest(targetUri string) (string, string) {
 }
 
 func (s *VppProxySuite) CurlRequestViaTunnel(targetUri string, proxyUri string) (string, string) {
-       args := fmt.Sprintf("--max-time 60 --insecure -p -x %s %s", proxyUri, targetUri)
+       args := fmt.Sprintf("--max-time %d --insecure -p -x %s %s", s.maxTimeout, proxyUri, targetUri)
        body, log := s.RunCurlContainer(args)
        return body, log
 }
 
 func (s *VppProxySuite) CurlDownloadResource(uri string) {
-       args := fmt.Sprintf("--insecure --noproxy '*' --remote-name --output-dir /tmp %s", uri)
-       _, log := s.RunCurlContainer(args)
-       s.AssertNotContains(log, "Recv failure")
-       s.AssertContains(log, "HTTP/1.1 200")
+       args := fmt.Sprintf("-w @/tmp/write_out_download --max-time %d --insecure --noproxy '*' --remote-name --output-dir /tmp %s", s.maxTimeout, uri)
+       writeOut, log := s.RunCurlContainer(args)
+       s.AssertContains(writeOut, "GET response code: 200")
+       s.AssertNotContains(log, "bytes remaining to read")
+       s.AssertNotContains(log, "Operation timed out")
 }
 
 func (s *VppProxySuite) CurlUploadResource(uri, file string) {
-       args := fmt.Sprintf("--insecure --noproxy '*' -T %s %s", file, uri)
-       _, log := s.RunCurlContainer(args)
-       s.AssertContains(log, "HTTP/1.1 201")
+       args := fmt.Sprintf("-w @/tmp/write_out_upload --max-time %d --insecure --noproxy '*' -T %s %s", s.maxTimeout, file, uri)
+       writeOut, log := s.RunCurlContainer(args)
+       s.AssertContains(writeOut, "PUT response code: 201")
+       s.AssertNotContains(log, "Operation timed out")
 }
 
 func (s *VppProxySuite) CurlDownloadResourceViaTunnel(uri string, proxyUri string) {
-       args := fmt.Sprintf("--max-time 180 --insecure -p -x %s --remote-name --output-dir /tmp %s", proxyUri, uri)
-       _, log := s.RunCurlContainer(args)
-       s.AssertNotContains(log, "Recv failure")
-       s.AssertNotContains(log, "Operation timed out")
-       s.AssertContains(log, "CONNECT tunnel established")
-       s.AssertContains(log, "HTTP/1.1 200")
+       args := fmt.Sprintf("-w @/tmp/write_out_download_connect --max-time %d --insecure -p -x %s --remote-name --output-dir /tmp %s", s.maxTimeout, proxyUri, uri)
+       writeOut, log := s.RunCurlContainer(args)
+       s.AssertContains(writeOut, "CONNECT response code: 200")
+       s.AssertContains(writeOut, "GET response code: 200")
        s.AssertNotContains(log, "bytes remaining to read")
+       s.AssertNotContains(log, "Operation timed out")
 }
 
 func (s *VppProxySuite) CurlUploadResourceViaTunnel(uri, proxyUri, file string) {
-       args := fmt.Sprintf("--max-time 180 --insecure -p -x %s -T %s %s", proxyUri, file, uri)
-       _, log := s.RunCurlContainer(args)
+       args := fmt.Sprintf("-w @/tmp/write_out_upload_connect --max-time %d --insecure -p -x %s -T %s %s", s.maxTimeout, proxyUri, file, uri)
+       writeOut, log := s.RunCurlContainer(args)
+       s.AssertContains(writeOut, "CONNECT response code: 200")
+       s.AssertContains(writeOut, "PUT response code: 201")
        s.AssertNotContains(log, "Operation timed out")
-       s.AssertContains(log, "CONNECT tunnel established")
-       s.AssertContains(log, "HTTP/1.1 201")
 }
 
 var _ = Describe("VppProxySuite", Ordered, ContinueOnFailure, func() {
diff --git a/extras/hs-test/resources/curl/write_out_download b/extras/hs-test/resources/curl/write_out_download
new file mode 100644 (file)
index 0000000..9fc7699
--- /dev/null
@@ -0,0 +1 @@
+Download size: %{size_download} bytes\nDownload speed: %{speed_download} bytes per second\nGET response code: %{response_code}\n
\ No newline at end of file
diff --git a/extras/hs-test/resources/curl/write_out_download_connect b/extras/hs-test/resources/curl/write_out_download_connect
new file mode 100644 (file)
index 0000000..bd7c915
--- /dev/null
@@ -0,0 +1 @@
+Download size: %{size_download} bytes\nDownload speed: %{speed_download} bytes per second\nCONNECT response code: %{http_connect}\nGET response code: %{response_code}\n
\ No newline at end of file
diff --git a/extras/hs-test/resources/curl/write_out_upload b/extras/hs-test/resources/curl/write_out_upload
new file mode 100644 (file)
index 0000000..c2857aa
--- /dev/null
@@ -0,0 +1 @@
+Upload size: %{size_upload} bytes\nUpload speed: %{speed_upload} bytes per second\nPUT response code: %{response_code}\n
\ No newline at end of file
diff --git a/extras/hs-test/resources/curl/write_out_upload_connect b/extras/hs-test/resources/curl/write_out_upload_connect
new file mode 100644 (file)
index 0000000..3502165
--- /dev/null
@@ -0,0 +1 @@
+Upload size: %{size_upload} bytes\nUpload speed: %{speed_upload} bytes per second\nCONNECT response code: %{http_connect}\nPUT response code: %{response_code}\n
\ No newline at end of file
index 62d27cb..26d5834 100644 (file)
@@ -15,6 +15,9 @@ events {
 http {
   keepalive_timeout 300s;
   keepalive_requests 1000000;
+  client_body_timeout {{.Timeout}}s;
+  client_header_timeout {{.Timeout}}s;
+  send_timeout {{.Timeout}}s;
   sendfile on;
   server {
     access_log /tmp/nginx/{{.LogPrefix}}-access.log;