2022-08-09 14:44:47 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2023-01-26 10:07:29 +01:00
|
|
|
"fmt"
|
2022-10-12 22:58:01 +02:00
|
|
|
"time"
|
2022-08-09 14:44:47 +00:00
|
|
|
)
|
|
|
|
|
2022-12-01 09:56:37 +01:00
|
|
|
func (s *VethsSuite) TestVclEchoQuic() {
|
2022-12-19 20:35:27 +01:00
|
|
|
s.skip("quic test skipping..")
|
2022-08-09 14:44:47 +00:00
|
|
|
s.testVclEcho("quic")
|
|
|
|
}
|
|
|
|
|
2022-12-01 09:56:37 +01:00
|
|
|
func (s *VethsSuite) TestVclEchoUdp() {
|
2022-12-19 20:35:27 +01:00
|
|
|
s.skip("udp echo currently broken in vpp, skipping..")
|
2022-08-09 14:44:47 +00:00
|
|
|
s.testVclEcho("udp")
|
|
|
|
}
|
|
|
|
|
2022-12-01 09:56:37 +01:00
|
|
|
func (s *VethsSuite) TestVclEchoTcp() {
|
2022-08-09 14:44:47 +00:00
|
|
|
s.testVclEcho("tcp")
|
|
|
|
}
|
|
|
|
|
2022-12-01 09:56:37 +01:00
|
|
|
func (s *VethsSuite) testVclEcho(proto string) {
|
2023-02-28 16:55:01 +01:00
|
|
|
serverVethAddress := s.netInterfaces["vppsrv"].ip4AddressString()
|
2023-01-26 10:07:29 +01:00
|
|
|
uri := proto + "://" + serverVethAddress + "/12344"
|
2022-08-09 14:44:47 +00:00
|
|
|
|
2022-12-14 16:30:04 +01:00
|
|
|
echoSrvContainer := s.getContainerByName("server-application")
|
2023-01-26 10:07:29 +01:00
|
|
|
serverCommand := "vpp_echo server TX=RX" +
|
2023-02-28 16:55:01 +01:00
|
|
|
" socket-name " + echoSrvContainer.getContainerWorkDir() + "/var/run/app_ns_sockets/1" +
|
2023-01-26 10:07:29 +01:00
|
|
|
" use-app-socket-api" +
|
|
|
|
" uri " + uri
|
|
|
|
s.log(serverCommand)
|
2023-02-02 08:58:04 +01:00
|
|
|
echoSrvContainer.execServer(serverCommand)
|
2022-08-09 14:44:47 +00:00
|
|
|
|
2022-12-14 16:30:04 +01:00
|
|
|
echoClnContainer := s.getContainerByName("client-application")
|
|
|
|
|
2023-01-26 10:07:29 +01:00
|
|
|
clientCommand := "vpp_echo client" +
|
2023-02-28 16:55:01 +01:00
|
|
|
" socket-name " + echoClnContainer.getContainerWorkDir() + "/var/run/app_ns_sockets/2" +
|
2023-01-26 10:07:29 +01:00
|
|
|
" use-app-socket-api uri " + uri
|
|
|
|
s.log(clientCommand)
|
2023-02-02 08:58:04 +01:00
|
|
|
o := echoClnContainer.exec(clientCommand)
|
2022-12-06 15:38:05 +01:00
|
|
|
|
2022-12-19 20:35:27 +01:00
|
|
|
s.log(o)
|
2022-08-09 14:44:47 +00:00
|
|
|
}
|
2022-10-12 22:58:01 +02:00
|
|
|
|
2022-12-01 09:56:37 +01:00
|
|
|
func (s *VethsSuite) TestVclRetryAttach() {
|
2023-01-26 10:07:29 +01:00
|
|
|
s.skip("this test takes too long, for now it's being skipped")
|
2022-10-12 22:58:01 +02:00
|
|
|
s.testRetryAttach("tcp")
|
|
|
|
}
|
|
|
|
|
2022-12-01 09:56:37 +01:00
|
|
|
func (s *VethsSuite) testRetryAttach(proto string) {
|
2023-02-02 08:58:04 +01:00
|
|
|
srvVppContainer := s.getTransientContainerByName("server-vpp")
|
2022-10-12 22:58:01 +02:00
|
|
|
|
2023-01-26 10:07:29 +01:00
|
|
|
echoSrvContainer := s.getContainerByName("server-application")
|
2022-12-06 19:46:24 +01:00
|
|
|
|
2023-02-28 16:55:01 +01:00
|
|
|
serverVclConfContent := fmt.Sprintf(vclTemplate, echoSrvContainer.getContainerWorkDir(), "1")
|
2023-01-26 10:07:29 +01:00
|
|
|
echoSrvContainer.createFile("/vcl.conf", serverVclConfContent)
|
2022-12-06 19:46:24 +01:00
|
|
|
|
2023-01-26 10:07:29 +01:00
|
|
|
echoSrvContainer.addEnvVar("VCL_CONFIG", "/vcl.conf")
|
2023-02-02 08:58:04 +01:00
|
|
|
echoSrvContainer.execServer("vcl_test_server -p " + proto + " 12346")
|
2022-10-12 22:58:01 +02:00
|
|
|
|
2022-12-19 20:35:27 +01:00
|
|
|
s.log("This whole test case can take around 3 minutes to run. Please be patient.")
|
|
|
|
s.log("... Running first echo client test, before disconnect.")
|
2023-01-26 10:07:29 +01:00
|
|
|
|
2023-02-02 08:58:04 +01:00
|
|
|
serverVeth := s.netInterfaces[serverInterfaceName]
|
2023-02-28 16:55:01 +01:00
|
|
|
serverVethAddress := serverVeth.ip4AddressString()
|
2023-01-26 10:07:29 +01:00
|
|
|
|
2023-02-02 08:58:04 +01:00
|
|
|
echoClnContainer := s.getTransientContainerByName("client-application")
|
2023-02-28 16:55:01 +01:00
|
|
|
clientVclConfContent := fmt.Sprintf(vclTemplate, echoClnContainer.getContainerWorkDir(), "2")
|
2023-01-26 10:07:29 +01:00
|
|
|
echoClnContainer.createFile("/vcl.conf", clientVclConfContent)
|
|
|
|
|
|
|
|
testClientCommand := "vcl_test_client -U -p " + proto + " " + serverVethAddress + " 12346"
|
|
|
|
echoClnContainer.addEnvVar("VCL_CONFIG", "/vcl.conf")
|
2023-02-02 08:58:04 +01:00
|
|
|
o := echoClnContainer.exec(testClientCommand)
|
2023-01-26 10:07:29 +01:00
|
|
|
s.log(o)
|
2022-12-19 20:35:27 +01:00
|
|
|
s.log("... First test ended. Stopping VPP server now.")
|
2022-10-12 22:58:01 +02:00
|
|
|
|
|
|
|
// Stop server-vpp-instance, start it again and then run vcl-test-client once more
|
2023-01-26 10:07:29 +01:00
|
|
|
srvVppContainer.vppInstance.disconnect()
|
2022-10-12 22:58:01 +02:00
|
|
|
stopVppCommand := "/bin/bash -c 'ps -C vpp_main -o pid= | xargs kill -9'"
|
2023-02-02 08:58:04 +01:00
|
|
|
srvVppContainer.exec(stopVppCommand)
|
2023-01-26 10:07:29 +01:00
|
|
|
|
|
|
|
s.setupServerVpp()
|
2022-10-12 22:58:01 +02:00
|
|
|
|
2022-12-19 20:35:27 +01:00
|
|
|
s.log("... VPP server is starting again, so waiting for a bit.")
|
2022-10-12 22:58:01 +02:00
|
|
|
time.Sleep(30 * time.Second) // Wait a moment for the re-attachment to happen
|
|
|
|
|
2022-12-19 20:35:27 +01:00
|
|
|
s.log("... Running second echo client test, after disconnect and re-attachment.")
|
2023-02-02 08:58:04 +01:00
|
|
|
o = echoClnContainer.exec(testClientCommand)
|
2023-01-26 10:07:29 +01:00
|
|
|
s.log(o)
|
2022-12-19 20:35:27 +01:00
|
|
|
s.log("Done.")
|
2022-10-12 22:58:01 +02:00
|
|
|
}
|
2022-11-16 12:51:11 +01:00
|
|
|
|
|
|
|
func (s *VethsSuite) TestTcpWithLoss() {
|
2023-02-02 08:58:04 +01:00
|
|
|
serverVpp := s.getContainerByName("server-vpp").vppInstance
|
2022-11-16 12:51:11 +01:00
|
|
|
|
2023-02-02 08:58:04 +01:00
|
|
|
serverVeth := s.netInterfaces[serverInterfaceName]
|
|
|
|
serverVpp.vppctl("test echo server uri tcp://%s/20022",
|
2023-02-28 16:55:01 +01:00
|
|
|
serverVeth.ip4AddressString())
|
2022-11-16 12:51:11 +01:00
|
|
|
|
2023-02-02 08:58:04 +01:00
|
|
|
clientVpp := s.getContainerByName("client-vpp").vppInstance
|
2022-11-16 12:51:11 +01:00
|
|
|
|
|
|
|
// Ensure that VPP doesn't abort itself with NSIM enabled
|
|
|
|
// Warning: Removing this ping will make the test fail!
|
2023-02-28 16:55:01 +01:00
|
|
|
clientVpp.vppctl("ping %s", serverVeth.ip4AddressString())
|
2022-11-16 12:51:11 +01:00
|
|
|
|
|
|
|
// Add loss of packets with Network Delay Simulator
|
2023-02-02 08:58:04 +01:00
|
|
|
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")
|
2022-11-16 12:51:11 +01:00
|
|
|
|
|
|
|
// Do echo test from client-vpp container
|
2023-02-02 08:58:04 +01:00
|
|
|
output := clientVpp.vppctl("test echo client uri tcp://%s/20022 mbytes 50",
|
2023-02-28 16:55:01 +01:00
|
|
|
serverVeth.ip4AddressString())
|
2022-11-16 12:51:11 +01:00
|
|
|
s.assertEqual(true, len(output) != 0)
|
|
|
|
s.assertNotContains(output, "failed: timeout")
|
2022-12-19 20:35:27 +01:00
|
|
|
s.log(output)
|
2022-11-16 12:51:11 +01:00
|
|
|
}
|