From 9d9fe3306746748d88270948beb4806a0e77223c Mon Sep 17 00:00:00 2001 From: Akihiro Suda Date: Wed, 25 May 2016 06:21:26 +0000 Subject: [PATCH] Fix a race in pkg/integration.TestChannelBufferTimeout Update #22965 Signed-off-by: Akihiro Suda --- integration/utils_test.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/integration/utils_test.go b/integration/utils_test.go index 8ebdb14..b354ab9 100644 --- a/integration/utils_test.go +++ b/integration/utils_test.go @@ -510,9 +510,11 @@ func TestChannelBufferTimeout(t *testing.T) { buf := &ChannelBuffer{make(chan []byte, 1)} defer buf.Close() + done := make(chan struct{}, 1) go func() { time.Sleep(100 * time.Millisecond) io.Copy(buf, strings.NewReader(expected)) + done <- struct{}{} }() // Wait long enough @@ -521,9 +523,7 @@ func TestChannelBufferTimeout(t *testing.T) { if err == nil && err.Error() != "timeout reading from channel" { t.Fatalf("Expected an error, got %s", err) } - - // Wait for the end :) - time.Sleep(150 * time.Millisecond) + <-done } func TestChannelBuffer(t *testing.T) {