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>
This commit is contained in:
David Anderson 2020-07-27 19:46:34 +00:00 committed by Dave Anderson
parent 7578c815be
commit c3958898f1

View File

@ -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)