2024-06-26 09:47:10 +02:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
2024-10-15 14:56:16 +02:00
|
|
|
"time"
|
2024-06-26 09:47:10 +02:00
|
|
|
|
|
|
|
. "fd.io/hs-test/infra"
|
|
|
|
. "github.com/onsi/ginkgo/v2"
|
|
|
|
)
|
|
|
|
|
|
|
|
func init() {
|
2024-11-27 09:47:44 +01:00
|
|
|
RegisterIperfTests(IperfUdpLinuxTest)
|
2024-06-26 09:47:10 +02:00
|
|
|
}
|
|
|
|
|
2024-11-27 09:47:44 +01:00
|
|
|
func IperfUdpLinuxTest(s *IperfSuite) {
|
2024-12-09 14:18:31 +01:00
|
|
|
serverIpAddress := s.Interfaces.Server.Ip4AddressString()
|
|
|
|
clientIpAddress := s.Interfaces.Client.Ip4AddressString()
|
2024-06-26 09:47:10 +02:00
|
|
|
|
|
|
|
clnCh := make(chan error)
|
|
|
|
stopServerCh := make(chan struct{})
|
|
|
|
srvCh := make(chan error, 1)
|
2024-12-06 16:00:25 +01:00
|
|
|
clnRes := make(chan []byte, 1)
|
2024-06-26 09:47:10 +02:00
|
|
|
|
|
|
|
defer func() {
|
|
|
|
stopServerCh <- struct{}{}
|
|
|
|
}()
|
|
|
|
|
|
|
|
go func() {
|
|
|
|
defer GinkgoRecover()
|
|
|
|
cmd := "iperf3 -4 -s -B " + serverIpAddress + " -p " + s.GetPortFromPpid()
|
2024-12-09 14:18:31 +01:00
|
|
|
s.StartServerApp(s.Containers.Server, "iperf3", cmd, srvCh, stopServerCh)
|
2024-06-26 09:47:10 +02:00
|
|
|
}()
|
|
|
|
err := <-srvCh
|
|
|
|
s.AssertNil(err, fmt.Sprint(err))
|
|
|
|
s.Log("server running")
|
|
|
|
|
|
|
|
go func() {
|
|
|
|
defer GinkgoRecover()
|
|
|
|
cmd := "iperf3 -c " + serverIpAddress + " -B " + clientIpAddress +
|
2024-12-06 16:00:25 +01:00
|
|
|
" -u -l 1460 -b 10g -J -p " + s.GetPortFromPpid()
|
2024-12-09 14:18:31 +01:00
|
|
|
s.StartClientApp(s.Containers.Client, cmd, clnCh, clnRes)
|
2024-06-26 09:47:10 +02:00
|
|
|
}()
|
2024-10-15 14:56:16 +02:00
|
|
|
s.AssertChannelClosed(time.Minute*3, clnCh)
|
2024-12-06 16:00:25 +01:00
|
|
|
output := <-clnRes
|
|
|
|
result := s.ParseJsonIperfOutput(output)
|
|
|
|
s.LogJsonIperfOutput(result)
|
|
|
|
s.AssertIperfMinTransfer(result, 800)
|
2024-06-26 09:47:10 +02:00
|
|
|
}
|