From 0b62f26349308d2a05150943c2f6ad56bd20b7af Mon Sep 17 00:00:00 2001 From: David Crawshaw Date: Fri, 22 Oct 2021 10:17:53 -0700 Subject: [PATCH] magicsock: remove test data race Speculative, I haven't been able to replicate it locally. Fixes #3156 Signed-off-by: David Crawshaw --- wgengine/magicsock/magicsock_test.go | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/wgengine/magicsock/magicsock_test.go b/wgengine/magicsock/magicsock_test.go index f075a9063..486af23be 100644 --- a/wgengine/magicsock/magicsock_test.go +++ b/wgengine/magicsock/magicsock_test.go @@ -51,6 +51,13 @@ import ( func init() { os.Setenv("IN_TS_TEST", "1") + + // Some of these tests lose a disco pong before establishing a + // direct connection, so instead of waiting 5 seconds in the + // test, reduce the wait period. + // (In particular, TestActiveDiscovery.) + discoPingInterval = 100 * time.Millisecond + pingTimeoutDuration = 100 * time.Millisecond } // WaitReady waits until the magicsock is entirely initialized and connected @@ -743,18 +750,6 @@ func TestActiveDiscovery(t *testing.T) { testActiveDiscovery(t, n) }) - // The following tests lose a disco pong before establishing a - // direct connection, so instead of waiting 5 seconds in the - // test, reduce the wait period. - origPingTimeoutDuration := pingTimeoutDuration - origDiscoPingInterval := discoPingInterval - discoPingInterval = 100 * time.Millisecond - pingTimeoutDuration = 100 * time.Millisecond - defer func() { - pingTimeoutDuration = origPingTimeoutDuration - discoPingInterval = origDiscoPingInterval - }() - t.Run("facing_easy_firewalls", func(t *testing.T) { mstun := &natlab.Machine{Name: "stun"} m1 := &natlab.Machine{