X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=extras%2Fhs-test%2Fvcl_test.go;h=a949565f299296843ef7439422379fe3293c9d9f;hb=56e17cf7a23831b353bc1836def47dad7f869dad;hp=fe55af1866abc43d46aa3f065aff4817ccf02f4f;hpb=e7625d08566f6127acb351376797b4fdc75e3c6a;p=vpp.git diff --git a/extras/hs-test/vcl_test.go b/extras/hs-test/vcl_test.go index fe55af1866a..a949565f299 100644 --- a/extras/hs-test/vcl_test.go +++ b/extras/hs-test/vcl_test.go @@ -5,43 +5,106 @@ import ( "time" ) -func (s *VethsSuite) TestVclEchoQuic() { - s.skip("quic test skipping..") - s.testVclEcho("quic") +func getVclConfig(c *Container, ns_id_optional ...string) string { + var s Stanza + ns_id := "default" + if len(ns_id_optional) > 0 { + ns_id = ns_id_optional[0] + } + s.newStanza("vcl"). + append(fmt.Sprintf("app-socket-api %[1]s/var/run/app_ns_sockets/%[2]s", c.getContainerWorkDir(), ns_id)). + append("app-scope-global"). + append("app-scope-local"). + append("use-mq-eventfd") + if len(ns_id_optional) > 0 { + s.append(fmt.Sprintf("namespace-id %[1]s", ns_id)). + append(fmt.Sprintf("namespace-secret %[1]s", ns_id)) + } + return s.close().toString() } -func (s *VethsSuite) TestVclEchoUdp() { - s.skip("udp echo currently broken in vpp, skipping..") - s.testVclEcho("udp") +func (s *VethsSuite) TestXEchoVclClientUdp() { + s.testXEchoVclClient("udp") } -func (s *VethsSuite) TestVclEchoTcp() { - s.testVclEcho("tcp") +func (s *VethsSuite) TestXEchoVclClientTcp() { + s.testXEchoVclClient("tcp") +} + +func (s *VethsSuite) testXEchoVclClient(proto string) { + port := "12345" + serverVpp := s.getContainerByName("server-vpp").vppInstance + + serverVeth := s.netInterfaces[serverInterfaceName] + serverVpp.vppctl("test echo server uri %s://%s/%s fifo-size 64k", proto, serverVeth.ip4AddressString(), port) + + echoClnContainer := s.getTransientContainerByName("client-app") + echoClnContainer.createFile("/vcl.conf", getVclConfig(echoClnContainer)) + + testClientCommand := "vcl_test_client -N 100 -p " + proto + " " + serverVeth.ip4AddressString() + " " + port + s.log(testClientCommand) + echoClnContainer.addEnvVar("VCL_CONFIG", "/vcl.conf") + o := echoClnContainer.exec(testClientCommand) + s.log(o) + s.assertContains(o, "CLIENT RESULTS") +} + +func (s *VethsSuite) TestXEchoVclServerUdp() { + s.testXEchoVclServer("udp") +} + +func (s *VethsSuite) TestXEchoVclServerTcp() { + s.testXEchoVclServer("tcp") +} + +func (s *VethsSuite) testXEchoVclServer(proto string) { + port := "12345" + srvVppCont := s.getContainerByName("server-vpp") + srvAppCont := s.getContainerByName("server-app") + + srvAppCont.createFile("/vcl.conf", getVclConfig(srvVppCont)) + srvAppCont.addEnvVar("VCL_CONFIG", "/vcl.conf") + vclSrvCmd := fmt.Sprintf("vcl_test_server -p %s %s", proto, port) + srvAppCont.execServer(vclSrvCmd) + + serverVeth := s.netInterfaces[serverInterfaceName] + serverVethAddress := serverVeth.ip4AddressString() + + clientVpp := s.getContainerByName("client-vpp").vppInstance + o := clientVpp.vppctl("test echo client uri %s://%s/%s fifo-size 64k verbose mbytes 2", proto, serverVethAddress, port) + s.log(o) + s.assertContains(o, "Test finished at") } func (s *VethsSuite) testVclEcho(proto string) { - serverVethAddress := s.netInterfaces["vppsrv"].ip4AddressString() - uri := proto + "://" + serverVethAddress + "/12344" + port := "12345" + srvVppCont := s.getContainerByName("server-vpp") + srvAppCont := s.getContainerByName("server-app") - echoSrvContainer := s.getContainerByName("server-application") - serverCommand := "vpp_echo server TX=RX" + - " socket-name " + echoSrvContainer.getContainerWorkDir() + "/var/run/app_ns_sockets/1" + - " use-app-socket-api" + - " uri " + uri - s.log(serverCommand) - echoSrvContainer.execServer(serverCommand) + srvAppCont.createFile("/vcl.conf", getVclConfig(srvVppCont)) + srvAppCont.addEnvVar("VCL_CONFIG", "/vcl.conf") + srvAppCont.execServer("vcl_test_server " + port) - echoClnContainer := s.getContainerByName("client-application") + serverVeth := s.netInterfaces[serverInterfaceName] + serverVethAddress := serverVeth.ip4AddressString() - clientCommand := "vpp_echo client" + - " socket-name " + echoClnContainer.getContainerWorkDir() + "/var/run/app_ns_sockets/2" + - " use-app-socket-api uri " + uri - s.log(clientCommand) - o := echoClnContainer.exec(clientCommand) + echoClnContainer := s.getTransientContainerByName("client-app") + echoClnContainer.createFile("/vcl.conf", getVclConfig(echoClnContainer)) + testClientCommand := "vcl_test_client -p " + proto + " " + serverVethAddress + " " + port + echoClnContainer.addEnvVar("VCL_CONFIG", "/vcl.conf") + o := echoClnContainer.exec(testClientCommand) s.log(o) } +func (s *VethsSuite) TestVclEchoTcp() { + s.testVclEcho("tcp") +} + +func (s *VethsSuite) TestVclEchoUdp() { + s.testVclEcho("udp") +} + func (s *VethsSuite) TestVclRetryAttach() { s.skip("this test takes too long, for now it's being skipped") s.testRetryAttach("tcp") @@ -50,10 +113,9 @@ func (s *VethsSuite) TestVclRetryAttach() { func (s *VethsSuite) testRetryAttach(proto string) { srvVppContainer := s.getTransientContainerByName("server-vpp") - echoSrvContainer := s.getContainerByName("server-application") + echoSrvContainer := s.getContainerByName("server-app") - serverVclConfContent := fmt.Sprintf(vclTemplate, echoSrvContainer.getContainerWorkDir(), "1") - echoSrvContainer.createFile("/vcl.conf", serverVclConfContent) + echoSrvContainer.createFile("/vcl.conf", getVclConfig(echoSrvContainer)) echoSrvContainer.addEnvVar("VCL_CONFIG", "/vcl.conf") echoSrvContainer.execServer("vcl_test_server -p " + proto + " 12346") @@ -64,9 +126,8 @@ func (s *VethsSuite) testRetryAttach(proto string) { serverVeth := s.netInterfaces[serverInterfaceName] serverVethAddress := serverVeth.ip4AddressString() - echoClnContainer := s.getTransientContainerByName("client-application") - clientVclConfContent := fmt.Sprintf(vclTemplate, echoClnContainer.getContainerWorkDir(), "2") - echoClnContainer.createFile("/vcl.conf", clientVclConfContent) + echoClnContainer := s.getTransientContainerByName("client-app") + echoClnContainer.createFile("/vcl.conf", getVclConfig(echoClnContainer)) testClientCommand := "vcl_test_client -U -p " + proto + " " + serverVethAddress + " 12346" echoClnContainer.addEnvVar("VCL_CONFIG", "/vcl.conf") @@ -89,30 +150,3 @@ func (s *VethsSuite) testRetryAttach(proto string) { s.log(o) s.log("Done.") } - -func (s *VethsSuite) TestTcpWithLoss() { - serverVpp := s.getContainerByName("server-vpp").vppInstance - - serverVeth := s.netInterfaces[serverInterfaceName] - serverVpp.vppctl("test echo server uri tcp://%s/20022", - serverVeth.ip4AddressString()) - - clientVpp := s.getContainerByName("client-vpp").vppInstance - - // Ensure that VPP doesn't abort itself with NSIM enabled - // Warning: Removing this ping will make the test fail! - clientVpp.vppctl("ping %s", serverVeth.ip4AddressString()) - - // Add loss of packets with Network Delay Simulator - clientVpp.vppctl("set nsim poll-main-thread delay 0.01 ms bandwidth 40 gbit" + - " packet-size 1400 packets-per-drop 1000") - - clientVpp.vppctl("nsim output-feature enable-disable host-vppcln") - - // Do echo test from client-vpp container - output := clientVpp.vppctl("test echo client uri tcp://%s/20022 mbytes 50", - serverVeth.ip4AddressString()) - s.assertEqual(true, len(output) != 0) - s.assertNotContains(output, "failed: timeout") - s.log(output) -}