From 3759fb8987590c9023de4de646c2c6f46581a0d6 Mon Sep 17 00:00:00 2001 From: Josh Bleecher Snyder Date: Mon, 13 Sep 2021 15:17:05 -0700 Subject: [PATCH] derp: deflake TestSendFreeze On about 1 out of 500 runs, TestSendFreeze failed: derp_test.go:416: bob: unexpected message type derp.PeerGoneMessage Closing alice before bob created a race. If bob closed promptly, the test passed. If bob closed slowly, and alice's disappearance caused bob to receive a PeerGoneMessage before closing, the test failed. Deflake the test by closing bob first. With this fix, the test passed 12,000 times locally. Fixes #2668 Signed-off-by: Josh Bleecher Snyder --- derp/derp_test.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/derp/derp_test.go b/derp/derp_test.go index c94c36217..7219d762e 100644 --- a/derp/derp_test.go +++ b/derp/derp_test.go @@ -403,8 +403,11 @@ func TestSendFreeze(t *testing.T) { t.Logf("TEST COMPLETE, cancelling sender") cancel() t.Logf("closing connections") - aliceConn.Close() + // Close bob before alice. + // Starting with alice can cause a PeerGoneMessage to reach + // bob before bob is closed, causing a test flake (issue 2668). bobConn.Close() + aliceConn.Close() cathyConn.Close() for i := 0; i < cap(errCh); i++ {