8 const vclTemplate = `vcl {
9 app-socket-api %[1]s/var/run/app_ns_sockets/%[2]s
13 namespace-secret %[2]s
18 func (s *VethsSuite) TestXEchoVclClientUdp() {
19 s.testXEchoVclClient("udp")
22 func (s *VethsSuite) TestXEchoVclClientTcp() {
23 s.testXEchoVclClient("tcp")
26 func (s *VethsSuite) testXEchoVclClient(proto string) {
28 serverVpp := s.getContainerByName("server-vpp").vppInstance
30 serverVeth := s.netInterfaces[serverInterfaceName]
31 serverVpp.vppctl("test echo server uri %s://%s/%s fifo-size 64k", proto, serverVeth.ip4AddressString(), port)
33 echoClnContainer := s.getTransientContainerByName("client-app")
34 clientVclConfContent := fmt.Sprintf(vclTemplate, echoClnContainer.getContainerWorkDir(), "2")
35 echoClnContainer.createFile("/vcl.conf", clientVclConfContent)
37 testClientCommand := "vcl_test_client -N 100 -p " + proto + " " + serverVeth.ip4AddressString() + " " + port
38 s.log(testClientCommand)
39 echoClnContainer.addEnvVar("VCL_CONFIG", "/vcl.conf")
40 o := echoClnContainer.exec(testClientCommand)
42 s.assertContains(o, "CLIENT RESULTS")
45 func (s *VethsSuite) TestXEchoVclServerUdp() {
46 s.testXEchoVclServer("udp")
49 func (s *VethsSuite) TestXEchoVclServerTcp() {
50 s.testXEchoVclServer("tcp")
53 func (s *VethsSuite) testXEchoVclServer(proto string) {
55 srvVppCont := s.getContainerByName("server-vpp")
56 srvAppCont := s.getContainerByName("server-app")
58 serverVclConfContent := fmt.Sprintf(vclTemplate, srvVppCont.getContainerWorkDir(), "1")
59 srvAppCont.createFile("/vcl.conf", serverVclConfContent)
60 srvAppCont.addEnvVar("VCL_CONFIG", "/vcl.conf")
61 vclSrvCmd := fmt.Sprintf("vcl_test_server -p %s %s", proto, port)
62 srvAppCont.execServer(vclSrvCmd)
64 serverVeth := s.netInterfaces[serverInterfaceName]
65 serverVethAddress := serverVeth.ip4AddressString()
67 clientVpp := s.getContainerByName("client-vpp").vppInstance
68 o := clientVpp.vppctl("test echo client uri %s://%s/%s fifo-size 64k verbose mbytes 2", proto, serverVethAddress, port)
70 s.assertContains(o, "Test finished at")
73 func (s *VethsSuite) testVclEcho(proto string) {
75 srvVppCont := s.getContainerByName("server-vpp")
76 srvAppCont := s.getContainerByName("server-app")
78 serverVclConfContent := fmt.Sprintf(vclTemplate, srvVppCont.getContainerWorkDir(), "1")
79 srvAppCont.createFile("/vcl.conf", serverVclConfContent)
80 srvAppCont.addEnvVar("VCL_CONFIG", "/vcl.conf")
81 srvAppCont.execServer("vcl_test_server " + port)
83 serverVeth := s.netInterfaces[serverInterfaceName]
84 serverVethAddress := serverVeth.ip4AddressString()
86 echoClnContainer := s.getTransientContainerByName("client-app")
87 clientVclConfContent := fmt.Sprintf(vclTemplate, echoClnContainer.getContainerWorkDir(), "2")
88 echoClnContainer.createFile("/vcl.conf", clientVclConfContent)
90 testClientCommand := "vcl_test_client -p " + proto + " " + serverVethAddress + " " + port
91 echoClnContainer.addEnvVar("VCL_CONFIG", "/vcl.conf")
92 o := echoClnContainer.exec(testClientCommand)
96 func (s *VethsSuite) TestVclEchoTcp() {
100 func (s *VethsSuite) TestVclEchoUdp() {
104 func (s *VethsSuite) TestVclRetryAttach() {
105 s.skip("this test takes too long, for now it's being skipped")
106 s.testRetryAttach("tcp")
109 func (s *VethsSuite) testRetryAttach(proto string) {
110 srvVppContainer := s.getTransientContainerByName("server-vpp")
112 echoSrvContainer := s.getContainerByName("server-app")
114 serverVclConfContent := fmt.Sprintf(vclTemplate, echoSrvContainer.getContainerWorkDir(), "1")
115 echoSrvContainer.createFile("/vcl.conf", serverVclConfContent)
117 echoSrvContainer.addEnvVar("VCL_CONFIG", "/vcl.conf")
118 echoSrvContainer.execServer("vcl_test_server -p " + proto + " 12346")
120 s.log("This whole test case can take around 3 minutes to run. Please be patient.")
121 s.log("... Running first echo client test, before disconnect.")
123 serverVeth := s.netInterfaces[serverInterfaceName]
124 serverVethAddress := serverVeth.ip4AddressString()
126 echoClnContainer := s.getTransientContainerByName("client-app")
127 clientVclConfContent := fmt.Sprintf(vclTemplate, echoClnContainer.getContainerWorkDir(), "2")
128 echoClnContainer.createFile("/vcl.conf", clientVclConfContent)
130 testClientCommand := "vcl_test_client -U -p " + proto + " " + serverVethAddress + " 12346"
131 echoClnContainer.addEnvVar("VCL_CONFIG", "/vcl.conf")
132 o := echoClnContainer.exec(testClientCommand)
134 s.log("... First test ended. Stopping VPP server now.")
136 // Stop server-vpp-instance, start it again and then run vcl-test-client once more
137 srvVppContainer.vppInstance.disconnect()
138 stopVppCommand := "/bin/bash -c 'ps -C vpp_main -o pid= | xargs kill -9'"
139 srvVppContainer.exec(stopVppCommand)
143 s.log("... VPP server is starting again, so waiting for a bit.")
144 time.Sleep(30 * time.Second) // Wait a moment for the re-attachment to happen
146 s.log("... Running second echo client test, after disconnect and re-attachment.")
147 o = echoClnContainer.exec(testClientCommand)