710163cf20c2d51945c5f2fa13396ae30f890782
[vpp.git] / extras / hs-test / echo_test.go
1 package main
2
3 func init() {
4         registerVethTests(EchoBuiltinTest)
5         registerSoloVethTests(TcpWithLossTest)
6 }
7
8 func EchoBuiltinTest(s *VethsSuite) {
9         serverVpp := s.getContainerByName("server-vpp").vppInstance
10         serverVeth := s.getInterfaceByName(serverInterfaceName)
11
12         serverVpp.vppctl("test echo server " +
13                 " uri tcp://" + serverVeth.ip4AddressString() + "/1234")
14
15         clientVpp := s.getContainerByName("client-vpp").vppInstance
16
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")
20         s.log(o)
21         s.assertNotContains(o, "failed:")
22 }
23
24 func TcpWithLossTest(s *VethsSuite) {
25         serverVpp := s.getContainerByName("server-vpp").vppInstance
26
27         serverVeth := s.getInterfaceByName(serverInterfaceName)
28         serverVpp.vppctl("test echo server uri tcp://%s/20022",
29                 serverVeth.ip4AddressString())
30
31         clientVpp := s.getContainerByName("client-vpp").vppInstance
32
33         // TODO: investigate why this ping was here:
34         // ---------
35         // Ensure that VPP doesn't abort itself with NSIM enabled
36         // Warning: Removing this ping will make the test fail!
37         // clientVpp.vppctl("ping %s", serverVeth.ip4AddressString())
38         // ---------
39
40         // Add loss of packets with Network Delay Simulator
41         clientVpp.vppctl("set nsim poll-main-thread delay 0.01 ms bandwidth 40 gbit" +
42                 " packet-size 1400 packets-per-drop 1000")
43
44         clientVpp.vppctl("nsim output-feature enable-disable " + s.getInterfaceByName(clientInterfaceName).name)
45
46         // Do echo test from client-vpp container
47         output := clientVpp.vppctl("test echo client uri tcp://%s/20022 verbose echo-bytes mbytes 50",
48                 serverVeth.ip4AddressString())
49         s.log(output)
50         s.assertNotEqual(len(output), 0)
51         s.assertNotContains(output, "failed: timeout", output)
52 }