7 "github.com/edwarnicke/exechelper"
10 func testProxyHttpTcp(s *NsSuite, proto string) error {
11 const outputFile = "test.data"
13 stopServer := make(chan struct{}, 1)
14 serverRunning := make(chan struct{}, 1)
17 err := exechelper.Run(fmt.Sprintf("ip netns exec server truncate -s %s %s", srcFile, srcFile))
18 s.assertNil(err, "failed to run truncate command")
19 defer func() { os.Remove(srcFile) }()
21 s.log("test file created...")
23 go s.startHttpServer(serverRunning, stopServer, ":666", "server")
24 // TODO better error handling and recovery
27 defer func(chan struct{}) {
28 stopServer <- struct{}{}
31 s.log("http server started...")
33 clientVeth := s.netInterfaces[clientInterface]
34 c := fmt.Sprintf("ip netns exec client wget --no-proxy --retry-connrefused"+
35 " --retry-on-http-error=503 --tries=10 -O %s ", outputFile)
37 c += " --secure-protocol=TLSv1_3 --no-check-certificate https://"
39 c += fmt.Sprintf("%s:555/%s", clientVeth.ip4AddressString(), srcFile)
41 _, err = exechelper.CombinedOutput(c)
42 s.assertNil(err, "failed to run wget")
43 stopServer <- struct{}{}
45 defer func() { os.Remove(outputFile) }()
47 s.assertNil(assertFileSize(outputFile, srcFile))
51 func configureVppProxy(s *NsSuite, proto string) {
52 serverVeth := s.netInterfaces[serverInterface]
53 clientVeth := s.netInterfaces[clientInterface]
55 testVppProxy := s.getContainerByName("vpp").vppInstance
56 output := testVppProxy.vppctl(
57 "test proxy server server-uri %s://%s/555 client-uri tcp://%s/666",
59 clientVeth.ip4AddressString(),
60 serverVeth.peer.ip4AddressString(),
62 s.log("proxy configured...", output)
65 func (s *NsSuite) TestVppProxyHttpTcp() {
67 configureVppProxy(s, proto)
68 err := testProxyHttpTcp(s, proto)
72 func (s *NsSuite) TestVppProxyHttpTls() {
74 configureVppProxy(s, proto)
75 err := testProxyHttpTcp(s, proto)
79 func configureEnvoyProxy(s *NsSuite) {
80 envoyContainer := s.getContainerByName("envoy")
81 envoyContainer.create()
83 serverVeth := s.netInterfaces[serverInterface]
87 Server: serverVeth.peer.ip4AddressString(),
89 envoyContainer.createConfig(
90 "/etc/envoy/envoy.yaml",
91 "resources/envoy/proxy.yaml",
94 s.assertNil(envoyContainer.start())
97 func (s *NsSuite) TestEnvoyProxyHttpTcp() {
98 configureEnvoyProxy(s)
99 err := testProxyHttpTcp(s, "tcp")