Filip Tehlar | 229f5fc | 2022-08-09 14:44:47 +0000 | [diff] [blame] | 1 | package main |
| 2 | |
| 3 | import ( |
Adrian Villin | 4677d92 | 2024-06-14 09:32:39 +0200 | [diff] [blame] | 4 | . "fd.io/hs-test/infra" |
Filip Tehlar | 229f5fc | 2022-08-09 14:44:47 +0000 | [diff] [blame] | 5 | "fmt" |
Filip Tehlar | 229f5fc | 2022-08-09 14:44:47 +0000 | [diff] [blame] | 6 | ) |
| 7 | |
Adrian Villin | cee15aa | 2024-03-14 11:42:55 -0400 | [diff] [blame] | 8 | func init() { |
Matus Fabian | 8792e5c | 2024-08-14 12:38:20 +0200 | [diff] [blame] | 9 | RegisterVppProxyTests(VppProxyHttpTcpTest, VppProxyHttpTlsTest) |
| 10 | RegisterEnvoyProxyTests(EnvoyProxyHttpTcpTest) |
Matus Fabian | 7301abe | 2024-08-21 17:25:41 +0200 | [diff] [blame] | 11 | RegisterNginxProxyTests(NginxMirroringTest) |
Adrian Villin | cee15aa | 2024-03-14 11:42:55 -0400 | [diff] [blame] | 12 | } |
| 13 | |
Matus Fabian | 8792e5c | 2024-08-14 12:38:20 +0200 | [diff] [blame] | 14 | func configureVppProxy(s *VppProxySuite, proto string, proxyPort uint16) { |
| 15 | vppProxy := s.GetContainerByName(VppProxyContainerName).VppInstance |
| 16 | output := vppProxy.Vppctl( |
| 17 | "test proxy server server-uri %s://%s/%d client-uri tcp://%s/%d", |
Filip Tehlar | 3336eef | 2023-11-29 07:40:18 +0100 | [diff] [blame] | 18 | proto, |
Matus Fabian | 8792e5c | 2024-08-14 12:38:20 +0200 | [diff] [blame] | 19 | s.VppProxyAddr(), |
| 20 | proxyPort, |
| 21 | s.NginxAddr(), |
| 22 | s.NginxPort(), |
Maros Ondrejicka | 2908f8c | 2023-02-02 08:58:04 +0100 | [diff] [blame] | 23 | ) |
Adrian Villin | 4677d92 | 2024-06-14 09:32:39 +0200 | [diff] [blame] | 24 | s.Log("proxy configured: " + output) |
Filip Tehlar | 229f5fc | 2022-08-09 14:44:47 +0000 | [diff] [blame] | 25 | } |
| 26 | |
Matus Fabian | 8792e5c | 2024-08-14 12:38:20 +0200 | [diff] [blame] | 27 | func VppProxyHttpTcpTest(s *VppProxySuite) { |
| 28 | var proxyPort uint16 = 8080 |
| 29 | configureVppProxy(s, "tcp", proxyPort) |
| 30 | uri := fmt.Sprintf("http://%s:%d/httpTestFile", s.VppProxyAddr(), proxyPort) |
| 31 | s.CurlDownloadResource(uri) |
Filip Tehlar | 3336eef | 2023-11-29 07:40:18 +0100 | [diff] [blame] | 32 | } |
| 33 | |
Matus Fabian | 8792e5c | 2024-08-14 12:38:20 +0200 | [diff] [blame] | 34 | func VppProxyHttpTlsTest(s *VppProxySuite) { |
| 35 | var proxyPort uint16 = 8080 |
| 36 | configureVppProxy(s, "tls", proxyPort) |
| 37 | uri := fmt.Sprintf("https://%s:%d/httpTestFile", s.VppProxyAddr(), proxyPort) |
| 38 | s.CurlDownloadResource(uri) |
Filip Tehlar | 229f5fc | 2022-08-09 14:44:47 +0000 | [diff] [blame] | 39 | } |
| 40 | |
Matus Fabian | 8792e5c | 2024-08-14 12:38:20 +0200 | [diff] [blame] | 41 | func EnvoyProxyHttpTcpTest(s *EnvoyProxySuite) { |
| 42 | uri := fmt.Sprintf("http://%s:%d/httpTestFile", s.ProxyAddr(), s.ProxyPort()) |
| 43 | s.CurlDownloadResource(uri) |
Filip Tehlar | 229f5fc | 2022-08-09 14:44:47 +0000 | [diff] [blame] | 44 | } |
Matus Fabian | 7301abe | 2024-08-21 17:25:41 +0200 | [diff] [blame] | 45 | |
| 46 | // broken when CPUS > 1 |
| 47 | func NginxMirroringTest(s *NginxProxySuite) { |
| 48 | s.SkipIfMultiWorker() |
| 49 | uri := fmt.Sprintf("http://%s:%d/httpTestFile", s.ProxyAddr(), s.ProxyPort()) |
| 50 | s.CurlDownloadResource(uri) |
| 51 | } |