From c02f243b8c1a2235ecf7f4ee79eedd23d5fbcd0e Mon Sep 17 00:00:00 2001 From: chyezh Date: Thu, 2 Jan 2025 15:02:07 +0800 Subject: [PATCH 1/2] enhance: TestDeleteComplexExpr may failure because of timeout Signed-off-by: chyezh --- tests/go_client/testcases/delete_test.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/tests/go_client/testcases/delete_test.go b/tests/go_client/testcases/delete_test.go index cdab8ed3febc1..7a92b7fc9f4ed 100644 --- a/tests/go_client/testcases/delete_test.go +++ b/tests/go_client/testcases/delete_test.go @@ -5,6 +5,7 @@ import ( "testing" "time" + "github.com/remeh/sizedwaitgroup" "github.com/stretchr/testify/require" "go.uber.org/zap" @@ -476,7 +477,9 @@ func TestDeleteComplexExpr(t *testing.T) { {expr: fmt.Sprintf("%s == [0, 1]", common.DefaultDoubleArrayField), count: 0}, // array == {expr: fmt.Sprintf("array_length(%s) == %d", common.DefaultDoubleArrayField, capacity), count: common.DefaultNb}, // array_length } - for _, exprLimit := range exprLimits { + sizedwaitgroup := sizedwaitgroup.New(5) + testFunc := func(exprLimit exprCount) { + defer sizedwaitgroup.Done() ctx := hp.CreateContext(t, time.Second*common.DefaultTimeout*2) mc := createDefaultMilvusClient(ctx, t) @@ -503,6 +506,13 @@ func TestDeleteComplexExpr(t *testing.T) { common.CheckErr(t, err, true) require.Zero(t, resQuery.ResultCount) } + + for _, exprLimit := range exprLimits { + exprLimit := exprLimit + sizedwaitgroup.Add() + go testFunc(exprLimit) + } + sizedwaitgroup.Wait() } func TestDeleteInvalidExpr(t *testing.T) { From 46528309dee0095900929ee3653fb964e2d3aab8 Mon Sep 17 00:00:00 2001 From: chyezh Date: Thu, 2 Jan 2025 16:53:00 +0800 Subject: [PATCH 2/2] fix: ut Signed-off-by: chyezh --- tests/go_client/testcases/delete_test.go | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/tests/go_client/testcases/delete_test.go b/tests/go_client/testcases/delete_test.go index 7a92b7fc9f4ed..0d77081fbb17e 100644 --- a/tests/go_client/testcases/delete_test.go +++ b/tests/go_client/testcases/delete_test.go @@ -2,10 +2,10 @@ package testcases import ( "fmt" + "sync" "testing" "time" - "github.com/remeh/sizedwaitgroup" "github.com/stretchr/testify/require" "go.uber.org/zap" @@ -435,8 +435,6 @@ func TestDeletePartitionName(t *testing.T) { // test delete ids field not pk int64 func TestDeleteComplexExpr(t *testing.T) { - t.Parallel() - type exprCount struct { expr string count int @@ -477,9 +475,13 @@ func TestDeleteComplexExpr(t *testing.T) { {expr: fmt.Sprintf("%s == [0, 1]", common.DefaultDoubleArrayField), count: 0}, // array == {expr: fmt.Sprintf("array_length(%s) == %d", common.DefaultDoubleArrayField, capacity), count: common.DefaultNb}, // array_length } - sizedwaitgroup := sizedwaitgroup.New(5) + ch := make(chan struct{}, 5) + wg := sync.WaitGroup{} testFunc := func(exprLimit exprCount) { - defer sizedwaitgroup.Done() + defer func() { + wg.Done() + <-ch + }() ctx := hp.CreateContext(t, time.Second*common.DefaultTimeout*2) mc := createDefaultMilvusClient(ctx, t) @@ -509,10 +511,11 @@ func TestDeleteComplexExpr(t *testing.T) { for _, exprLimit := range exprLimits { exprLimit := exprLimit - sizedwaitgroup.Add() + ch <- struct{}{} + wg.Add(1) go testFunc(exprLimit) } - sizedwaitgroup.Wait() + wg.Wait() } func TestDeleteInvalidExpr(t *testing.T) {