diff options
author | Adrian Villin <avillin@cisco.com> | 2024-12-09 14:18:31 +0100 |
---|---|---|
committer | Florin Coras <florin.coras@gmail.com> | 2024-12-11 17:47:04 +0000 |
commit | af5fcbfa713ca3693ee9d28354fe004b76f74d6a (patch) | |
tree | daeff93cee05a340586e69f73bc834141967b6a1 /extras/hs-test/nginx_test.go | |
parent | fb8f51697c748d28d4b542554a96a83ab74f6678 (diff) |
hs-test: replaced container/interface getter func
- replaced s.GetContainerByName("xyz") with s.Containers.Xyz in tests
and suites
- same thing for interfaces
- each suite has its own structs with containers/interfaces
- structs are initialized in SetupSuite
Type: test
Change-Id: I5bd99605b40921b7b8c844e8650f6fb0915e9e99
Signed-off-by: Adrian Villin <avillin@cisco.com>
Diffstat (limited to 'extras/hs-test/nginx_test.go')
-rw-r--r-- | extras/hs-test/nginx_test.go | 48 |
1 files changed, 21 insertions, 27 deletions
diff --git a/extras/hs-test/nginx_test.go b/extras/hs-test/nginx_test.go index 7a6f5b3c182..12aa2487c2d 100644 --- a/extras/hs-test/nginx_test.go +++ b/extras/hs-test/nginx_test.go @@ -17,22 +17,20 @@ func init() { func NginxHttp3Test(s *NoTopoSuite) { query := "index.html" - nginxCont := s.GetContainerByName(NginxHttp3ContainerName) - nginxCont.Create() - s.CreateNginxHttp3Config(nginxCont) - nginxCont.Start() + s.Containers.NginxHttp3.Create() + s.CreateNginxHttp3Config(s.Containers.NginxHttp3) + s.Containers.NginxHttp3.Start() - vpp := s.GetContainerByName("vpp").VppInstance + vpp := s.Containers.Vpp.VppInstance vpp.WaitForApp("nginx-", 5) serverAddress := s.VppAddr() defer func() { os.Remove(query) }() - curlCont := s.GetContainerByName("curl") args := fmt.Sprintf("curl --noproxy '*' --local-port 55444 --http3-only -k https://%s:8443/%s", serverAddress, query) - curlCont.ExtraRunningArgs = args - curlCont.Run() - body, stats := curlCont.GetOutput() + s.Containers.Curl.ExtraRunningArgs = args + s.Containers.Curl.Run() + body, stats := s.Containers.Curl.GetOutput() s.Log(body) s.Log(stats) s.AssertNotContains(stats, "refused") @@ -44,13 +42,12 @@ func NginxAsServerTest(s *NoTopoSuite) { query := "return_ok" finished := make(chan error, 1) - nginxCont := s.GetContainerByName("nginx") - nginxCont.Create() - s.CreateNginxConfig(nginxCont, false) + s.Containers.Nginx.Create() + s.CreateNginxConfig(s.Containers.Nginx, false) s.AddNginxVclConfig(false) - nginxCont.Start() + s.Containers.Nginx.Start() - vpp := s.GetContainerByName("vpp").VppInstance + vpp := s.Containers.Vpp.VppInstance vpp.WaitForApp("nginx-", 5) serverAddress := s.VppAddr() @@ -79,17 +76,15 @@ func runNginxPerf(s *NoTopoSuite, mode, ab_or_wrk string, multiThreadWorkers boo serverAddress := s.VppAddr() - vpp := s.GetContainerByName("vpp").VppInstance + vpp := s.Containers.Vpp.VppInstance - nginxCont := s.GetContainerByName(SingleTopoContainerNginx) - nginxCont.Create() + s.Containers.Nginx.Create() s.AddNginxVclConfig(multiThreadWorkers) - s.CreateNginxConfig(nginxCont, multiThreadWorkers) - nginxCont.Start() + s.CreateNginxConfig(s.Containers.Nginx, multiThreadWorkers) + s.Containers.Nginx.Start() vpp.WaitForApp("nginx-", 5) if ab_or_wrk == "ab" { - abCont := s.GetContainerByName("ab") args := fmt.Sprintf("-n %d -c %d", nRequests, nClients) if mode == "rps" { args += " -k" @@ -99,21 +94,20 @@ 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" - abCont.ExtraRunningArgs = args + s.Containers.Ab.ExtraRunningArgs = args s.Log("Test might take up to 2 minutes to finish. Please wait") - abCont.Run() - o, err := abCont.GetOutput() + s.Containers.Ab.Run() + o, err := s.Containers.Ab.GetOutput() rps := parseString(o, "Requests per second:") s.Log(rps) s.AssertContains(err, "Finished "+fmt.Sprint(nRequests)) } else { - wrkCont := s.GetContainerByName("wrk") args := fmt.Sprintf("-c %d -t 2 -d 30 http://%s:80/64B.json", nClients, serverAddress) - wrkCont.ExtraRunningArgs = args - wrkCont.Run() + s.Containers.Wrk.ExtraRunningArgs = args + s.Containers.Wrk.Run() s.Log("Please wait for 30s, test is running.") - o, err := wrkCont.GetOutput() + o, err := s.Containers.Wrk.GetOutput() rps := parseString(o, "requests") s.Log(rps) s.Log(err) |