tstest/natlab: be a bit more lenient during test shutdown.

There is a race in natlab where we might start shutdown while natlab is still running
a goroutine or two to deliver packets. This adds a small grace period to try and receive
it before continuing shutdown.

Signed-off-by: David Anderson <danderson@tailscale.com>
reviewable/pr609/r1
David Anderson 4 years ago committed by Dave Anderson
parent 7578c815be
commit c3958898f1

@ -732,6 +732,14 @@ func newPinger(t *testing.T, logf logger.Logf, srcM, dstM *magicStack, srcIP, ds
t.Errorf("timed out waiting for ping to transit")
return true
case <-ctx.Done():
// Try a little bit longer to consume the packet we're
// waiting for. This is to deal with shutdown races, where
// natlab may still be delivering a packet to us from a
// goroutine.
select {
case <-dstM.tun.Inbound:
case <-time.After(time.Second):
}
return false
}
}
@ -763,7 +771,6 @@ func testActiveDiscovery(t *testing.T, d *devices) {
tstest.PanicOnLog()
rc := tstest.NewResourceCheck()
defer rc.Assert(t)
defer natlab.WaitIdle()
tlogf, setT := makeNestable(t)
setT(t)

Loading…
Cancel
Save