blob: f4273c87b14f2a51f0b6471ddab1ab36dd9180a9 [file] [log] [blame]
Filip Tehlar229f5fc2022-08-09 14:44:47 +00001package main
2
3import (
Maros Ondrejicka0db15752022-10-12 22:58:01 +02004 "time"
Filip Tehlar229f5fc2022-08-09 14:44:47 +00005)
6
Maros Ondrejicka11a03e92022-12-01 09:56:37 +01007func (s *VethsSuite) TestVclEchoQuic() {
Maros Ondrejicka87531802022-12-19 20:35:27 +01008 s.skip("quic test skipping..")
Filip Tehlar229f5fc2022-08-09 14:44:47 +00009 s.testVclEcho("quic")
10}
11
Maros Ondrejicka11a03e92022-12-01 09:56:37 +010012func (s *VethsSuite) TestVclEchoUdp() {
Maros Ondrejicka87531802022-12-19 20:35:27 +010013 s.skip("udp echo currently broken in vpp, skipping..")
Filip Tehlar229f5fc2022-08-09 14:44:47 +000014 s.testVclEcho("udp")
15}
16
Maros Ondrejicka11a03e92022-12-01 09:56:37 +010017func (s *VethsSuite) TestVclEchoTcp() {
Filip Tehlar229f5fc2022-08-09 14:44:47 +000018 s.testVclEcho("tcp")
19}
20
Maros Ondrejicka11a03e92022-12-01 09:56:37 +010021func (s *VethsSuite) testVclEcho(proto string) {
Maros Ondrejickadb823ed2022-12-14 16:30:04 +010022 srvVppContainer := s.getContainerByName("server-vpp")
Filip Tehlar229f5fc2022-08-09 14:44:47 +000023
Maros Ondrejickadb823ed2022-12-14 16:30:04 +010024 _, err := srvVppContainer.execAction("Configure2Veths srv")
Maros Ondrejicka0e79abb2022-12-06 19:46:24 +010025 s.assertNil(err)
Filip Tehlar229f5fc2022-08-09 14:44:47 +000026
Maros Ondrejickadb823ed2022-12-14 16:30:04 +010027 clnVppContainer := s.getContainerByName("client-vpp")
28
29 _, err = clnVppContainer.execAction("Configure2Veths cln")
Maros Ondrejicka0e79abb2022-12-06 19:46:24 +010030 s.assertNil(err)
Filip Tehlar229f5fc2022-08-09 14:44:47 +000031
Maros Ondrejickadb823ed2022-12-14 16:30:04 +010032 echoSrvContainer := s.getContainerByName("server-application")
33
Filip Tehlar229f5fc2022-08-09 14:44:47 +000034 // run server app
Filip Tehlarf3ee2b62023-01-09 12:07:09 +010035 _, err = echoSrvContainer.execAction("RunEchoServer " + proto)
Maros Ondrejicka0e79abb2022-12-06 19:46:24 +010036 s.assertNil(err)
Filip Tehlar229f5fc2022-08-09 14:44:47 +000037
Maros Ondrejickadb823ed2022-12-14 16:30:04 +010038 echoClnContainer := s.getContainerByName("client-application")
39
Filip Tehlarf3ee2b62023-01-09 12:07:09 +010040 o, err := echoClnContainer.execAction("RunEchoClient " + proto)
Maros Ondrejicka0e79abb2022-12-06 19:46:24 +010041 s.assertNil(err)
Maros Ondrejicka98a91e82022-12-06 15:38:05 +010042
Maros Ondrejicka87531802022-12-19 20:35:27 +010043 s.log(o)
Filip Tehlar229f5fc2022-08-09 14:44:47 +000044}
Maros Ondrejicka0db15752022-10-12 22:58:01 +020045
Maros Ondrejicka11a03e92022-12-01 09:56:37 +010046func (s *VethsSuite) TestVclRetryAttach() {
Maros Ondrejicka87531802022-12-19 20:35:27 +010047 s.skip()
Maros Ondrejicka0db15752022-10-12 22:58:01 +020048 s.testRetryAttach("tcp")
49}
50
Maros Ondrejicka11a03e92022-12-01 09:56:37 +010051func (s *VethsSuite) testRetryAttach(proto string) {
Maros Ondrejickadb823ed2022-12-14 16:30:04 +010052 srvVppContainer := s.getContainerByName("server-vpp")
Maros Ondrejicka0db15752022-10-12 22:58:01 +020053
Maros Ondrejickadb823ed2022-12-14 16:30:04 +010054 _, err := srvVppContainer.execAction("Configure2Veths srv-with-preset-hw-addr")
Maros Ondrejicka0e79abb2022-12-06 19:46:24 +010055 s.assertNil(err)
Maros Ondrejicka0db15752022-10-12 22:58:01 +020056
Maros Ondrejickadb823ed2022-12-14 16:30:04 +010057 clnVppContainer := s.getContainerByName("client-vpp")
58
59 _, err = clnVppContainer.execAction("Configure2Veths cln")
Maros Ondrejicka0e79abb2022-12-06 19:46:24 +010060 s.assertNil(err)
Maros Ondrejicka0db15752022-10-12 22:58:01 +020061
Maros Ondrejickadb823ed2022-12-14 16:30:04 +010062 echoSrvContainer := s.getContainerByName("server-application")
Filip Tehlarf3ee2b62023-01-09 12:07:09 +010063 _, err = echoSrvContainer.execAction("RunVclEchoServer " + proto)
Maros Ondrejicka0e79abb2022-12-06 19:46:24 +010064 s.assertNil(err)
Maros Ondrejicka0db15752022-10-12 22:58:01 +020065
Maros Ondrejicka87531802022-12-19 20:35:27 +010066 s.log("This whole test case can take around 3 minutes to run. Please be patient.")
67 s.log("... Running first echo client test, before disconnect.")
Maros Ondrejickadb823ed2022-12-14 16:30:04 +010068 echoClnContainer := s.getContainerByName("client-application")
Filip Tehlarf3ee2b62023-01-09 12:07:09 +010069 _, err = echoClnContainer.execAction("RunVclEchoClient " + proto)
Maros Ondrejicka0e79abb2022-12-06 19:46:24 +010070 s.assertNil(err)
Maros Ondrejicka87531802022-12-19 20:35:27 +010071 s.log("... First test ended. Stopping VPP server now.")
Maros Ondrejicka0db15752022-10-12 22:58:01 +020072
73 // Stop server-vpp-instance, start it again and then run vcl-test-client once more
74 stopVppCommand := "/bin/bash -c 'ps -C vpp_main -o pid= | xargs kill -9'"
Maros Ondrejickadb823ed2022-12-14 16:30:04 +010075 _, err = srvVppContainer.exec(stopVppCommand)
Maros Ondrejicka0e79abb2022-12-06 19:46:24 +010076 s.assertNil(err)
Maros Ondrejicka0db15752022-10-12 22:58:01 +020077 time.Sleep(5 * time.Second) // Give parent process time to reap the killed child process
78 stopVppCommand = "/bin/bash -c 'ps -C hs-test -o pid= | xargs kill -9'"
Maros Ondrejickadb823ed2022-12-14 16:30:04 +010079 _, err = srvVppContainer.exec(stopVppCommand)
Maros Ondrejicka0e79abb2022-12-06 19:46:24 +010080 s.assertNil(err)
Maros Ondrejickadb823ed2022-12-14 16:30:04 +010081 _, err = srvVppContainer.execAction("Configure2Veths srv-with-preset-hw-addr")
Maros Ondrejicka0e79abb2022-12-06 19:46:24 +010082 s.assertNil(err)
Maros Ondrejicka0db15752022-10-12 22:58:01 +020083
Maros Ondrejicka87531802022-12-19 20:35:27 +010084 s.log("... VPP server is starting again, so waiting for a bit.")
Maros Ondrejicka0db15752022-10-12 22:58:01 +020085 time.Sleep(30 * time.Second) // Wait a moment for the re-attachment to happen
86
Maros Ondrejicka87531802022-12-19 20:35:27 +010087 s.log("... Running second echo client test, after disconnect and re-attachment.")
Filip Tehlarf3ee2b62023-01-09 12:07:09 +010088 _, err = echoClnContainer.execAction("RunVclEchoClient " + proto)
Maros Ondrejicka0e79abb2022-12-06 19:46:24 +010089 s.assertNil(err)
Maros Ondrejicka87531802022-12-19 20:35:27 +010090 s.log("Done.")
Maros Ondrejicka0db15752022-10-12 22:58:01 +020091}
Maros Ondrejicka5b746312022-11-16 12:51:11 +010092
93func (s *VethsSuite) TestTcpWithLoss() {
Maros Ondrejickadb823ed2022-12-14 16:30:04 +010094 serverContainer := s.getContainerByName("server-vpp")
Maros Ondrejicka5b746312022-11-16 12:51:11 +010095
96 serverVpp := NewVppInstance(serverContainer)
97 s.assertNotNil(serverVpp)
Maros Ondrejicka5b746312022-11-16 12:51:11 +010098 serverVpp.set2VethsServer()
Maros Ondrejickadb823ed2022-12-14 16:30:04 +010099 err := serverVpp.start()
Maros Ondrejicka5b746312022-11-16 12:51:11 +0100100 s.assertNil(err, "starting VPP failed")
101
102 _, err = serverVpp.vppctl("test echo server uri tcp://10.10.10.1/20022")
103 s.assertNil(err, "starting echo server failed")
104
Maros Ondrejickadb823ed2022-12-14 16:30:04 +0100105 clientContainer := s.getContainerByName("client-vpp")
Maros Ondrejicka5b746312022-11-16 12:51:11 +0100106
107 clientVpp := NewVppInstance(clientContainer)
108 s.assertNotNil(clientVpp)
Maros Ondrejicka5b746312022-11-16 12:51:11 +0100109 clientVpp.set2VethsClient()
110 err = clientVpp.start()
111 s.assertNil(err, "starting VPP failed")
112
113 // Ensure that VPP doesn't abort itself with NSIM enabled
114 // Warning: Removing this ping will make the test fail!
115 _, err = serverVpp.vppctl("ping 10.10.10.2")
116 s.assertNil(err, "ping failed")
117
118 // Add loss of packets with Network Delay Simulator
119 _, err = clientVpp.vppctl("set nsim poll-main-thread delay 0.01 ms bandwidth 40 gbit packet-size 1400 packets-per-drop 1000")
120 s.assertNil(err, "configuring NSIM failed")
121 _, err = clientVpp.vppctl("nsim output-feature enable-disable host-vppcln")
122 s.assertNil(err, "enabling NSIM failed")
123
124 // Do echo test from client-vpp container
125 output, err := clientVpp.vppctl("test echo client uri tcp://10.10.10.1/20022 mbytes 50")
126 s.assertNil(err)
127 s.assertEqual(true, len(output) != 0)
128 s.assertNotContains(output, "failed: timeout")
Maros Ondrejicka87531802022-12-19 20:35:27 +0100129 s.log(output)
Maros Ondrejicka5b746312022-11-16 12:51:11 +0100130}