diff options
author | Adrian Villin <avillin@cisco.com> | 2024-06-26 09:47:10 +0200 |
---|---|---|
committer | Florin Coras <florin.coras@gmail.com> | 2024-09-18 18:09:44 +0000 |
commit | 3ecd6840af4f890a11d26628ac34d31786b16758 (patch) | |
tree | c87d6a0407460efca5a13fd54afe1850ddbb6376 /extras/hs-test/iperf_linux_test.go | |
parent | 0950830ee9fff7ce62145cab64ed76605487e647 (diff) |
hs-test: containerize iperf tests
Type: test
Change-Id: I2c0bb76d96ccadd5ecfd6a04565420855043699e
Signed-off-by: Adrian Villin <avillin@cisco.com>
Diffstat (limited to 'extras/hs-test/iperf_linux_test.go')
-rw-r--r-- | extras/hs-test/iperf_linux_test.go | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/extras/hs-test/iperf_linux_test.go b/extras/hs-test/iperf_linux_test.go new file mode 100644 index 00000000000..14422fe5efa --- /dev/null +++ b/extras/hs-test/iperf_linux_test.go @@ -0,0 +1,48 @@ +package main + +import ( + "fmt" + + . "fd.io/hs-test/infra" + . "github.com/onsi/ginkgo/v2" +) + +func init() { + RegisterIperfTests(IperfLinuxTest) +} + +func IperfLinuxTest(s *IperfSuite) { + serverContainer := s.GetContainerByName(ServerIperfContainerName) + serverIpAddress := s.GetInterfaceByName(ServerIperfInterfaceName).Ip4AddressString() + clientContainer := s.GetContainerByName(ClientIperfContainerName) + clientIpAddress := s.GetInterfaceByName(ClientIperfInterfaceName).Ip4AddressString() + + clnCh := make(chan error) + stopServerCh := make(chan struct{}) + srvCh := make(chan error, 1) + clnRes := make(chan string, 1) + + defer func() { + stopServerCh <- struct{}{} + }() + + go func() { + defer GinkgoRecover() + cmd := "iperf3 -4 -s -B " + serverIpAddress + " -p " + s.GetPortFromPpid() + s.StartServerApp(serverContainer, "iperf3", cmd, srvCh, stopServerCh) + }() + err := <-srvCh + s.AssertNil(err, fmt.Sprint(err)) + s.Log("server running") + + go func() { + defer GinkgoRecover() + cmd := "iperf3 -c " + serverIpAddress + " -B " + clientIpAddress + + " -u -l 1460 -b 10g -p " + s.GetPortFromPpid() + s.StartClientApp(clientContainer, cmd, clnCh, clnRes) + }() + + s.Log(<-clnRes) + err = <-clnCh + s.AssertNil(err, "err: '%s'", err) +} |