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 | cee15aa | 2024-03-14 11:42:55 -0400 | [diff] [blame] | 24 | func TcpWithLossTest(s *VethsSuite) { |
Filip Tehlar | efe875e | 2023-09-04 14:17:52 +0200 | [diff] [blame] | 25 | serverVpp := s.getContainerByName("server-vpp").vppInstance |
| 26 | |
adrianvillin | 28bd8f0 | 2024-02-13 06:00:02 -0500 | [diff] [blame] | 27 | serverVeth := s.getInterfaceByName(serverInterfaceName) |
Filip Tehlar | efe875e | 2023-09-04 14:17:52 +0200 | [diff] [blame] | 28 | serverVpp.vppctl("test echo server uri tcp://%s/20022", |
| 29 | serverVeth.ip4AddressString()) |
| 30 | |
| 31 | clientVpp := s.getContainerByName("client-vpp").vppInstance |
| 32 | |
| 33 | // Ensure that VPP doesn't abort itself with NSIM enabled |
Matus Fabian | c899ab4 | 2024-04-22 13:42:00 +0200 | [diff] [blame] | 34 | // Warning: Removing this ping will make VPP crash! |
| 35 | clientVpp.vppctl("ping %s", serverVeth.ip4AddressString()) |
Filip Tehlar | efe875e | 2023-09-04 14:17:52 +0200 | [diff] [blame] | 36 | |
| 37 | // Add loss of packets with Network Delay Simulator |
| 38 | clientVpp.vppctl("set nsim poll-main-thread delay 0.01 ms bandwidth 40 gbit" + |
| 39 | " packet-size 1400 packets-per-drop 1000") |
| 40 | |
Matus Fabian | c899ab4 | 2024-04-22 13:42:00 +0200 | [diff] [blame] | 41 | clientVpp.vppctl("nsim output-feature enable-disable host-" + s.getInterfaceByName(clientInterfaceName).name) |
Filip Tehlar | efe875e | 2023-09-04 14:17:52 +0200 | [diff] [blame] | 42 | |
| 43 | // Do echo test from client-vpp container |
| 44 | output := clientVpp.vppctl("test echo client uri tcp://%s/20022 verbose echo-bytes mbytes 50", |
| 45 | serverVeth.ip4AddressString()) |
| 46 | s.log(output) |
| 47 | s.assertNotEqual(len(output), 0) |
adrianvillin | 7c67547 | 2024-02-12 02:44:53 -0500 | [diff] [blame] | 48 | s.assertNotContains(output, "failed: timeout", output) |
Filip Tehlar | 229f5fc | 2022-08-09 14:44:47 +0000 | [diff] [blame] | 49 | } |