Test_run_Start should call t.Parallel on the top level as well as its subtests
234 }
235}
236
237func Test_run_Start(t *testing.T) {238 type args struct {
239 ctx context.Context
240 }
Test_run_PostStop should call t.Parallel on the top level as well as its subtests
580 }
581}
582
583func Test_run_PostStop(t *testing.T) {584 type args struct {
585 in0 context.Context
586 }
Test_run_PreStart should call t.Parallel on the top level as well as its subtests
120 }
121}
122
123func Test_run_PreStart(t *testing.T) {124 type args struct {
125 ctx context.Context
126 }
Test_run_PreStop should call t.Parallel on the top level as well as its subtests
352 }
353}
354
355func Test_run_PreStop(t *testing.T) {356 type args struct {
357 in0 context.Context
358 }
Test_run_Stop should call t.Parallel on the top level as well as its subtests
466 }
467}
468
469func Test_run_Stop(t *testing.T) {470 type args struct {
471 ctx context.Context
472 }
TestNew should call t.Parallel on the top level as well as its subtests
31 "github.com/vdaas/vald/pkg/manager/index/service"
32)
33
34func TestNew(t *testing.T) { 35 type args struct {
36 cfg *config.Data
37 }
TestWithIndexingDuration should call t.Parallel on the top level as well as its subtests
112 }
113}
114
115func TestWithIndexingDuration(t *testing.T) {116 type args struct {
117 dur string
118 }
TestWithSaveIndexDurationLimit should call t.Parallel on the top level as well as its subtests
282 }
283}
284
285func TestWithSaveIndexDurationLimit(t *testing.T) {286 type args struct {
287 dur string
288 }
TestWithMinUncommitted should call t.Parallel on the top level as well as its subtests
452 }
453}
454
455func TestWithMinUncommitted(t *testing.T) {456 type args struct {
457 n uint32
458 }
TestWithCreationPoolSize should call t.Parallel on the top level as well as its subtests
537 }
538}
539
540func TestWithCreationPoolSize(t *testing.T) {541 type args struct {
542 size uint32
543 }
TestWithErrGroup should call t.Parallel on the top level as well as its subtests
707 }
708}
709
710func TestWithErrGroup(t *testing.T) {711 type args struct {
712 eg errgroup.Group
713 }
TestWithIndexingConcurrency should call t.Parallel on the top level as well as its subtests
27 "github.com/vdaas/vald/internal/test/goleak"
28)
29
30func TestWithIndexingConcurrency(t *testing.T) { 31 type args struct {
32 c int
33 }
TestWithDiscoverer should call t.Parallel on the top level as well as its subtests
622 }
623}
624
625func TestWithDiscoverer(t *testing.T) {626 type args struct {
627 c discoverer.Client
628 }
TestWithSaveIndexWaitDuration should call t.Parallel on the top level as well as its subtests
367 }
368}
369
370func TestWithSaveIndexWaitDuration(t *testing.T) {371 type args struct {
372 dur string
373 }
TestWithIndexingDurationLimit should call t.Parallel on the top level as well as its subtests
197 }
198}
199
200func TestWithIndexingDurationLimit(t *testing.T) {201 type args struct {
202 dur string
203 }
Test_indexInfos_Range should call t.Parallel on the top level as well as its subtests
886 }
887}
888
889func Test_indexInfos_Range(t *testing.T) { 890 type args struct {
891 f func(key string, value *payload.Info_Index_Count) bool
892 }
Test_indexInfos_Store should call t.Parallel on the top level as well as its subtests
314 }
315}
316
317func Test_indexInfos_Store(t *testing.T) { 318 type args struct {
319 key string
320 value *payload.Info_Index_Count
Test_newEntryIndexInfos should call t.Parallel on the top level as well as its subtests
27 "github.com/vdaas/vald/internal/test/goleak"
28)
29
30func Test_newEntryIndexInfos(t *testing.T) { 31 type args struct {
32 i *payload.Info_Index_Count
33 }
Test_indexInfos_dirtyLocked should call t.Parallel on the top level as well as its subtests
1078 }
1079}
1080
1081func Test_indexInfos_dirtyLocked(t *testing.T) {1082 type fields struct {
1083 read atomic.Value
1084 dirty map[string]*entryIndexInfos
Test_indexInfos_Load should call t.Parallel on the top level as well as its subtests
112 }
113}
114
115func Test_indexInfos_Load(t *testing.T) { 116 type args struct {
117 key string
118 }
Test_entryIndexInfos_storeLocked should call t.Parallel on the top level as well as its subtests
604 }
605}
606
607func Test_entryIndexInfos_storeLocked(t *testing.T) { 608 type args struct {
609 i **payload.Info_Index_Count
610 }
Test_indexInfos_Delete should call t.Parallel on the top level as well as its subtests
697 }
698}
699
700func Test_indexInfos_Delete(t *testing.T) { 701 type args struct {
702 key string
703 }
Test_entryIndexInfos_delete should call t.Parallel on the top level as well as its subtests
798 }
799}
800
801func Test_entryIndexInfos_delete(t *testing.T) { 802 type fields struct {
803 p unsafe.Pointer
804 }
Test_entryIndexInfos_unexpungeLocked should call t.Parallel on the top level as well as its subtests
516 }
517}
518
519func Test_entryIndexInfos_unexpungeLocked(t *testing.T) { 520 type fields struct {
521 p unsafe.Pointer
522 }
Test_entryIndexInfos_load should call t.Parallel on the top level as well as its subtests
222 }
223}
224
225func Test_entryIndexInfos_load(t *testing.T) { 226 type fields struct {
227 p unsafe.Pointer
228 }
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()
})
}