Files
vpp/extras/hs-test/iperf_linux_test.go
Adrian Villin 8b2a67c8f3 hs-test: improved iperf testing
- set iperf to json output
- added iperf json parsing function
- we can now check if iperf transferred more than X megabytes
  (other asserts can be added)

Type: test

Change-Id: I560104a153456b46f22a1affee4301018063b99d
Signed-off-by: Adrian Villin <avillin@cisco.com>
2024-12-10 05:03:54 +00:00

51 lines
1.3 KiB
Go

package main
import (
"fmt"
"time"
. "fd.io/hs-test/infra"
. "github.com/onsi/ginkgo/v2"
)
func init() {
RegisterIperfTests(IperfUdpLinuxTest)
}
func IperfUdpLinuxTest(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 []byte, 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 -J -p " + s.GetPortFromPpid()
s.StartClientApp(clientContainer, cmd, clnCh, clnRes)
}()
s.AssertChannelClosed(time.Minute*3, clnCh)
output := <-clnRes
result := s.ParseJsonIperfOutput(output)
s.LogJsonIperfOutput(result)
s.AssertIperfMinTransfer(result, 800)
}