hsa: unify echo test setup
[vpp.git] / extras / hs-test / echo_test.go
1 package main
2
3 func (s *VethsSuite) TestEchoBuiltin() {
4         serverVpp := s.getContainerByName("server-vpp").vppInstance
5         serverVeth := s.netInterfaces["vppsrv"]
6
7         serverVpp.vppctl("test echo server " +
8                 " uri tcp://" + serverVeth.ip4AddressString() + "/1234")
9
10         clientVpp := s.getContainerByName("client-vpp").vppInstance
11
12         o := clientVpp.vppctl("test echo client nclients 100 bytes 1 verbose" +
13                 " syn-timeout 100 test-timeout 100" +
14                 " uri tcp://" + serverVeth.ip4AddressString() + "/1234")
15         s.log(o)
16         s.assertNotContains(o, "failed:")
17 }
18
19 func (s *VethsSuite) TestTcpWithLoss() {
20         serverVpp := s.getContainerByName("server-vpp").vppInstance
21
22         serverVeth := s.netInterfaces[serverInterfaceName]
23         serverVpp.vppctl("test echo server uri tcp://%s/20022",
24                 serverVeth.ip4AddressString())
25
26         clientVpp := s.getContainerByName("client-vpp").vppInstance
27
28         // Ensure that VPP doesn't abort itself with NSIM enabled
29         // Warning: Removing this ping will make the test fail!
30         clientVpp.vppctl("ping %s", serverVeth.ip4AddressString())
31
32         // Add loss of packets with Network Delay Simulator
33         clientVpp.vppctl("set nsim poll-main-thread delay 0.01 ms bandwidth 40 gbit" +
34                 " packet-size 1400 packets-per-drop 1000")
35
36         clientVpp.vppctl("nsim output-feature enable-disable host-vppcln")
37
38         // Do echo test from client-vpp container
39         output := clientVpp.vppctl("test echo client uri tcp://%s/20022 verbose echo-bytes mbytes 50",
40                 serverVeth.ip4AddressString())
41         s.log(output)
42         s.assertNotEqual(len(output), 0)
43         s.assertNotContains(output, "failed: timeout")
44 }