blob: 167cf25fa529218ce0262900fe46074a5a257341 [file] [log] [blame]
Filip Tehlar229f5fc2022-08-09 14:44:47 +00001package main
2
3import (
Adrian Villin4677d922024-06-14 09:32:39 +02004 . "fd.io/hs-test/infra"
Filip Tehlar229f5fc2022-08-09 14:44:47 +00005 "fmt"
Filip Tehlar229f5fc2022-08-09 14:44:47 +00006)
7
Adrian Villincee15aa2024-03-14 11:42:55 -04008func init() {
Matus Fabian8792e5c2024-08-14 12:38:20 +02009 RegisterVppProxyTests(VppProxyHttpTcpTest, VppProxyHttpTlsTest)
10 RegisterEnvoyProxyTests(EnvoyProxyHttpTcpTest)
Matus Fabian7301abe2024-08-21 17:25:41 +020011 RegisterNginxProxyTests(NginxMirroringTest)
Adrian Villincee15aa2024-03-14 11:42:55 -040012}
13
Matus Fabian8792e5c2024-08-14 12:38:20 +020014func 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 Tehlar3336eef2023-11-29 07:40:18 +010018 proto,
Matus Fabian8792e5c2024-08-14 12:38:20 +020019 s.VppProxyAddr(),
20 proxyPort,
21 s.NginxAddr(),
22 s.NginxPort(),
Maros Ondrejicka2908f8c2023-02-02 08:58:04 +010023 )
Adrian Villin4677d922024-06-14 09:32:39 +020024 s.Log("proxy configured: " + output)
Filip Tehlar229f5fc2022-08-09 14:44:47 +000025}
26
Matus Fabian8792e5c2024-08-14 12:38:20 +020027func 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 Tehlar3336eef2023-11-29 07:40:18 +010032}
33
Matus Fabian8792e5c2024-08-14 12:38:20 +020034func 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 Tehlar229f5fc2022-08-09 14:44:47 +000039}
40
Matus Fabian8792e5c2024-08-14 12:38:20 +020041func EnvoyProxyHttpTcpTest(s *EnvoyProxySuite) {
42 uri := fmt.Sprintf("http://%s:%d/httpTestFile", s.ProxyAddr(), s.ProxyPort())
43 s.CurlDownloadResource(uri)
Filip Tehlar229f5fc2022-08-09 14:44:47 +000044}
Matus Fabian7301abe2024-08-21 17:25:41 +020045
46// broken when CPUS > 1
47func NginxMirroringTest(s *NginxProxySuite) {
48 s.SkipIfMultiWorker()
49 uri := fmt.Sprintf("http://%s:%d/httpTestFile", s.ProxyAddr(), s.ProxyPort())
50 s.CurlDownloadResource(uri)
51}