blob: 33728db6c97e10a7bcb819500162bc2ff7fc159a [file] [log] [blame]
Filip Tehlar229f5fc2022-08-09 14:44:47 +00001package main
2
Adrian Villincee15aa2024-03-14 11:42:55 -04003func init() {
4 registerVethTests(EchoBuiltinTest)
5 registerSoloVethTests(TcpWithLossTest)
6}
7
8func EchoBuiltinTest(s *VethsSuite) {
Maros Ondrejickaffa3f602023-01-26 10:07:29 +01009 serverVpp := s.getContainerByName("server-vpp").vppInstance
adrianvillin28bd8f02024-02-13 06:00:02 -050010 serverVeth := s.getInterfaceByName(serverInterfaceName)
Maros Ondrejickaffa3f602023-01-26 10:07:29 +010011
Maros Ondrejicka2908f8c2023-02-02 08:58:04 +010012 serverVpp.vppctl("test echo server " +
Maros Ondrejickae7625d02023-02-28 16:55:01 +010013 " uri tcp://" + serverVeth.ip4AddressString() + "/1234")
Filip Tehlar229f5fc2022-08-09 14:44:47 +000014
Maros Ondrejickaffa3f602023-01-26 10:07:29 +010015 clientVpp := s.getContainerByName("client-vpp").vppInstance
Filip Tehlar229f5fc2022-08-09 14:44:47 +000016
Filip Tehlarefe875e2023-09-04 14:17:52 +020017 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 Ondrejicka87531802022-12-19 20:35:27 +010020 s.log(o)
Filip Tehlarefe875e2023-09-04 14:17:52 +020021 s.assertNotContains(o, "failed:")
22}
23
Adrian Villincee15aa2024-03-14 11:42:55 -040024func TcpWithLossTest(s *VethsSuite) {
Filip Tehlarefe875e2023-09-04 14:17:52 +020025 serverVpp := s.getContainerByName("server-vpp").vppInstance
26
adrianvillin28bd8f02024-02-13 06:00:02 -050027 serverVeth := s.getInterfaceByName(serverInterfaceName)
Filip Tehlarefe875e2023-09-04 14:17:52 +020028 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 Fabianc899ab42024-04-22 13:42:00 +020034 // Warning: Removing this ping will make VPP crash!
35 clientVpp.vppctl("ping %s", serverVeth.ip4AddressString())
Filip Tehlarefe875e2023-09-04 14:17:52 +020036
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 Fabianc899ab42024-04-22 13:42:00 +020041 clientVpp.vppctl("nsim output-feature enable-disable host-" + s.getInterfaceByName(clientInterfaceName).name)
Filip Tehlarefe875e2023-09-04 14:17:52 +020042
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)
Adrian Villin46d66002024-05-15 04:33:41 -040048 s.assertNotContains(output, "failed", output)
Filip Tehlar229f5fc2022-08-09 14:44:47 +000049}