From c3cee7f5a433708a394cee4e89c223f80036f5d9 Mon Sep 17 00:00:00 2001 From: Andrei Vagin Date: Wed, 18 Mar 2020 17:41:06 -0700 Subject: Deflake third_party/gvisor/pkg/gate/gate_test TestConcurrentAll executes 1000 goroutines which never sleep, so they are not preempted by Go's runtime. In Go 1.14, async preemption has been added, but the added runtime.Gosched() call will do nothing wrong in this case too. PiperOrigin-RevId: 301705712 --- pkg/gate/gate_test.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pkg/gate/gate_test.go b/pkg/gate/gate_test.go index 850693df8..316015e06 100644 --- a/pkg/gate/gate_test.go +++ b/pkg/gate/gate_test.go @@ -15,6 +15,7 @@ package gate_test import ( + "runtime" "testing" "time" @@ -165,6 +166,8 @@ func worker(g *gate.Gate, done *sync.WaitGroup) { if !g.Enter() { break } + // Golang before v1.14 doesn't preempt busyloops. + runtime.Gosched() g.Leave() } done.Done() -- cgit v1.2.3