Fix a race in pkg/integration.TestChannelBufferTimeout

Update #22965

Signed-off-by: Akihiro Suda <suda.akihiro@lab.ntt.co.jp>
Upstream-commit: d0d828e292733fa1d5e2d09d7f184be69129e757
Component: engine
This commit is contained in:
Akihiro Suda
2016-05-25 07:09:38 +00:00
parent 6373766983
commit a4084df811
@@ -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) {