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) testVclEcho(proto string) {
20 srvVppCont := s.getContainerByName("server-vpp")
21 srvAppCont := s.getContainerByName("server-app")
23 serverVclConfContent := fmt.Sprintf(vclTemplate, srvVppCont.getContainerWorkDir(), "1")
24 srvAppCont.createFile("/vcl.conf", serverVclConfContent)
25 srvAppCont.addEnvVar("VCL_CONFIG", "/vcl.conf")
26 srvAppCont.execServer("vcl_test_server " + port)
28 serverVeth := s.netInterfaces[serverInterfaceName]
29 serverVethAddress := serverVeth.ip4AddressString()
31 echoClnContainer := s.getTransientContainerByName("client-app")
32 clientVclConfContent := fmt.Sprintf(vclTemplate, echoClnContainer.getContainerWorkDir(), "2")
33 echoClnContainer.createFile("/vcl.conf", clientVclConfContent)
35 testClientCommand := "vcl_test_client -p " + proto + " " + serverVethAddress + " " + port
36 echoClnContainer.addEnvVar("VCL_CONFIG", "/vcl.conf")
37 o := echoClnContainer.exec(testClientCommand)
41 func (s *VethsSuite) TestVclEchoTcp() {
45 func (s *VethsSuite) TestVclEchoUdp() {
49 func (s *VethsSuite) TestVclRetryAttach() {
50 s.skip("this test takes too long, for now it's being skipped")
51 s.testRetryAttach("tcp")
54 func (s *VethsSuite) testRetryAttach(proto string) {
55 srvVppContainer := s.getTransientContainerByName("server-vpp")
57 echoSrvContainer := s.getContainerByName("server-app")
59 serverVclConfContent := fmt.Sprintf(vclTemplate, echoSrvContainer.getContainerWorkDir(), "1")
60 echoSrvContainer.createFile("/vcl.conf", serverVclConfContent)
62 echoSrvContainer.addEnvVar("VCL_CONFIG", "/vcl.conf")
63 echoSrvContainer.execServer("vcl_test_server -p " + proto + " 12346")
65 s.log("This whole test case can take around 3 minutes to run. Please be patient.")
66 s.log("... Running first echo client test, before disconnect.")
68 serverVeth := s.netInterfaces[serverInterfaceName]
69 serverVethAddress := serverVeth.ip4AddressString()
71 echoClnContainer := s.getTransientContainerByName("client-app")
72 clientVclConfContent := fmt.Sprintf(vclTemplate, echoClnContainer.getContainerWorkDir(), "2")
73 echoClnContainer.createFile("/vcl.conf", clientVclConfContent)
75 testClientCommand := "vcl_test_client -U -p " + proto + " " + serverVethAddress + " 12346"
76 echoClnContainer.addEnvVar("VCL_CONFIG", "/vcl.conf")
77 o := echoClnContainer.exec(testClientCommand)
79 s.log("... First test ended. Stopping VPP server now.")
81 // Stop server-vpp-instance, start it again and then run vcl-test-client once more
82 srvVppContainer.vppInstance.disconnect()
83 stopVppCommand := "/bin/bash -c 'ps -C vpp_main -o pid= | xargs kill -9'"
84 srvVppContainer.exec(stopVppCommand)
88 s.log("... VPP server is starting again, so waiting for a bit.")
89 time.Sleep(30 * time.Second) // Wait a moment for the re-attachment to happen
91 s.log("... Running second echo client test, after disconnect and re-attachment.")
92 o = echoClnContainer.exec(testClientCommand)
97 func (s *VethsSuite) TestTcpWithLoss() {
98 serverVpp := s.getContainerByName("server-vpp").vppInstance
100 serverVeth := s.netInterfaces[serverInterfaceName]
101 serverVpp.vppctl("test echo server uri tcp://%s/20022",
102 serverVeth.ip4AddressString())
104 clientVpp := s.getContainerByName("client-vpp").vppInstance
106 // Ensure that VPP doesn't abort itself with NSIM enabled
107 // Warning: Removing this ping will make the test fail!
108 clientVpp.vppctl("ping %s", serverVeth.ip4AddressString())
110 // Add loss of packets with Network Delay Simulator
111 clientVpp.vppctl("set nsim poll-main-thread delay 0.01 ms bandwidth 40 gbit" +
112 " packet-size 1400 packets-per-drop 1000")
114 clientVpp.vppctl("nsim output-feature enable-disable host-vppcln")
116 // Do echo test from client-vpp container
117 output := clientVpp.vppctl("test echo client uri tcp://%s/20022 mbytes 50",
118 serverVeth.ip4AddressString())
119 s.assertEqual(true, len(output) != 0)
120 s.assertNotContains(output, "failed: timeout")