From 459cdbd19b7a91f931c1cc59790c496ff1c9c2cc Mon Sep 17 00:00:00 2001 From: Florin Coras Date: Sat, 31 May 2025 17:42:38 -0400 Subject: [PATCH] hs-test: ldp test server logging improvements - 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 --- extras/hs-test/ldp_test.go | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/extras/hs-test/ldp_test.go b/extras/hs-test/ldp_test.go index 8f9982a2aaa..c30bc27055a 100644 --- a/extras/hs-test/ldp_test.go +++ b/extras/hs-test/ldp_test.go @@ -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 -- 2.16.6