blob: ce852bea3e042a844b2fe7c70876159a2f74a7bb [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 Villin0df582e2024-05-22 09:26:47 -040024// unstable with multiple workers
Adrian Villincee15aa2024-03-14 11:42:55 -040025func TcpWithLossTest(s *VethsSuite) {
Adrian Villin0df582e2024-05-22 09:26:47 -040026 s.SkipIfMultiWorker()
Filip Tehlarefe875e2023-09-04 14:17:52 +020027 serverVpp := s.getContainerByName("server-vpp").vppInstance
28
adrianvillin28bd8f02024-02-13 06:00:02 -050029 serverVeth := s.getInterfaceByName(serverInterfaceName)
Filip Tehlarefe875e2023-09-04 14:17:52 +020030 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 Fabianc899ab42024-04-22 13:42:00 +020036 // Warning: Removing this ping will make VPP crash!
37 clientVpp.vppctl("ping %s", serverVeth.ip4AddressString())
Filip Tehlarefe875e2023-09-04 14:17:52 +020038
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 Fabianc899ab42024-04-22 13:42:00 +020043 clientVpp.vppctl("nsim output-feature enable-disable host-" + s.getInterfaceByName(clientInterfaceName).name)
Filip Tehlarefe875e2023-09-04 14:17:52 +020044
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 Villin46d66002024-05-15 04:33:41 -040050 s.assertNotContains(output, "failed", output)
Filip Tehlar229f5fc2022-08-09 14:44:47 +000051}