From 8d84125e93309812968762bd55c72df33ed9ed97 Mon Sep 17 00:00:00 2001 From: Adrian Villin Date: Fri, 15 Aug 2025 14:52:53 +0200 Subject: [PATCH] hs-test: iperf improvements - added AssertIperfMinTransfer to KindIperfVclTest - fixed 'make cleanup-perf' Type: test Change-Id: I50f7d837b1d4d842cb7464a5ee08cbecdea7adcd Signed-off-by: Adrian Villin --- extras/hs-test/Makefile | 4 ++-- extras/hs-test/infra/common/utils_common.go | 21 +++++++++++++++++++++ extras/hs-test/kind_test.go | 9 ++++++--- extras/hs-test/ldp_test.go | 20 +------------------- 4 files changed, 30 insertions(+), 24 deletions(-) diff --git a/extras/hs-test/Makefile b/extras/hs-test/Makefile index bc52c22d0a7..902f3d922f2 100644 --- a/extras/hs-test/Makefile +++ b/extras/hs-test/Makefile @@ -376,10 +376,10 @@ cleanup-perf: fi @echo "****************************" @echo "Removing kubernetes pods:" - @kubectl delete pods --all --grace-period=0 -n namespace$$(cat .last_hst_ppid) + @kubectl delete pods --all --grace-period=0 -n hs-test$$(cat .last_hst_ppid) @echo "****************************" @echo "Removing kubernetes namespace:" - @kubectl delete namespace namespace$$(cat .last_hst_ppid) + @kubectl delete namespace hs-test$$(cat .last_hst_ppid) @echo "****************************" @echo "Done." @echo "****************************" diff --git a/extras/hs-test/infra/common/utils_common.go b/extras/hs-test/infra/common/utils_common.go index 5b3d7181748..15db60b387e 100644 --- a/extras/hs-test/infra/common/utils_common.go +++ b/extras/hs-test/infra/common/utils_common.go @@ -66,6 +66,27 @@ type IPerfResult struct { func (s *HstCommon) ParseJsonIperfOutput(jsonResult []byte) IPerfResult { var result IPerfResult + + // 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(jsonResult) + braceCount := 0 + for i := 0; i < len(jsonResult); i++ { + if jsonResult[i] == '{' { + if jsonStart == -1 { + jsonStart = i + } + braceCount++ + } else if jsonResult[i] == '}' { + braceCount-- + if braceCount == 0 { + jsonEnd = i + 1 + break + } + } + } + jsonResult = jsonResult[jsonStart:jsonEnd] + // remove iperf warning line if present if strings.Contains(string(jsonResult), "warning") { index := strings.Index(string(jsonResult), "\n") diff --git a/extras/hs-test/kind_test.go b/extras/hs-test/kind_test.go index 8039e6b0624..aaac1b52480 100644 --- a/extras/hs-test/kind_test.go +++ b/extras/hs-test/kind_test.go @@ -30,12 +30,15 @@ func KindIperfVclTest(s *KindSuite) { s.FixVersionNumber(s.Pods.ClientGeneric, s.Pods.ServerGeneric) o, err := s.Pods.ServerGeneric.Exec(ctx, []string{"/bin/bash", "-c", - vcl + " " + ldp + " iperf3 -s -D -4"}) + vcl + " " + ldp + " iperf3 -s -D -4 -B " + s.Pods.ServerGeneric.IpAddress}) s.AssertNil(err, o) o, err = s.Pods.ClientGeneric.Exec(ctx, []string{"/bin/bash", "-c", - vcl + " " + ldp + " iperf3 -l 1460 -b 10g -c " + s.Pods.ServerGeneric.IpAddress}) - s.Log(o) + vcl + " " + ldp + " iperf3 -J -l 1460 -b 10g -c " + s.Pods.ServerGeneric.IpAddress}) + s.AssertNil(err) + result := s.ParseJsonIperfOutput([]byte(o)) + s.LogJsonIperfOutput(result) + s.AssertIperfMinTransfer(result, 2000) } func NginxRpsTest(s *KindSuite) { diff --git a/extras/hs-test/ldp_test.go b/extras/hs-test/ldp_test.go index 1c057b081b3..b0c6276236f 100644 --- a/extras/hs-test/ldp_test.go +++ b/extras/hs-test/ldp_test.go @@ -117,25 +117,7 @@ func ldPreloadIperf(s *LdpSuite, extraClientArgs string) IPerfResult { s.AssertChannelClosed(time.Minute*4, clnCh) output := <-clnRes - // 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]) + result := s.ParseJsonIperfOutput(output) s.LogJsonIperfOutput(result) return result -- 2.16.6