Commit 47a372bc authored by k8s-merge-robot's avatar k8s-merge-robot

Merge pull request #25955 from jsafrane/flake-op-timeout

Automatic merge from submit-queue Increase goroutinemap unit test timeouts. 50ms is flaky in Jenkins. This makes the test to take at least 0.5s to check that things that should block and wait for something really do block and wait (was 100ms before). Fixes #25825
parents 6a1abc15 55f91483
...@@ -24,6 +24,11 @@ import ( ...@@ -24,6 +24,11 @@ import (
"k8s.io/kubernetes/pkg/util/wait" "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) { func Test_NewGoRoutineMap_Positive_SingleOp(t *testing.T) {
// Arrange // Arrange
grm := NewGoRoutineMap() grm := NewGoRoutineMap()
...@@ -210,8 +215,7 @@ func Test_NewGoRoutineMap_Positive_WaitEmpty(t *testing.T) { ...@@ -210,8 +215,7 @@ func Test_NewGoRoutineMap_Positive_WaitEmpty(t *testing.T) {
}() }()
// Assert // Assert
// Tolerate 50 milliseconds for goroutine context switches etc. err := waitChannelWithTimeout(waitDoneCh, testTimeout)
err := waitChannelWithTimeout(waitDoneCh, 50*time.Millisecond)
if err != nil { if err != nil {
t.Errorf("Error waiting for GoRoutineMap.Wait: %v", err) t.Errorf("Error waiting for GoRoutineMap.Wait: %v", err)
} }
...@@ -236,18 +240,11 @@ func Test_NewGoRoutineMap_Positive_Wait(t *testing.T) { ...@@ -236,18 +240,11 @@ func Test_NewGoRoutineMap_Positive_Wait(t *testing.T) {
waitDoneCh <- true 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 // Finish the operation
operation1DoneCh <- true operation1DoneCh <- true
// check that Wait() finishes in reasonable time // Assert
err = waitChannelWithTimeout(waitDoneCh, 50*time.Millisecond) err = waitChannelWithTimeout(waitDoneCh, testTimeout)
if err != nil { if err != nil {
t.Fatalf("Error waiting for GoRoutineMap.Wait: %v", err) t.Fatalf("Error waiting for GoRoutineMap.Wait: %v", err)
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment