7 "github.com/edwarnicke/exechelper"
10 func testProxyHttpTcp(s *NsSuite) 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 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"+
38 clientVeth.ip4AddressString(),
42 _, err = exechelper.CombinedOutput(c)
43 s.assertNil(err, "failed to run wget")
44 stopServer <- struct{}{}
46 defer func() { os.Remove(outputFile) }()
48 s.assertNil(assertFileSize(outputFile, srcFile))
52 func configureVppProxy(s *NsSuite) {
53 serverVeth := s.netInterfaces[serverInterface]
54 clientVeth := s.netInterfaces[clientInterface]
56 testVppProxy := s.getContainerByName("vpp").vppInstance
57 output := testVppProxy.vppctl(
58 "test proxy server server-uri tcp://%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 err := testProxyHttpTcp(s)
71 func configureEnvoyProxy(s *NsSuite) {
72 envoyContainer := s.getContainerByName("envoy")
73 envoyContainer.create()
75 serverVeth := s.netInterfaces[serverInterface]
79 Server: serverVeth.peer.ip4AddressString(),
81 envoyContainer.createConfig(
82 "/etc/envoy/envoy.yaml",
83 "resources/envoy/proxy.yaml",
86 s.assertNil(envoyContainer.start())
89 func (s *NsSuite) TestEnvoyProxyHttpTcp() {
90 configureEnvoyProxy(s)
91 err := testProxyHttpTcp(s)