diff options
author | Matus Fabian <matfabia@cisco.com> | 2024-08-14 12:38:20 +0200 |
---|---|---|
committer | Florin Coras <florin.coras@gmail.com> | 2024-08-22 03:25:19 +0000 |
commit | 8792e5c5c5e8e4f6c514ff81c97a7fb31890d657 (patch) | |
tree | ebb33de76afe10d080969ee6fc9d543935e1564a /extras/hs-test/infra/utils.go | |
parent | 58cb6ba81833a79a877448aa60d7d68604ad6c4e (diff) |
hs-test: proxy testing improvement
- new container topologies and suites for VPP proxy and Envoy proxy
- removed build docker image since it can't be used with CI cache
builder, container builders are designed to be stateless, they
only preserve build-cache, but not images
Type: test
Change-Id: I93e4d079780d18d6aa3b5ce807adc4707b6f2d9b
Signed-off-by: Matus Fabian <matfabia@cisco.com>
Diffstat (limited to 'extras/hs-test/infra/utils.go')
-rw-r--r-- | extras/hs-test/infra/utils.go | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/extras/hs-test/infra/utils.go b/extras/hs-test/infra/utils.go index 05b7b365487..3df83f32508 100644 --- a/extras/hs-test/infra/utils.go +++ b/extras/hs-test/infra/utils.go @@ -7,6 +7,7 @@ import ( "net/http" "net/http/httputil" "os" + "os/exec" "strings" "time" ) @@ -126,3 +127,59 @@ func TcpSendReceive(address, data string) (string, error) { } return string(reply), nil } + +/* +RunCurlContainer execute curl command with given args. +Container with name "curl" must be available. +Curl runs in verbose mode and progress meter switch off by default. +*/ +func (s *HstSuite) RunCurlContainer(args string) (string, string) { + curlCont := s.GetContainerByName("curl") + cmd := fmt.Sprintf("curl -v -s %s", args) + s.Log(cmd) + curlCont.ExtraRunningArgs = cmd + curlCont.Run() + stdout, stderr := curlCont.GetOutput() + s.Log(stderr) + s.Log(stdout) + return stdout, stderr +} + +/* +CollectNginxLogs save access and error logs to the test execution directory. +Nginx logging need to be set following way: + + - error_log <default-work-dir>/{{.LogPrefix}}-error.log; + - access_log <default-work-dir>/{{.LogPrefix}}-access.log; + +where LogPrefix is set to nginxContainer.Name +*/ +func (s *HstSuite) CollectNginxLogs(containerName string) { + nginxContainer := s.GetContainerByName(containerName) + targetDir := nginxContainer.getLogDirPath() + source := nginxContainer.GetHostWorkDir() + "/" + nginxContainer.Name + "-" + cmd := exec.Command("cp", "-t", targetDir, source+"error.log", source+"access.log") + s.Log(cmd.String()) + err := cmd.Run() + if err != nil { + s.Log(fmt.Sprint(err)) + } +} + +/* +CollectEnvoyLogs save access logs to the test execution directory. +Envoy access log path need to be set following way: +<default-work-dir>/{{.LogPrefix}}-access.log +where LogPrefix is set to envoyContainer.Name +*/ +func (s *HstSuite) CollectEnvoyLogs(containerName string) { + envoyContainer := s.GetContainerByName(containerName) + targetDir := envoyContainer.getLogDirPath() + source := envoyContainer.GetHostWorkDir() + "/" + envoyContainer.Name + "-" + cmd := exec.Command("cp", "-t", targetDir, source+"access.log") + s.Log(cmd.String()) + err := cmd.Run() + if err != nil { + s.Log(fmt.Sprint(err)) + } +} |