From b2f3ac3c964df59e1ce1663a9d3c103d74fb6bde Mon Sep 17 00:00:00 2001 From: Wenqi Qiu Date: Thu, 21 Mar 2024 19:29:37 +0800 Subject: [PATCH] Fix checking channel Signed-off-by: Wenqi Qiu --- test/performance/framework/case.go | 4 +--- test/performance/framework/service.go | 4 ++-- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/test/performance/framework/case.go b/test/performance/framework/case.go index 69cc8205e27..f5d61ad6afe 100644 --- a/test/performance/framework/case.go +++ b/test/performance/framework/case.go @@ -72,7 +72,6 @@ func (c *ScaleTestCase) Run(ctx context.Context, testData *ScaleData) error { testData.maxCheckNum = testData.nodesNum * 10 ress := make(chan time.Duration, testData.maxCheckNum) res := "failed" - actualCheckNum := 0 scaleNum := 0 defer func() { close(ress) @@ -91,7 +90,6 @@ func (c *ScaleTestCase) Run(ctx context.Context, testData *ScaleData) error { if err != nil { return err.(error) } - actualCheckNum = scaleRes.actualCheckNum scaleNum = scaleRes.scaleNum res = "success" } @@ -99,7 +97,7 @@ func (c *ScaleTestCase) Run(ctx context.Context, testData *ScaleData) error { var rows [][]string var total, minRes, maxRes, avg time.Duration count := 0 - for i := 0; i < actualCheckNum; i++ { + for i := 0; i < len(ress); i++ { res := <-ress total += res count++ diff --git a/test/performance/framework/service.go b/test/performance/framework/service.go index 15ab6f88600..5d0c3a32a9a 100644 --- a/test/performance/framework/service.go +++ b/test/performance/framework/service.go @@ -59,7 +59,7 @@ func ScaleService(ctx context.Context, ch chan time.Duration, data *ScaleData) ( defer func() { res.err = err for { - if len(ch) == res.scaleNum { + if len(ch) == cap(ch) { break } klog.InfoS("Waiting the check goroutine finish") @@ -205,7 +205,7 @@ func scaleUp(ctx context.Context, data *ScaleData, ch chan time.Duration) (svcs var err error var clientPod *corev1.Pod svc.Spec.ClusterIP = clusterIP.String() - klog.InfoS("go FetchTimestampFromLog", "cap(ch)", cap(ch)) + klog.InfoS("go FetchTimestampFromLog", "cap(ch)", cap(ch), "len(ch)", len(ch)) fromPod := &podList.Items[testPodIndex%len(podList.Items)] testPodIndex++ clientPod, err = workload_pod.CreateClientPod(ctx, cs, fromPod.Namespace, fromPod.Name, []string{fmt.Sprintf("%s:%d", clusterIP, 80)}, workload_pod.ScaleTestPodProbeContainerName)