package main import ( "fmt" . "fd.io/hs-test/infra" ) func init() { RegisterVppProxyTests(VppProxyHttpGetTcpTest, VppProxyHttpGetTlsTest, VppProxyHttpPutTcpTest, VppProxyHttpPutTlsTest) RegisterEnvoyProxyTests(EnvoyProxyHttpGetTcpTest, EnvoyProxyHttpPutTcpTest) RegisterNginxProxyTests(NginxMirroringTest) RegisterNginxProxySoloTests(MirrorMultiThreadTest) } func configureVppProxy(s *VppProxySuite, proto string, proxyPort uint16) { vppProxy := s.GetContainerByName(VppProxyContainerName).VppInstance output := vppProxy.Vppctl( "test proxy server server-uri %s://%s/%d client-uri tcp://%s/%d", proto, s.VppProxyAddr(), proxyPort, s.NginxAddr(), s.NginxPort(), ) s.Log("proxy configured: " + output) } func VppProxyHttpGetTcpTest(s *VppProxySuite) { var proxyPort uint16 = 8080 configureVppProxy(s, "tcp", proxyPort) uri := fmt.Sprintf("http://%s:%d/httpTestFile", s.VppProxyAddr(), proxyPort) s.CurlDownloadResource(uri) } func VppProxyHttpGetTlsTest(s *VppProxySuite) { var proxyPort uint16 = 8080 configureVppProxy(s, "tls", proxyPort) uri := fmt.Sprintf("https://%s:%d/httpTestFile", s.VppProxyAddr(), proxyPort) s.CurlDownloadResource(uri) } func VppProxyHttpPutTcpTest(s *VppProxySuite) { var proxyPort uint16 = 8080 configureVppProxy(s, "tcp", proxyPort) uri := fmt.Sprintf("http://%s:%d/upload/testFile", s.VppProxyAddr(), proxyPort) s.CurlUploadResource(uri, CurlContainerTestFile) } func VppProxyHttpPutTlsTest(s *VppProxySuite) { var proxyPort uint16 = 8080 configureVppProxy(s, "tls", proxyPort) uri := fmt.Sprintf("https://%s:%d/upload/testFile", s.VppProxyAddr(), proxyPort) s.CurlUploadResource(uri, CurlContainerTestFile) } func EnvoyProxyHttpGetTcpTest(s *EnvoyProxySuite) { uri := fmt.Sprintf("http://%s:%d/httpTestFile", s.ProxyAddr(), s.ProxyPort()) s.CurlDownloadResource(uri) } func EnvoyProxyHttpPutTcpTest(s *EnvoyProxySuite) { uri := fmt.Sprintf("http://%s:%d/upload/testFile", s.ProxyAddr(), s.ProxyPort()) s.CurlUploadResource(uri, CurlContainerTestFile) } func MirrorMultiThreadTest(s *NginxProxySuite) { nginxMirroring(s, true) } func NginxMirroringTest(s *NginxProxySuite) { nginxMirroring(s, false) } func nginxMirroring(s *NginxProxySuite, multiThreadWorkers bool) { nginxProxyContainer := s.GetContainerByName(NginxProxyContainerName) vpp := s.GetContainerByName(VppContainerName).VppInstance s.AddVclConfig(nginxProxyContainer, multiThreadWorkers) s.CreateNginxProxyConfig(nginxProxyContainer, multiThreadWorkers) nginxProxyContainer.Start() vpp.WaitForApp("nginx-", 5) uri := fmt.Sprintf("http://%s:%d/httpTestFile", s.ProxyAddr(), s.ProxyPort()) s.CurlDownloadResource(uri) }