From 09e81b8ba1dfd76607b12b373384249f4fae3ee9 Mon Sep 17 00:00:00 2001 From: Christine Dodrill Date: Thu, 15 Jul 2021 09:59:18 -0400 Subject: [PATCH] tstest/integration/vms: deflake the tailscale_status test (#2427) This test used to try to run this only once, but this variant of the test attempts to run `tailscale status` up to 6 times in a loop with exponential backoff. This fixes the flakiness found in previous instances of this test. Signed-off-by: Christine Dodrill --- tstest/integration/vms/vms_test.go | 31 +++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/tstest/integration/vms/vms_test.go b/tstest/integration/vms/vms_test.go index 95d561908..1ee4b5951 100644 --- a/tstest/integration/vms/vms_test.go +++ b/tstest/integration/vms/vms_test.go @@ -449,11 +449,32 @@ func (h Harness) testDistro(t *testing.T, d Distro, ipm ipMapping) { }) t.Run("tailscale status", func(t *testing.T) { - runTestCommands(t, timeout, cli, []expect.Batcher{ - &expect.BSnd{S: "sleep 5 && tailscale status\n"}, - &expect.BExp{R: `100.64.0.1`}, - &expect.BExp{R: `(\#)`}, - }) + dur := 100 * time.Millisecond + var outp []byte + var err error + + // NOTE(Xe): retry `tailscale status` a few times until it works. When tailscaled + // starts with testcontrol sometimes there can be up to a few seconds where + // tailscaled is in an unknown state on these virtual machines. This exponential + // delay loop should delay long enough for tailscaled to be ready. + for count := 0; count < 10; count++ { + sess := getSession(t, cli) + + outp, err = sess.CombinedOutput("tailscale status") + if err == nil { + if !strings.Contains(string(outp), "100.64.0.1") { + t.Log(string(outp)) + t.Fatal("can't find tester IP") + } + + return + } + time.Sleep(dur) + dur = dur * 2 + } + + t.Log(string(outp)) + t.Fatalf("error: %v", err) }) t.Run("dump routes", func(t *testing.T) {