From 6a8298b1372dbaa90d69573b23b4bbdc55eda8df Mon Sep 17 00:00:00 2001 From: Klaus Post Date: Wed, 15 Apr 2020 03:39:03 +0200 Subject: [PATCH] Reduce Mutex test runs (#9345) Some tests take a long time on CI: * `--- PASS: TestRWMutex (226.49s)` * ` --- PASS: TestRWMutex (7.13s)` Reduce the number of runs. Before/after locally: ``` --- PASS: TestRWMutex (20.95s) --- PASS: TestRWMutex (7.13s) --- PASS: TestMutex (3.01s) --- PASS: TestMutex (1.65s) ``` --- pkg/dsync/drwmutex_test.go | 2 +- pkg/dsync/dsync_test.go | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/pkg/dsync/drwmutex_test.go b/pkg/dsync/drwmutex_test.go index 065deccff..53dbd533e 100644 --- a/pkg/dsync/drwmutex_test.go +++ b/pkg/dsync/drwmutex_test.go @@ -240,7 +240,7 @@ func HammerRWMutex(gomaxprocs, numReaders, numIterations int) { // Borrowed from rwmutex_test.go func TestRWMutex(t *testing.T) { defer runtime.GOMAXPROCS(runtime.GOMAXPROCS(-1)) - n := 1000 + n := 100 if testing.Short() { n = 5 } diff --git a/pkg/dsync/dsync_test.go b/pkg/dsync/dsync_test.go index 95b53c462..ec5d4cebb 100644 --- a/pkg/dsync/dsync_test.go +++ b/pkg/dsync/dsync_test.go @@ -242,10 +242,14 @@ func HammerMutex(m *DRWMutex, loops int, cdone chan bool) { // Borrowed from mutex_test.go func TestMutex(t *testing.T) { + loops := 200 + if testing.Short() { + loops = 5 + } c := make(chan bool) m := NewDRWMutex(context.Background(), ds, "test") for i := 0; i < 10; i++ { - go HammerMutex(m, 1000, c) + go HammerMutex(m, loops, c) } for i := 0; i < 10; i++ { <-c