TestPairingHeap should call t.Parallel on the top level as well as its subtests
25 "github.com/vdaas/vald/internal/test/goleak"
26)
27
28func TestPairingHeap(t *testing.T) { 29 type test struct {
30 name string
31 args []*DistPayload
TestWithKey should call t.Parallel on the top level as well as its subtests
103 }
104}
105
106func TestWithKey(t *testing.T) {107 type T = credentials
108 type args struct {
109 key string
TestWithCert should call t.Parallel on the top level as well as its subtests
26 "github.com/vdaas/vald/internal/test/goleak"
27)
28
29func TestWithCert(t *testing.T) { 30 type T = credentials
31 type args struct {
32 cert string
TestWithInsecureSkipVerify should call t.Parallel on the top level as well as its subtests
338 }
339}
340
341func TestWithInsecureSkipVerify(t *testing.T) {342 type T = credentials
343 type args struct {
344 insecure bool
TestWithTLSConfig should call t.Parallel on the top level as well as its subtests
259 }
260}
261
262func TestWithTLSConfig(t *testing.T) {263 type T = credentials
264 type args struct {
265 cfg *tls.Config
TestWithCa should call t.Parallel on the top level as well as its subtests
181 }
182}
183
184func TestWithCa(t *testing.T) {185 type T = credentials
186 type args struct {
187 ca string
TestGenSameValueVec should call t.Parallel on the top level as well as its subtests
424 }
425}
426
427func TestGenSameValueVec(t *testing.T) { 428 type args struct {
429 size int
430 val float32
TestGenUint8Vec should call t.Parallel on the top level as well as its subtests
316 }
317}
318
319func TestGenUint8Vec(t *testing.T) { 320 type args struct {
321 dist Distribution
322 num int
TestGenF32Vec should call t.Parallel on the top level as well as its subtests
208 }
209}
210
211func TestGenF32Vec(t *testing.T) { 212 type args struct {
213 dist Distribution
214 num int
TestUint8VectorGenerator should call t.Parallel on the top level as well as its subtests
115 }
116}
117
118func TestUint8VectorGenerator(t *testing.T) { 119 type args struct {
120 d Distribution
121 n int
TestFloat32VectorGenerator should call t.Parallel on the top level as well as its subtests
22 "github.com/vdaas/vald/internal/test/goleak"
23)
24
25func TestFloat32VectorGenerator(t *testing.T) { 26 type args struct {
27 d Distribution
28 n int
TestConvertVectorsUint8ToFloat32 should call t.Parallel on the top level as well as its subtests
547 }
548}
549
550func TestConvertVectorsUint8ToFloat32(t *testing.T) { 551 type args struct {
552 vectors [][]uint8
553 }
TestRandom should call t.Parallel on the top level as well as its subtests
20 "github.com/vdaas/vald/internal/test/goleak"
21)
22
23func TestRandom(t *testing.T) {24 type args struct {
25 l int
26 }
TestGenMultiRemoveReq should call t.Parallel on the top level as well as its subtests
22 "github.com/vdaas/vald/internal/test/goleak"
23)
24
25func TestGenMultiRemoveReq(t *testing.T) { 26 type args struct {
27 num int
28 cfg *payload.Remove_Config
TestGenObjectStreamLocation should call t.Parallel on the top level as well as its subtests
151 }
152}
153
154func TestGenObjectStreamLocation(t *testing.T) {155 type args struct {
156 num int
157 name string
TestGenObjectLocations should call t.Parallel on the top level as well as its subtests
29 comparator.IgnoreUnexported(payload.Object_Location{}),
30}
31
32func TestGenObjectLocations(t *testing.T) { 33 type args struct {
34 num int
35 name string
TestGenSameVecMultiInsertReq should call t.Parallel on the top level as well as its subtests
243 }
244}
245
246func TestGenSameVecMultiInsertReq(t *testing.T) {247 type args struct {
248 num int
249 vec []float32
TestGenMultiInsertReq should call t.Parallel on the top level as well as its subtests
31 comparator.IgnoreUnexported(payload.Insert_Config{}),
32}
33
34func TestGenMultiInsertReq(t *testing.T) { 35 type args struct {
36 t ObjectType
37 dist vector.Distribution
TestJoin should call t.Parallel on the top level as well as its subtests
21 "github.com/vdaas/vald/internal/test/goleak"
22)
23
24func TestJoin(t *testing.T) { 25 type args struct {
26 elems []string
27 sep string
TestSortStableFunc should call t.Parallel on the top level as well as its subtests
189 }
190}
191
192func TestSortStableFunc(t *testing.T) {193 type args struct {
194 x []int
195 less func(left, right int) bool
TestSortFunc should call t.Parallel on the top level as well as its subtests
101 }
102}
103
104func TestSortFunc(t *testing.T) {105 type args struct {
106 x []int
107 less func(left, right int) bool
TestSort should call t.Parallel on the top level as well as its subtests
21 "github.com/vdaas/vald/internal/test/goleak"
22)
23
24func TestSort(t *testing.T) { 25 type args struct {
26 x []int
27 }
TestRemoveDuplicates should call t.Parallel on the top level as well as its subtests
277 }
278}
279
280func TestRemoveDuplicates(t *testing.T) {281 type args struct {
282 x []int
283 less func(left, right int) bool
TestFloat32 should call t.Parallel on the top level as well as its subtests
162 }
163}
164
165func TestFloat32(t *testing.T) {166 type want struct {
167 min float32
168 max float32
TestRouting's subtests should call t.Parallel
69 }
70}
71
72func TestRouting(t *testing.T) { 73 t.Parallel()
74 type args struct {
75 name string
Description
Using the t.Parallel() method can be tricky and ollowing are some common inappropriate
usages of t.Parallel
:
— t.Parallel()
is called in either a top-level test function or a sub-test function only
— t.Parallel()
is called in the sub-test function; it is post-processed by defer
instead of t.Cleanup()
Here's a good blog post explaining how t.Parallel
should be used.
The description of the Parallel()
method from Go's official documentation:
func (t *T) Parallel()
Parallel signals that this test is to be run in parallel with (and only
with) other parallel tests. When a test is run multiple times due to use of
-test.count or -test.cpu, multiple instances of a single test never run in
parallel with each other.
Bad practice
func Test_TB2(t *testing.T) {
teardown := setup("Test_TB2")
t.Cleanup(teardown)
t.Parallel() // "Test_TB2's subtests should call t.Parallel"
tests := []struct { name string }{
{ name: "TB2_Sub1" },
{ name: "TB2_Sub2" },
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
call(tt.name)
})
}
}
func Test_Func1(t *testing.T) {
teardown := setup("Test_Func1")
t.Cleanup(teardown)
// "Test_Func1 should call t.Parallel on the top level as well"
t.Run("Func1_Sub1", func(t *testing.T) {
call("Func1_Sub1")
t.Parallel()
})
t.Run("Func1_Sub2", func(t *testing.T) {
call("Func1_Sub2")
t.Parallel()
})
}
Recommended
func Test_TB2(t *testing.T) {
teardown := setup("Test_TB2")
t.Cleanup(teardown)
t.Parallel()
tests := []struct { name string }{
{ name: "TB2_Sub1" },
{ name: "TB2_Sub2" },
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
call(tt.name)
})
}
}
func Test_Func1(t *testing.T) {
teardown := setup("Test_Func1")
t.Cleanup(teardown)
t.Parallel()
t.Run("Func1_Sub1", func(t *testing.T) {
call("Func1_Sub1")
t.Parallel()
})
t.Run("Func1_Sub2", func(t *testing.T) {
call("Func1_Sub2")
t.Parallel()
})
}