From c1e0cbed494c0441b5cc9eaf8deb236af2939bd7 Mon Sep 17 00:00:00 2001 From: Kristoffer Dalby Date: Mon, 23 Sep 2024 10:48:50 +0200 Subject: [PATCH] twqeak timeouts Signed-off-by: Kristoffer Dalby --- tsnet/tsnet_test.go | 30 ++++++++++-------------------- 1 file changed, 10 insertions(+), 20 deletions(-) diff --git a/tsnet/tsnet_test.go b/tsnet/tsnet_test.go index bcb5377e9..e82bfd9f3 100644 --- a/tsnet/tsnet_test.go +++ b/tsnet/tsnet_test.go @@ -946,7 +946,7 @@ func promMetricLabelsStr(labels []*dto.LabelPair) string { func TestUserMetrics(t *testing.T) { flakytest.Mark(t, "https://github.com/tailscale/tailscale/issues/13420") tstest.ResourceCheck(t) - ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second) + ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second) defer cancel() controlURL, c := startControl(t) @@ -996,14 +996,6 @@ func TestUserMetrics(t *testing.T) { mustDirect(t, t.Logf, lc1, lc2) - wantRoutes := 3 - // if runtime.GOOS == "windows" { - // // Windows doesn't support the being a subnet router - // // in userspace mode (tsnet), so the routes are not - // // set. - // wantRoutes = 0 - // } - // Wait for the routes to be propagated to node 1 to ensure // that the metrics are up-to-date. waitForCondition(t, "primary routes available for node1", 90*time.Second, func() bool { @@ -1014,11 +1006,9 @@ func TestUserMetrics(t *testing.T) { t.Logf("getting status: %s", err) return false } - // if runtime.GOOS == "windows" { - // return true - // } else { - return status1.Self.PrimaryRoutes != nil && status1.Self.PrimaryRoutes.Len() == wantRoutes - // } + t.Logf("status pr1: %v", status1.Self.PrimaryRoutes) + t.Logf("status r1: %v", status1.Self.AllowedIPs.AsSlice()) + return status1.Self.PrimaryRoutes != nil && status1.Self.PrimaryRoutes.Len() == 3 }) bytesToSend := 10 * 1024 * 1024 @@ -1032,14 +1022,14 @@ func TestUserMetrics(t *testing.T) { } t.Logf("Sent %d bytes from s1 to s2 in %s", bytesToSend, time.Since(start).String()) - time.Sleep(5 * time.Second) - - metrics1, err := lc1.UserMetrics(ctx) + ctxLc, cancelLc := context.WithTimeout(context.Background(), 5*time.Second) + defer cancelLc() + metrics1, err := lc1.UserMetrics(ctxLc) if err != nil { t.Fatal(err) } - status1, err := lc1.Status(ctx) + status1, err := lc1.Status(ctxLc) if err != nil { t.Fatal(err) } @@ -1064,7 +1054,7 @@ func TestUserMetrics(t *testing.T) { // - 192.0.2.0/24 // - 192.0.5.1/32 // - 0.0.0.0/0 - if got, want := parsedMetrics1["tailscaled_approved_routes,"], float64(wantRoutes); got != want { + if got, want := parsedMetrics1["tailscaled_approved_routes,"], 3.0; got != want { t.Errorf("metrics1, tailscaled_approved_routes: got %v, want %v", got, want) } @@ -1077,7 +1067,7 @@ func TestUserMetrics(t *testing.T) { // - 192.0.2.0/24 // - 192.0.5.1/32 // - 0.0.0.0/0 - if got, want := parsedMetrics1["tailscaled_primary_routes,"], float64(wantRoutes); got != want { + if got, want := parsedMetrics1["tailscaled_primary_routes,"], 3.0; got != want { t.Errorf("metrics1, tailscaled_primary_routes: got %v, want %v", got, want) }