1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Fix a race in pkg/integration.TestChannelBufferTimeout

Update #22965

Signed-off-by: Akihiro Suda <suda.akihiro@lab.ntt.co.jp>
This commit is contained in:
Akihiro Suda 2016-05-25 06:21:26 +00:00
parent 29dbcbad87
commit d0d828e292

View file

@ -510,9 +510,11 @@ func TestChannelBufferTimeout(t *testing.T) {
buf := &ChannelBuffer{make(chan []byte, 1)} buf := &ChannelBuffer{make(chan []byte, 1)}
defer buf.Close() defer buf.Close()
done := make(chan struct{}, 1)
go func() { go func() {
time.Sleep(100 * time.Millisecond) time.Sleep(100 * time.Millisecond)
io.Copy(buf, strings.NewReader(expected)) io.Copy(buf, strings.NewReader(expected))
done <- struct{}{}
}() }()
// Wait long enough // Wait long enough
@ -521,9 +523,7 @@ func TestChannelBufferTimeout(t *testing.T) {
if err == nil && err.Error() != "timeout reading from channel" { if err == nil && err.Error() != "timeout reading from channel" {
t.Fatalf("Expected an error, got %s", err) t.Fatalf("Expected an error, got %s", err)
} }
<-done
// Wait for the end :)
time.Sleep(150 * time.Millisecond)
} }
func TestChannelBuffer(t *testing.T) { func TestChannelBuffer(t *testing.T) {