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) error {
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)
66 func (s *NsSuite) TestVppProxyHttpTcp() {
67 err := configureVppProxy(s)
69 err = testProxyHttpTcp(s)
73 func configureEnvoyProxy(s *NsSuite) error {
74 envoyContainer := s.getContainerByName("envoy")
75 return envoyContainer.run()
78 func (s *NsSuite) TestEnvoyProxyHttpTcp() {
79 err := configureEnvoyProxy(s)
81 err = testProxyHttpTcp(s)