1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
|
package main
import (
"fmt"
. "fd.io/hs-test/infra"
)
func init() {
RegisterVppProxyTests(VppProxyHttpGetTcpTest, VppProxyHttpGetTlsTest, VppProxyHttpPutTcpTest, VppProxyHttpPutTlsTest,
VppConnectProxyGetTest, VppConnectProxyPutTest)
RegisterEnvoyProxyTests(EnvoyProxyHttpGetTcpTest, EnvoyProxyHttpPutTcpTest)
RegisterNginxProxyTests(NginxMirroringTest)
RegisterNginxProxySoloTests(MirrorMultiThreadTest)
}
func configureVppProxy(s *VppProxySuite, proto string, proxyPort uint16) {
vppProxy := s.GetContainerByName(VppProxyContainerName).VppInstance
cmd := fmt.Sprintf("test proxy server fifo-size 512k server-uri %s://%s/%d", proto, s.VppProxyAddr(), proxyPort)
if proto != "http" {
cmd += fmt.Sprintf(" client-uri tcp://%s/%d", s.NginxAddr(), s.NginxPort())
}
output := vppProxy.Vppctl(cmd)
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)
}
func VppConnectProxyGetTest(s *VppProxySuite) {
var proxyPort uint16 = 8080
configureVppProxy(s, "http", proxyPort)
targetUri := fmt.Sprintf("http://%s:%d/httpTestFile", s.NginxAddr(), s.NginxPort())
proxyUri := fmt.Sprintf("http://%s:%d", s.VppProxyAddr(), proxyPort)
s.CurlDownloadResourceViaTunnel(targetUri, proxyUri)
}
func VppConnectProxyPutTest(s *VppProxySuite) {
var proxyPort uint16 = 8080
configureVppProxy(s, "http", proxyPort)
proxyUri := fmt.Sprintf("http://%s:%d", s.VppProxyAddr(), proxyPort)
targetUri := fmt.Sprintf("http://%s:%d/upload/testFile", s.NginxAddr(), s.NginxPort())
s.CurlUploadResourceViaTunnel(targetUri, proxyUri, CurlContainerTestFile)
}
|