tcp: make syn-rcvd timeout configurable
[vpp.git] / extras / hs-test / echo_test.go
1 package main
2
3 import (
4         . "fd.io/hs-test/infra"
5 )
6
7 func init() {
8         RegisterVethTests(EchoBuiltinTest)
9         RegisterSoloVethTests(TcpWithLossTest)
10 }
11
12 func EchoBuiltinTest(s *VethsSuite) {
13         serverVpp := s.GetContainerByName("server-vpp").VppInstance
14         serverVeth := s.GetInterfaceByName(ServerInterfaceName)
15
16         serverVpp.Vppctl("test echo server " +
17                 " uri tcp://" + serverVeth.Ip4AddressString() + "/1234")
18
19         clientVpp := s.GetContainerByName("client-vpp").VppInstance
20
21         o := clientVpp.Vppctl("test echo client nclients 100 bytes 1 verbose" +
22                 " syn-timeout 100 test-timeout 100" +
23                 " uri tcp://" + serverVeth.Ip4AddressString() + "/1234")
24         s.Log(o)
25         s.AssertNotContains(o, "failed:")
26 }
27
28 // unstable with multiple workers
29 func TcpWithLossTest(s *VethsSuite) {
30         s.SkipIfMultiWorker()
31         serverVpp := s.GetContainerByName("server-vpp").VppInstance
32
33         serverVeth := s.GetInterfaceByName(ServerInterfaceName)
34         serverVpp.Vppctl("test echo server uri tcp://%s/20022",
35                 serverVeth.Ip4AddressString())
36
37         clientVpp := s.GetContainerByName("client-vpp").VppInstance
38
39         // Ensure that VPP doesn't abort itself with NSIM enabled
40         // Warning: Removing this ping will make VPP crash!
41         clientVpp.Vppctl("ping %s", serverVeth.Ip4AddressString())
42
43         // Add loss of packets with Network Delay Simulator
44         clientVpp.Vppctl("set nsim poll-main-thread delay 0.01 ms bandwidth 40 gbit" +
45                 " packet-size 1400 packets-per-drop 1000")
46
47         name := s.GetInterfaceByName(ClientInterfaceName).Name()
48         clientVpp.Vppctl("nsim output-feature enable-disable host-" + name)
49
50         // Do echo test from client-vpp container
51         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)
56 }