From 082cc1b0a720dec9345914d08a275947cb5fd78a Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Tue, 15 Jun 2021 12:41:06 -0700 Subject: [PATCH] tstest/integration: reenable TestAddPingRequest Failure understood now; see: https://github.com/tailscale/tailscale/pull/2088#issuecomment-859896598 As of 333e9e75d40dd1787e69ac281f393f8cd151e451, PingRequest is now safe for the server to send multiple times, without fear of the client handling it multiple times. Fixes #2079 Signed-off-by: Brad Fitzpatrick --- tstest/integration/integration_test.go | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/tstest/integration/integration_test.go b/tstest/integration/integration_test.go index e51834229..4c38752eb 100644 --- a/tstest/integration/integration_test.go +++ b/tstest/integration/integration_test.go @@ -230,7 +230,6 @@ func TestNodeAddressIPFields(t *testing.T) { } func TestAddPingRequest(t *testing.T) { - t.Skip("flaky in CI, tailscale/issues/2079") t.Parallel() bins := BuildTestBinaries(t) @@ -257,28 +256,34 @@ func TestAddPingRequest(t *testing.T) { } nodeKey := nodes[0].Key - for i := 0; i < 10; i++ { - t.Logf("ping %v ...", i) + + // Check that we get at least one ping reply after 10 tries. + for try := 1; try <= 10; try++ { + t.Logf("ping %v ...", try) ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) if err := env.Control.AwaitNodeInMapRequest(ctx, nodeKey); err != nil { t.Fatal(err) } cancel() - pr := &tailcfg.PingRequest{URL: fmt.Sprintf("%s/ping-%d", waitPing.URL, i), Log: true} - ok := env.Control.AddPingRequest(nodeKey, pr) - if !ok { - t.Fatalf("no node found with NodeKey %v in AddPingRequest", nodeKey) + + pr := &tailcfg.PingRequest{URL: fmt.Sprintf("%s/ping-%d", waitPing.URL, try), Log: true} + if !env.Control.AddPingRequest(nodeKey, pr) { + t.Logf("failed to AddPingRequest") + continue } // Wait for PingRequest to come back pingTimeout := time.NewTimer(2 * time.Second) + defer pingTimeout.Stop() select { case <-gotPing: - pingTimeout.Stop() + t.Logf("got ping; success") + return case <-pingTimeout.C: - t.Fatal("didn't get PingRequest from tailscaled") + // Try again. } } + t.Error("all ping attempts failed") } // testEnv contains the test environment (set of servers) used by one