blob: 6b4739a5457ad96dc501c741971644043fbf4c9b [file] [log] [blame]
Filip Tehlar229f5fc2022-08-09 14:44:47 +00001package main
2
Adrian Villin4677d922024-06-14 09:32:39 +02003import (
4 . "fd.io/hs-test/infra"
5)
6
Adrian Villincee15aa2024-03-14 11:42:55 -04007func init() {
Adrian Villin4677d922024-06-14 09:32:39 +02008 RegisterVethTests(EchoBuiltinTest)
9 RegisterSoloVethTests(TcpWithLossTest)
Adrian Villincee15aa2024-03-14 11:42:55 -040010}
11
12func EchoBuiltinTest(s *VethsSuite) {
Adrian Villin4677d922024-06-14 09:32:39 +020013 serverVpp := s.GetContainerByName("server-vpp").VppInstance
14 serverVeth := s.GetInterfaceByName(ServerInterfaceName)
Maros Ondrejickaffa3f602023-01-26 10:07:29 +010015
Adrian Villin4677d922024-06-14 09:32:39 +020016 serverVpp.Vppctl("test echo server " +
17 " uri tcp://" + serverVeth.Ip4AddressString() + "/1234")
Filip Tehlar229f5fc2022-08-09 14:44:47 +000018
Adrian Villin4677d922024-06-14 09:32:39 +020019 clientVpp := s.GetContainerByName("client-vpp").VppInstance
Filip Tehlar229f5fc2022-08-09 14:44:47 +000020
Adrian Villin4677d922024-06-14 09:32:39 +020021 o := clientVpp.Vppctl("test echo client nclients 100 bytes 1 verbose" +
Filip Tehlarefe875e2023-09-04 14:17:52 +020022 " syn-timeout 100 test-timeout 100" +
Adrian Villin4677d922024-06-14 09:32:39 +020023 " uri tcp://" + serverVeth.Ip4AddressString() + "/1234")
24 s.Log(o)
25 s.AssertNotContains(o, "failed:")
Filip Tehlarefe875e2023-09-04 14:17:52 +020026}
27
Adrian Villin0df582e2024-05-22 09:26:47 -040028// unstable with multiple workers
Adrian Villincee15aa2024-03-14 11:42:55 -040029func TcpWithLossTest(s *VethsSuite) {
Adrian Villin0df582e2024-05-22 09:26:47 -040030 s.SkipIfMultiWorker()
Adrian Villin4677d922024-06-14 09:32:39 +020031 serverVpp := s.GetContainerByName("server-vpp").VppInstance
Filip Tehlarefe875e2023-09-04 14:17:52 +020032
Adrian Villin4677d922024-06-14 09:32:39 +020033 serverVeth := s.GetInterfaceByName(ServerInterfaceName)
34 serverVpp.Vppctl("test echo server uri tcp://%s/20022",
35 serverVeth.Ip4AddressString())
Filip Tehlarefe875e2023-09-04 14:17:52 +020036
Adrian Villin4677d922024-06-14 09:32:39 +020037 clientVpp := s.GetContainerByName("client-vpp").VppInstance
Filip Tehlarefe875e2023-09-04 14:17:52 +020038
39 // Ensure that VPP doesn't abort itself with NSIM enabled
Matus Fabianc899ab42024-04-22 13:42:00 +020040 // Warning: Removing this ping will make VPP crash!
Adrian Villin4677d922024-06-14 09:32:39 +020041 clientVpp.Vppctl("ping %s", serverVeth.Ip4AddressString())
Filip Tehlarefe875e2023-09-04 14:17:52 +020042
43 // Add loss of packets with Network Delay Simulator
Adrian Villin4677d922024-06-14 09:32:39 +020044 clientVpp.Vppctl("set nsim poll-main-thread delay 0.01 ms bandwidth 40 gbit" +
Filip Tehlarefe875e2023-09-04 14:17:52 +020045 " packet-size 1400 packets-per-drop 1000")
46
Adrian Villin4677d922024-06-14 09:32:39 +020047 name := s.GetInterfaceByName(ClientInterfaceName).Name()
48 clientVpp.Vppctl("nsim output-feature enable-disable host-" + name)
Filip Tehlarefe875e2023-09-04 14:17:52 +020049
50 // Do echo test from client-vpp container
Adrian Villin4677d922024-06-14 09:32:39 +020051 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 Tehlar229f5fc2022-08-09 14:44:47 +000056}