hs-test: ldp test server logging improvements 61/43061/5
authorFlorin Coras <[email protected]>
Sat, 31 May 2025 21:42:38 +0000 (17:42 -0400)
committerDave Barach <[email protected]>
Mon, 2 Jun 2025 17:41:15 +0000 (17:41 +0000)
- dump stderr and stdout to a file instead of asking iperf to dump to
  file
- handle vcl/ldp debug logs when parsing iperf json output

Type: improvement

Change-Id: I535915315416e83c569f668f984ea9204d744174
Signed-off-by: Florin Coras <[email protected]>
extras/hs-test/ldp_test.go

index 8f9982a..c30bc27 100644 (file)
@@ -97,7 +97,7 @@ func ldPreloadIperf(s *LdpSuite, extraClientArgs string) IPerfResult {
 
        go func() {
                defer GinkgoRecover()
-               cmd := "iperf3 -4 -s -p " + s.Ports.Port1 + " --logfile " + s.IperfLogFileName(s.Containers.ServerApp)
+               cmd := "sh -c \"iperf3 -4 -s -p " + s.Ports.Port1 + " > " + s.IperfLogFileName(s.Containers.ServerApp) + " 2>&1\""
                s.StartServerApp(s.Containers.ServerApp, "iperf3", cmd, srvCh, stopServerCh)
        }()
 
@@ -112,7 +112,25 @@ func ldPreloadIperf(s *LdpSuite, extraClientArgs string) IPerfResult {
 
        s.AssertChannelClosed(time.Minute*4, clnCh)
        output := <-clnRes
-       result := s.ParseJsonIperfOutput(output)
+       // VCL/LDP debugging can pollute output so find the first occurrence of a curly brace to locate the start of JSON data
+       jsonStart := -1
+       jsonEnd := len(output)
+       braceCount := 0
+       for i := 0; i < len(output); i++ {
+               if output[i] == '{' {
+                       if jsonStart == -1 {
+                               jsonStart = i
+                       }
+                       braceCount++
+               } else if output[i] == '}' {
+                       braceCount--
+                       if braceCount == 0 {
+                               jsonEnd = i + 1
+                               break
+                       }
+               }
+       }
+       result := s.ParseJsonIperfOutput(output[jsonStart:jsonEnd])
        s.LogJsonIperfOutput(result)
 
        return result