hs-test: added iperf packet reorder tests 97/42797/8
authorAdrian Villin <[email protected]>
Wed, 16 Apr 2025 09:54:03 +0000 (11:54 +0200)
committerFlorin Coras <[email protected]>
Wed, 23 Apr 2025 17:10:38 +0000 (17:10 +0000)
Type: test

Change-Id: I1df8bc4e13bbbdd3c8ee15fbe645bd9a1e4d3fed
Signed-off-by: Adrian Villin <[email protected]>
extras/hs-test/ldp_test.go

index 6ce0943..ef2592c 100644 (file)
@@ -2,6 +2,7 @@ package main
 
 import (
        "fmt"
+       "os/exec"
        "time"
 
        . "fd.io/hs-test/infra"
@@ -9,11 +10,55 @@ import (
 )
 
 func init() {
-       RegisterLdpTests(LdpIperfUdpVppTest, LdpIperfUdpVppInterruptModeTest, RedisBenchmarkTest, LdpIperfTlsTcpTest, LdpIperfTcpVppTest)
+       RegisterLdpTests(LdpIperfUdpTest, LdpIperfUdpVppInterruptModeTest, RedisBenchmarkTest, LdpIperfTlsTcpTest, LdpIperfTcpTest, LdpIperfTcpReorderTest,
+               LdpIperfReverseTcpReorderTest, LdpIperfUdpReorderTest, LdpIperfReverseUdpReorderTest)
 }
 
 func LdpIperfUdpVppInterruptModeTest(s *LdpSuite) {
-       ldPreloadIperfVpp(s, true)
+       ldPreloadIperf(s, "-u")
+}
+
+func ldpIperfTcpReorder(s *LdpSuite, netInterface *NetInterface, extraIperfArgs string) {
+       cmd := exec.Command("ip", "netns", "exec", netInterface.Peer.NetworkNamespace,
+               "tc", "qdisc", "del", "dev", netInterface.Peer.Name(),
+               "root")
+       s.Log("defer '%s'", cmd.String())
+       defer cmd.Run()
+
+       // "10% of packets (with a correlation of 50%) will get sent immediately, others will be delayed by 10ms"
+       // https://www.man7.org/linux/man-pages/man8/tc-netem.8.html
+       cmd = exec.Command("ip", "netns", "exec", netInterface.Peer.NetworkNamespace,
+               "tc", "qdisc", "add", "dev", netInterface.Peer.Name(),
+               "root", "netem", "delay", "10ms", "reorder", "10%", "50%")
+       s.Log(cmd.String())
+       o, err := cmd.CombinedOutput()
+       s.AssertNil(err, string(o))
+
+       delete(s.Containers.ClientVpp.EnvVars, "VCL_CONFIG")
+       delete(s.Containers.ClientVpp.EnvVars, "LD_PRELOAD")
+       delete(s.Containers.ClientVpp.EnvVars, "VCL_DEBUG")
+       delete(s.Containers.ClientVpp.EnvVars, "LDP_DEBUG")
+       s.Containers.ClientVpp.VppInstance.Disconnect()
+       s.Containers.ClientVpp.VppInstance.Stop()
+       s.Containers.ClientVpp.Exec(false, "ip addr add dev %s %s", s.Interfaces.Client.Name(), s.Interfaces.Client.Ip4Address)
+
+       ldPreloadIperf(s, extraIperfArgs)
+}
+
+func LdpIperfTcpReorderTest(s *LdpSuite) {
+       ldpIperfTcpReorder(s, s.Interfaces.Server, "")
+}
+
+func LdpIperfReverseTcpReorderTest(s *LdpSuite) {
+       ldpIperfTcpReorder(s, s.Interfaces.Client, "-R")
+}
+
+func LdpIperfUdpReorderTest(s *LdpSuite) {
+       ldpIperfTcpReorder(s, s.Interfaces.Server, "-u")
+}
+
+func LdpIperfReverseUdpReorderTest(s *LdpSuite) {
+       ldpIperfTcpReorder(s, s.Interfaces.Client, "-u -R")
 }
 
 func LdpIperfTlsTcpTest(s *LdpSuite) {
@@ -26,22 +71,18 @@ func LdpIperfTlsTcpTest(s *LdpSuite) {
                c.AddEnvVar("LDP_TLS_CERT_FILE", "/crt.crt")
                c.AddEnvVar("LDP_TLS_KEY_FILE", "/key.key")
        }
-       ldPreloadIperfVpp(s, false)
+       ldPreloadIperf(s, "")
 }
 
-func LdpIperfTcpVppTest(s *LdpSuite) {
-       ldPreloadIperfVpp(s, false)
+func LdpIperfTcpTest(s *LdpSuite) {
+       ldPreloadIperf(s, "")
 }
 
-func LdpIperfUdpVppTest(s *LdpSuite) {
-       ldPreloadIperfVpp(s, true)
+func LdpIperfUdpTest(s *LdpSuite) {
+       ldPreloadIperf(s, "-u")
 }
 
-func ldPreloadIperfVpp(s *LdpSuite, useUdp bool) {
-       protocol := ""
-       if useUdp {
-               protocol = " -u "
-       }
+func ldPreloadIperf(s *LdpSuite, extraClientArgs string) {
        serverVethAddress := s.Interfaces.Server.Ip4AddressString()
        stopServerCh := make(chan struct{}, 1)
        srvCh := make(chan error, 1)
@@ -63,11 +104,11 @@ func ldPreloadIperfVpp(s *LdpSuite, useUdp bool) {
 
        go func() {
                defer GinkgoRecover()
-               cmd := "iperf3 -c " + serverVethAddress + " -l 1460 -b 10g -J -p " + s.GetPortFromPpid() + protocol
+               cmd := "iperf3 -c " + serverVethAddress + " -l 1460 -b 10g -J -p " + s.GetPortFromPpid() + " " + extraClientArgs
                s.StartClientApp(s.Containers.ClientVpp, cmd, clnCh, clnRes)
        }()
 
-       s.AssertChannelClosed(time.Minute*3, clnCh)
+       s.AssertChannelClosed(time.Minute*4, clnCh)
        output := <-clnRes
        result := s.ParseJsonIperfOutput(output)
        s.LogJsonIperfOutput(result)