diff options
Diffstat (limited to 'extras/hs-test/infra/suite_vpp_proxy.go')
-rw-r--r-- | extras/hs-test/infra/suite_vpp_proxy.go | 70 |
1 files changed, 38 insertions, 32 deletions
diff --git a/extras/hs-test/infra/suite_vpp_proxy.go b/extras/hs-test/infra/suite_vpp_proxy.go index 51beade2d9b..37d251a3a6d 100644 --- a/extras/hs-test/infra/suite_vpp_proxy.go +++ b/extras/hs-test/infra/suite_vpp_proxy.go @@ -14,20 +14,25 @@ import ( . "github.com/onsi/ginkgo/v2" ) -// These correspond to names used in yaml config const ( - VppProxyContainerName = "vpp-proxy" - ClientTapInterfaceName = "hstcln" - ServerTapInterfaceName = "hstsrv" - IperfServerContainerName = "iperfA" - IperfClientContainerName = "iperfB" - CurlContainerTestFile = "/tmp/testFile" + CurlContainerTestFile = "/tmp/testFile" ) type VppProxySuite struct { HstSuite serverPort uint16 maxTimeout int + Interfaces struct { + Client *NetInterface + Server *NetInterface + } + Containers struct { + VppProxy *Container + Curl *Container + NginxServerTransient *Container + IperfS *Container + IperfC *Container + } } var vppProxyTests = map[string][]func(s *VppProxySuite){} @@ -52,22 +57,25 @@ func (s *VppProxySuite) SetupSuite() { } else { s.maxTimeout = 60 } + s.Interfaces.Client = s.GetInterfaceByName("hstcln") + s.Interfaces.Server = s.GetInterfaceByName("hstsrv") + s.Containers.NginxServerTransient = s.GetTransientContainerByName("nginx-server") + s.Containers.VppProxy = s.GetContainerByName("vpp-proxy") + s.Containers.Curl = s.GetContainerByName("curl") + s.Containers.IperfC = s.GetContainerByName("iperfC") + s.Containers.IperfS = s.GetContainerByName("iperfS") } func (s *VppProxySuite) SetupTest() { s.HstSuite.SetupTest() // VPP HTTP connect-proxy - vppContainer := s.GetContainerByName(VppProxyContainerName) - vpp, err := vppContainer.newVppInstance(vppContainer.AllocatedCpus) + vpp, err := s.Containers.VppProxy.newVppInstance(s.Containers.VppProxy.AllocatedCpus) s.AssertNotNil(vpp, fmt.Sprint(err)) - clientInterface := s.GetInterfaceByName(ClientTapInterfaceName) - serverInterface := s.GetInterfaceByName(ServerTapInterfaceName) - s.AssertNil(vpp.Start()) - s.AssertNil(vpp.CreateTap(clientInterface, 1, 1)) - s.AssertNil(vpp.CreateTap(serverInterface, 1, 2)) + s.AssertNil(vpp.CreateTap(s.Interfaces.Client, 1, 1)) + s.AssertNil(vpp.CreateTap(s.Interfaces.Server, 1, 2)) if *DryRun { s.LogStartedContainers() @@ -76,36 +84,34 @@ func (s *VppProxySuite) SetupTest() { } func (s *VppProxySuite) TearDownTest() { - vpp := s.GetContainerByName(VppProxyContainerName).VppInstance + vpp := s.Containers.VppProxy.VppInstance if CurrentSpecReport().Failed() { s.Log(vpp.Vppctl("show session verbose 2")) s.Log(vpp.Vppctl("show error")) - s.CollectNginxLogs(NginxServerContainerName) + s.CollectNginxLogs(s.Containers.NginxServerTransient) } s.HstSuite.TearDownTest() } func (s *VppProxySuite) SetupNginxServer() { - nginxContainer := s.GetTransientContainerByName(NginxServerContainerName) - serverInterface := s.GetInterfaceByName(ServerTapInterfaceName) - s.AssertNil(nginxContainer.Create()) + s.AssertNil(s.Containers.NginxServerTransient.Create()) nginxSettings := struct { LogPrefix string Address string Port uint16 Timeout int }{ - LogPrefix: nginxContainer.Name, - Address: serverInterface.Ip4AddressString(), + LogPrefix: s.Containers.NginxServerTransient.Name, + Address: s.Interfaces.Server.Ip4AddressString(), Port: s.serverPort, Timeout: s.maxTimeout, } - nginxContainer.CreateConfigFromTemplate( + s.Containers.NginxServerTransient.CreateConfigFromTemplate( "/nginx.conf", "./resources/nginx/nginx_server.conf", nginxSettings, ) - s.AssertNil(nginxContainer.Start()) + s.AssertNil(s.Containers.NginxServerTransient.Start()) } func (s *VppProxySuite) ServerPort() uint16 { @@ -113,32 +119,32 @@ func (s *VppProxySuite) ServerPort() uint16 { } func (s *VppProxySuite) ServerAddr() string { - return s.GetInterfaceByName(ServerTapInterfaceName).Ip4AddressString() + return s.Interfaces.Server.Ip4AddressString() } func (s *VppProxySuite) VppProxyAddr() string { - return s.GetInterfaceByName(ClientTapInterfaceName).Peer.Ip4AddressString() + return s.Interfaces.Client.Peer.Ip4AddressString() } func (s *VppProxySuite) ClientAddr() string { - return s.GetInterfaceByName(ClientTapInterfaceName).Ip4AddressString() + return s.Interfaces.Client.Ip4AddressString() } func (s *VppProxySuite) CurlRequest(targetUri string) (string, string) { args := fmt.Sprintf("--insecure --noproxy '*' %s", targetUri) - body, log := s.RunCurlContainer(args) + body, log := s.RunCurlContainer(s.Containers.Curl, args) return body, log } func (s *VppProxySuite) CurlRequestViaTunnel(targetUri string, proxyUri string) (string, string) { args := fmt.Sprintf("--max-time %d --insecure -p -x %s %s", s.maxTimeout, proxyUri, targetUri) - body, log := s.RunCurlContainer(args) + body, log := s.RunCurlContainer(s.Containers.Curl, args) return body, log } func (s *VppProxySuite) CurlDownloadResource(uri string) { 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) + writeOut, log := s.RunCurlContainer(s.Containers.Curl, args) s.AssertContains(writeOut, "GET response code: 200") s.AssertNotContains(log, "bytes remaining to read") s.AssertNotContains(log, "Operation timed out") @@ -146,14 +152,14 @@ func (s *VppProxySuite) CurlDownloadResource(uri string) { func (s *VppProxySuite) CurlUploadResource(uri, file string) { 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) + writeOut, log := s.RunCurlContainer(s.Containers.Curl, 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("-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) + writeOut, log := s.RunCurlContainer(s.Containers.Curl, args) s.AssertContains(writeOut, "CONNECT response code: 200") s.AssertContains(writeOut, "GET response code: 200") s.AssertNotContains(log, "bytes remaining to read") @@ -163,7 +169,7 @@ func (s *VppProxySuite) CurlDownloadResourceViaTunnel(uri string, proxyUri strin func (s *VppProxySuite) CurlUploadResourceViaTunnel(uri, proxyUri, file string) { 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) + writeOut, log := s.RunCurlContainer(s.Containers.Curl, args) s.AssertContains(writeOut, "CONNECT response code: 200") s.AssertContains(writeOut, "PUT response code: 201") s.AssertNotContains(log, "Operation timed out") |