Filip Tehlar | 229f5fc | 2022-08-09 14:44:47 +0000 | [diff] [blame] | 1 | package main |
| 2 | |
Adrian Villin | cee15aa | 2024-03-14 11:42:55 -0400 | [diff] [blame] | 3 | func init() { |
| 4 | registerVethTests(EchoBuiltinTest) |
| 5 | registerSoloVethTests(TcpWithLossTest) |
| 6 | } |
| 7 | |
| 8 | func EchoBuiltinTest(s *VethsSuite) { |
Maros Ondrejicka | ffa3f60 | 2023-01-26 10:07:29 +0100 | [diff] [blame] | 9 | serverVpp := s.getContainerByName("server-vpp").vppInstance |
adrianvillin | 28bd8f0 | 2024-02-13 06:00:02 -0500 | [diff] [blame] | 10 | serverVeth := s.getInterfaceByName(serverInterfaceName) |
Maros Ondrejicka | ffa3f60 | 2023-01-26 10:07:29 +0100 | [diff] [blame] | 11 | |
Maros Ondrejicka | 2908f8c | 2023-02-02 08:58:04 +0100 | [diff] [blame] | 12 | serverVpp.vppctl("test echo server " + |
Maros Ondrejicka | e7625d0 | 2023-02-28 16:55:01 +0100 | [diff] [blame] | 13 | " uri tcp://" + serverVeth.ip4AddressString() + "/1234") |
Filip Tehlar | 229f5fc | 2022-08-09 14:44:47 +0000 | [diff] [blame] | 14 | |
Maros Ondrejicka | ffa3f60 | 2023-01-26 10:07:29 +0100 | [diff] [blame] | 15 | clientVpp := s.getContainerByName("client-vpp").vppInstance |
Filip Tehlar | 229f5fc | 2022-08-09 14:44:47 +0000 | [diff] [blame] | 16 | |
Filip Tehlar | efe875e | 2023-09-04 14:17:52 +0200 | [diff] [blame] | 17 | o := clientVpp.vppctl("test echo client nclients 100 bytes 1 verbose" + |
| 18 | " syn-timeout 100 test-timeout 100" + |
| 19 | " uri tcp://" + serverVeth.ip4AddressString() + "/1234") |
Maros Ondrejicka | 8753180 | 2022-12-19 20:35:27 +0100 | [diff] [blame] | 20 | s.log(o) |
Filip Tehlar | efe875e | 2023-09-04 14:17:52 +0200 | [diff] [blame] | 21 | s.assertNotContains(o, "failed:") |
| 22 | } |
| 23 | |
Adrian Villin | 0df582e | 2024-05-22 09:26:47 -0400 | [diff] [blame] | 24 | // unstable with multiple workers |
Adrian Villin | cee15aa | 2024-03-14 11:42:55 -0400 | [diff] [blame] | 25 | func TcpWithLossTest(s *VethsSuite) { |
Adrian Villin | 0df582e | 2024-05-22 09:26:47 -0400 | [diff] [blame] | 26 | s.SkipIfMultiWorker() |
Filip Tehlar | efe875e | 2023-09-04 14:17:52 +0200 | [diff] [blame] | 27 | serverVpp := s.getContainerByName("server-vpp").vppInstance |
| 28 | |
adrianvillin | 28bd8f0 | 2024-02-13 06:00:02 -0500 | [diff] [blame] | 29 | serverVeth := s.getInterfaceByName(serverInterfaceName) |
Filip Tehlar | efe875e | 2023-09-04 14:17:52 +0200 | [diff] [blame] | 30 | serverVpp.vppctl("test echo server uri tcp://%s/20022", |
| 31 | serverVeth.ip4AddressString()) |
| 32 | |
| 33 | clientVpp := s.getContainerByName("client-vpp").vppInstance |
| 34 | |
| 35 | // Ensure that VPP doesn't abort itself with NSIM enabled |
Matus Fabian | c899ab4 | 2024-04-22 13:42:00 +0200 | [diff] [blame] | 36 | // Warning: Removing this ping will make VPP crash! |
| 37 | clientVpp.vppctl("ping %s", serverVeth.ip4AddressString()) |
Filip Tehlar | efe875e | 2023-09-04 14:17:52 +0200 | [diff] [blame] | 38 | |
| 39 | // Add loss of packets with Network Delay Simulator |
| 40 | clientVpp.vppctl("set nsim poll-main-thread delay 0.01 ms bandwidth 40 gbit" + |
| 41 | " packet-size 1400 packets-per-drop 1000") |
| 42 | |
Matus Fabian | c899ab4 | 2024-04-22 13:42:00 +0200 | [diff] [blame] | 43 | clientVpp.vppctl("nsim output-feature enable-disable host-" + s.getInterfaceByName(clientInterfaceName).name) |
Filip Tehlar | efe875e | 2023-09-04 14:17:52 +0200 | [diff] [blame] | 44 | |
| 45 | // Do echo test from client-vpp container |
| 46 | output := clientVpp.vppctl("test echo client uri tcp://%s/20022 verbose echo-bytes mbytes 50", |
| 47 | serverVeth.ip4AddressString()) |
| 48 | s.log(output) |
| 49 | s.assertNotEqual(len(output), 0) |
Adrian Villin | 46d6600 | 2024-05-15 04:33:41 -0400 | [diff] [blame] | 50 | s.assertNotContains(output, "failed", output) |
Filip Tehlar | 229f5fc | 2022-08-09 14:44:47 +0000 | [diff] [blame] | 51 | } |