From 55f9148331d13267e6902318e712965df84f0387 Mon Sep 17 00:00:00 2001 From: Jan Safranek Date: Fri, 20 May 2016 10:14:47 +0200 Subject: [PATCH] Increase goroutinemap unit test timeouts. 50ms is flaky in Jenkins. Fixes #25825 --- pkg/util/goroutinemap/goroutinemap_test.go | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/pkg/util/goroutinemap/goroutinemap_test.go b/pkg/util/goroutinemap/goroutinemap_test.go index 90b0603ed88..04d205c45de 100644 --- a/pkg/util/goroutinemap/goroutinemap_test.go +++ b/pkg/util/goroutinemap/goroutinemap_test.go @@ -24,6 +24,11 @@ import ( "k8s.io/kubernetes/pkg/util/wait" ) +// testTimeout is a timeout of goroutines to finish. This _should_ be just a +// "context switch" and it should take several ms, however, Clayton says "We +// have had flakes due to tests that assumed that 15s is long enough to sleep") +const testTimeout = 1 * time.Minute + func Test_NewGoRoutineMap_Positive_SingleOp(t *testing.T) { // Arrange grm := NewGoRoutineMap() @@ -210,8 +215,7 @@ func Test_NewGoRoutineMap_Positive_WaitEmpty(t *testing.T) { }() // Assert - // Tolerate 50 milliseconds for goroutine context switches etc. - err := waitChannelWithTimeout(waitDoneCh, 50*time.Millisecond) + err := waitChannelWithTimeout(waitDoneCh, testTimeout) if err != nil { t.Errorf("Error waiting for GoRoutineMap.Wait: %v", err) } @@ -236,18 +240,11 @@ func Test_NewGoRoutineMap_Positive_Wait(t *testing.T) { waitDoneCh <- true }() - // Assert - // Check that Wait() really blocks - err = waitChannelWithTimeout(waitDoneCh, 100*time.Millisecond) - if err == nil { - t.Fatalf("Expected Wait() to block but it returned early") - } - // Finish the operation operation1DoneCh <- true - // check that Wait() finishes in reasonable time - err = waitChannelWithTimeout(waitDoneCh, 50*time.Millisecond) + // Assert + err = waitChannelWithTimeout(waitDoneCh, testTimeout) if err != nil { t.Fatalf("Error waiting for GoRoutineMap.Wait: %v", err) }