Skip to content

Commit

Permalink
Fix checking channel
Browse files Browse the repository at this point in the history
Signed-off-by: Wenqi Qiu <[email protected]>
  • Loading branch information
wenqiq committed Mar 21, 2024
1 parent b39ad49 commit b2f3ac3
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
4 changes: 1 addition & 3 deletions test/performance/framework/case.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -91,15 +90,14 @@ func (c *ScaleTestCase) Run(ctx context.Context, testData *ScaleData) error {
if err != nil {
return err.(error)
}
actualCheckNum = scaleRes.actualCheckNum
scaleNum = scaleRes.scaleNum
res = "success"
}

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++
Expand Down
4 changes: 2 additions & 2 deletions test/performance/framework/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit b2f3ac3

Please sign in to comment.