Filip Tehlar | 229f5fc | 2022-08-09 14:44:47 +0000 | [diff] [blame] | 1 | package main |
| 2 | |
| 3 | import ( |
Maros Ondrejicka | 0db1575 | 2022-10-12 22:58:01 +0200 | [diff] [blame] | 4 | "time" |
Filip Tehlar | 229f5fc | 2022-08-09 14:44:47 +0000 | [diff] [blame] | 5 | ) |
| 6 | |
Maros Ondrejicka | 11a03e9 | 2022-12-01 09:56:37 +0100 | [diff] [blame] | 7 | func (s *VethsSuite) TestVclEchoQuic() { |
Maros Ondrejicka | 8753180 | 2022-12-19 20:35:27 +0100 | [diff] [blame] | 8 | s.skip("quic test skipping..") |
Filip Tehlar | 229f5fc | 2022-08-09 14:44:47 +0000 | [diff] [blame] | 9 | s.testVclEcho("quic") |
| 10 | } |
| 11 | |
Maros Ondrejicka | 11a03e9 | 2022-12-01 09:56:37 +0100 | [diff] [blame] | 12 | func (s *VethsSuite) TestVclEchoUdp() { |
Maros Ondrejicka | 8753180 | 2022-12-19 20:35:27 +0100 | [diff] [blame] | 13 | s.skip("udp echo currently broken in vpp, skipping..") |
Filip Tehlar | 229f5fc | 2022-08-09 14:44:47 +0000 | [diff] [blame] | 14 | s.testVclEcho("udp") |
| 15 | } |
| 16 | |
Maros Ondrejicka | 11a03e9 | 2022-12-01 09:56:37 +0100 | [diff] [blame] | 17 | func (s *VethsSuite) TestVclEchoTcp() { |
Filip Tehlar | 229f5fc | 2022-08-09 14:44:47 +0000 | [diff] [blame] | 18 | s.testVclEcho("tcp") |
| 19 | } |
| 20 | |
Maros Ondrejicka | 11a03e9 | 2022-12-01 09:56:37 +0100 | [diff] [blame] | 21 | func (s *VethsSuite) testVclEcho(proto string) { |
Maros Ondrejicka | db823ed | 2022-12-14 16:30:04 +0100 | [diff] [blame] | 22 | srvVppContainer := s.getContainerByName("server-vpp") |
Filip Tehlar | 229f5fc | 2022-08-09 14:44:47 +0000 | [diff] [blame] | 23 | |
Maros Ondrejicka | db823ed | 2022-12-14 16:30:04 +0100 | [diff] [blame] | 24 | _, err := srvVppContainer.execAction("Configure2Veths srv") |
Maros Ondrejicka | 0e79abb | 2022-12-06 19:46:24 +0100 | [diff] [blame] | 25 | s.assertNil(err) |
Filip Tehlar | 229f5fc | 2022-08-09 14:44:47 +0000 | [diff] [blame] | 26 | |
Maros Ondrejicka | db823ed | 2022-12-14 16:30:04 +0100 | [diff] [blame] | 27 | clnVppContainer := s.getContainerByName("client-vpp") |
| 28 | |
| 29 | _, err = clnVppContainer.execAction("Configure2Veths cln") |
Maros Ondrejicka | 0e79abb | 2022-12-06 19:46:24 +0100 | [diff] [blame] | 30 | s.assertNil(err) |
Filip Tehlar | 229f5fc | 2022-08-09 14:44:47 +0000 | [diff] [blame] | 31 | |
Maros Ondrejicka | db823ed | 2022-12-14 16:30:04 +0100 | [diff] [blame] | 32 | echoSrvContainer := s.getContainerByName("server-application") |
| 33 | |
Filip Tehlar | 229f5fc | 2022-08-09 14:44:47 +0000 | [diff] [blame] | 34 | // run server app |
Filip Tehlar | f3ee2b6 | 2023-01-09 12:07:09 +0100 | [diff] [blame] | 35 | _, err = echoSrvContainer.execAction("RunEchoServer " + proto) |
Maros Ondrejicka | 0e79abb | 2022-12-06 19:46:24 +0100 | [diff] [blame] | 36 | s.assertNil(err) |
Filip Tehlar | 229f5fc | 2022-08-09 14:44:47 +0000 | [diff] [blame] | 37 | |
Maros Ondrejicka | db823ed | 2022-12-14 16:30:04 +0100 | [diff] [blame] | 38 | echoClnContainer := s.getContainerByName("client-application") |
| 39 | |
Filip Tehlar | f3ee2b6 | 2023-01-09 12:07:09 +0100 | [diff] [blame] | 40 | o, err := echoClnContainer.execAction("RunEchoClient " + proto) |
Maros Ondrejicka | 0e79abb | 2022-12-06 19:46:24 +0100 | [diff] [blame] | 41 | s.assertNil(err) |
Maros Ondrejicka | 98a91e8 | 2022-12-06 15:38:05 +0100 | [diff] [blame] | 42 | |
Maros Ondrejicka | 8753180 | 2022-12-19 20:35:27 +0100 | [diff] [blame] | 43 | s.log(o) |
Filip Tehlar | 229f5fc | 2022-08-09 14:44:47 +0000 | [diff] [blame] | 44 | } |
Maros Ondrejicka | 0db1575 | 2022-10-12 22:58:01 +0200 | [diff] [blame] | 45 | |
Maros Ondrejicka | 11a03e9 | 2022-12-01 09:56:37 +0100 | [diff] [blame] | 46 | func (s *VethsSuite) TestVclRetryAttach() { |
Maros Ondrejicka | 8753180 | 2022-12-19 20:35:27 +0100 | [diff] [blame] | 47 | s.skip() |
Maros Ondrejicka | 0db1575 | 2022-10-12 22:58:01 +0200 | [diff] [blame] | 48 | s.testRetryAttach("tcp") |
| 49 | } |
| 50 | |
Maros Ondrejicka | 11a03e9 | 2022-12-01 09:56:37 +0100 | [diff] [blame] | 51 | func (s *VethsSuite) testRetryAttach(proto string) { |
Maros Ondrejicka | db823ed | 2022-12-14 16:30:04 +0100 | [diff] [blame] | 52 | srvVppContainer := s.getContainerByName("server-vpp") |
Maros Ondrejicka | 0db1575 | 2022-10-12 22:58:01 +0200 | [diff] [blame] | 53 | |
Maros Ondrejicka | db823ed | 2022-12-14 16:30:04 +0100 | [diff] [blame] | 54 | _, err := srvVppContainer.execAction("Configure2Veths srv-with-preset-hw-addr") |
Maros Ondrejicka | 0e79abb | 2022-12-06 19:46:24 +0100 | [diff] [blame] | 55 | s.assertNil(err) |
Maros Ondrejicka | 0db1575 | 2022-10-12 22:58:01 +0200 | [diff] [blame] | 56 | |
Maros Ondrejicka | db823ed | 2022-12-14 16:30:04 +0100 | [diff] [blame] | 57 | clnVppContainer := s.getContainerByName("client-vpp") |
| 58 | |
| 59 | _, err = clnVppContainer.execAction("Configure2Veths cln") |
Maros Ondrejicka | 0e79abb | 2022-12-06 19:46:24 +0100 | [diff] [blame] | 60 | s.assertNil(err) |
Maros Ondrejicka | 0db1575 | 2022-10-12 22:58:01 +0200 | [diff] [blame] | 61 | |
Maros Ondrejicka | db823ed | 2022-12-14 16:30:04 +0100 | [diff] [blame] | 62 | echoSrvContainer := s.getContainerByName("server-application") |
Filip Tehlar | f3ee2b6 | 2023-01-09 12:07:09 +0100 | [diff] [blame] | 63 | _, err = echoSrvContainer.execAction("RunVclEchoServer " + proto) |
Maros Ondrejicka | 0e79abb | 2022-12-06 19:46:24 +0100 | [diff] [blame] | 64 | s.assertNil(err) |
Maros Ondrejicka | 0db1575 | 2022-10-12 22:58:01 +0200 | [diff] [blame] | 65 | |
Maros Ondrejicka | 8753180 | 2022-12-19 20:35:27 +0100 | [diff] [blame] | 66 | 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 Ondrejicka | db823ed | 2022-12-14 16:30:04 +0100 | [diff] [blame] | 68 | echoClnContainer := s.getContainerByName("client-application") |
Filip Tehlar | f3ee2b6 | 2023-01-09 12:07:09 +0100 | [diff] [blame] | 69 | _, err = echoClnContainer.execAction("RunVclEchoClient " + proto) |
Maros Ondrejicka | 0e79abb | 2022-12-06 19:46:24 +0100 | [diff] [blame] | 70 | s.assertNil(err) |
Maros Ondrejicka | 8753180 | 2022-12-19 20:35:27 +0100 | [diff] [blame] | 71 | s.log("... First test ended. Stopping VPP server now.") |
Maros Ondrejicka | 0db1575 | 2022-10-12 22:58:01 +0200 | [diff] [blame] | 72 | |
| 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 Ondrejicka | db823ed | 2022-12-14 16:30:04 +0100 | [diff] [blame] | 75 | _, err = srvVppContainer.exec(stopVppCommand) |
Maros Ondrejicka | 0e79abb | 2022-12-06 19:46:24 +0100 | [diff] [blame] | 76 | s.assertNil(err) |
Maros Ondrejicka | 0db1575 | 2022-10-12 22:58:01 +0200 | [diff] [blame] | 77 | 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 Ondrejicka | db823ed | 2022-12-14 16:30:04 +0100 | [diff] [blame] | 79 | _, err = srvVppContainer.exec(stopVppCommand) |
Maros Ondrejicka | 0e79abb | 2022-12-06 19:46:24 +0100 | [diff] [blame] | 80 | s.assertNil(err) |
Maros Ondrejicka | db823ed | 2022-12-14 16:30:04 +0100 | [diff] [blame] | 81 | _, err = srvVppContainer.execAction("Configure2Veths srv-with-preset-hw-addr") |
Maros Ondrejicka | 0e79abb | 2022-12-06 19:46:24 +0100 | [diff] [blame] | 82 | s.assertNil(err) |
Maros Ondrejicka | 0db1575 | 2022-10-12 22:58:01 +0200 | [diff] [blame] | 83 | |
Maros Ondrejicka | 8753180 | 2022-12-19 20:35:27 +0100 | [diff] [blame] | 84 | s.log("... VPP server is starting again, so waiting for a bit.") |
Maros Ondrejicka | 0db1575 | 2022-10-12 22:58:01 +0200 | [diff] [blame] | 85 | time.Sleep(30 * time.Second) // Wait a moment for the re-attachment to happen |
| 86 | |
Maros Ondrejicka | 8753180 | 2022-12-19 20:35:27 +0100 | [diff] [blame] | 87 | s.log("... Running second echo client test, after disconnect and re-attachment.") |
Filip Tehlar | f3ee2b6 | 2023-01-09 12:07:09 +0100 | [diff] [blame] | 88 | _, err = echoClnContainer.execAction("RunVclEchoClient " + proto) |
Maros Ondrejicka | 0e79abb | 2022-12-06 19:46:24 +0100 | [diff] [blame] | 89 | s.assertNil(err) |
Maros Ondrejicka | 8753180 | 2022-12-19 20:35:27 +0100 | [diff] [blame] | 90 | s.log("Done.") |
Maros Ondrejicka | 0db1575 | 2022-10-12 22:58:01 +0200 | [diff] [blame] | 91 | } |
Maros Ondrejicka | 5b74631 | 2022-11-16 12:51:11 +0100 | [diff] [blame] | 92 | |
| 93 | func (s *VethsSuite) TestTcpWithLoss() { |
Maros Ondrejicka | db823ed | 2022-12-14 16:30:04 +0100 | [diff] [blame] | 94 | serverContainer := s.getContainerByName("server-vpp") |
Maros Ondrejicka | 5b74631 | 2022-11-16 12:51:11 +0100 | [diff] [blame] | 95 | |
| 96 | serverVpp := NewVppInstance(serverContainer) |
| 97 | s.assertNotNil(serverVpp) |
Maros Ondrejicka | 5b74631 | 2022-11-16 12:51:11 +0100 | [diff] [blame] | 98 | serverVpp.set2VethsServer() |
Maros Ondrejicka | db823ed | 2022-12-14 16:30:04 +0100 | [diff] [blame] | 99 | err := serverVpp.start() |
Maros Ondrejicka | 5b74631 | 2022-11-16 12:51:11 +0100 | [diff] [blame] | 100 | 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 Ondrejicka | db823ed | 2022-12-14 16:30:04 +0100 | [diff] [blame] | 105 | clientContainer := s.getContainerByName("client-vpp") |
Maros Ondrejicka | 5b74631 | 2022-11-16 12:51:11 +0100 | [diff] [blame] | 106 | |
| 107 | clientVpp := NewVppInstance(clientContainer) |
| 108 | s.assertNotNil(clientVpp) |
Maros Ondrejicka | 5b74631 | 2022-11-16 12:51:11 +0100 | [diff] [blame] | 109 | 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 Ondrejicka | 8753180 | 2022-12-19 20:35:27 +0100 | [diff] [blame] | 129 | s.log(output) |
Maros Ondrejicka | 5b74631 | 2022-11-16 12:51:11 +0100 | [diff] [blame] | 130 | } |