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