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 c := fmt.Sprintf("ip netns exec client wget --retry-connrefused --retry-on-http-error=503 --tries=10 -O %s 10.0.0.2:555/%s", outputFile, srcFile)
34 _, err = exechelper.CombinedOutput(c)
35 s.assertNil(err, "failed to run wget")
36 stopServer <- struct{}{}
38 defer func() { os.Remove(outputFile) }()
40 s.assertNil(assertFileSize(outputFile, srcFile))
44 func configureVppProxy(s *NsSuite) error {
45 container := s.getContainerByName("vpp")
46 testVppProxy := NewVppInstance(container)
47 testVppProxy.setVppProxy()
48 err := testVppProxy.start()
49 s.assertNil(err, "failed to start and configure VPP")
50 s.log("VPP running and configured...")
52 output, err := testVppProxy.vppctl("test proxy server server-uri tcp://10.0.0.2/555 client-uri tcp://10.0.1.1/666")
53 s.log("Proxy configured...", string(output))
57 func (s *NsSuite) TestVppProxyHttpTcp() {
58 err := configureVppProxy(s)
60 err = testProxyHttpTcp(s)
64 func configureEnvoyProxy(s *NsSuite) error {
65 vppContainer := s.getContainerByName("vpp")
66 testVppForEnvoyProxy := NewVppInstance(vppContainer)
67 testVppForEnvoyProxy.setEnvoyProxy()
68 err := testVppForEnvoyProxy.start()
69 s.assertNil(err, "failed to start and configure VPP")
71 envoyContainer := s.getContainerByName("envoy")
72 return envoyContainer.run()
75 func (s *NsSuite) TestEnvoyProxyHttpTcp() {
76 err := configureEnvoyProxy(s)
78 err = testProxyHttpTcp(s)