aboutsummaryrefslogtreecommitdiff
path: root/weed/wdclient/vid_map_test.go
diff options
context:
space:
mode:
authorLHHDZ <changlin.shi@ly.com>2022-07-22 17:54:57 +0800
committerLHHDZ <changlin.shi@ly.com>2022-07-22 17:54:57 +0800
commit994a2dec78bcc0beaf9d643a96b98c9d17bd22b5 (patch)
treed7d816d94868f045f9a0690c18231c47f950ae5f /weed/wdclient/vid_map_test.go
parent58c02d6429530d674d4e0e493e9e1a860208017e (diff)
downloadseaweedfs-994a2dec78bcc0beaf9d643a96b98c9d17bd22b5.tar.xz
seaweedfs-994a2dec78bcc0beaf9d643a96b98c9d17bd22b5.zip
fix `vid_map_test` tests
Diffstat (limited to 'weed/wdclient/vid_map_test.go')
-rw-r--r--weed/wdclient/vid_map_test.go26
1 files changed, 16 insertions, 10 deletions
diff --git a/weed/wdclient/vid_map_test.go b/weed/wdclient/vid_map_test.go
index 76746e948..b1cd24490 100644
--- a/weed/wdclient/vid_map_test.go
+++ b/weed/wdclient/vid_map_test.go
@@ -4,6 +4,7 @@ import (
"fmt"
"google.golang.org/grpc"
"strconv"
+ "sync"
"testing"
)
@@ -112,18 +113,23 @@ func TestLookupFileId(t *testing.T) {
}
//lock: concurrent test
- go func() {
- for i := 0; i < 100; i++ {
- mc.addLocation(uint32(i), Location{})
- }
- }()
- for i := 0; i < 10; i++ {
- for i := 0; i < 100; i++ {
- for i := 0; i < 20; i++ {
- _, _ = mc.GetLocations(uint32(i))
+ var wg sync.WaitGroup
+ for i := 0; i < 20; i++ {
+ wg.Add(1)
+ go func() {
+ defer wg.Done()
+ for i := 0; i < 100; i++ {
+ for i := 0; i < 20; i++ {
+ _, _ = mc.GetLocations(uint32(i))
+ }
}
- }
+ }()
+ }
+
+ for i := 0; i < 100; i++ {
+ mc.addLocation(uint32(i), Location{})
}
+ wg.Wait()
}
func BenchmarkLocationIndex(b *testing.B) {