فهرست منبع

Merge pull request #22973 from AkihiroSuda/fix22965IntegrationRace

Fix a race in pkg/integration.TestChannelBufferTimeout
Brian Goff 9 سال پیش
والد
کامیت
53e2deb159
1فایلهای تغییر یافته به همراه3 افزوده شده و 3 حذف شده
  1. 3 3
      pkg/integration/utils_test.go

+ 3 - 3
pkg/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) {