twqeak timeouts

Signed-off-by: Kristoffer Dalby <kristoffer@tailscale.com>
This commit is contained in:
Kristoffer Dalby 2024-09-23 10:48:50 +02:00
parent 031f1a2315
commit c1e0cbed49
No known key found for this signature in database

View File

@ -946,7 +946,7 @@ func promMetricLabelsStr(labels []*dto.LabelPair) string {
func TestUserMetrics(t *testing.T) { func TestUserMetrics(t *testing.T) {
flakytest.Mark(t, "https://github.com/tailscale/tailscale/issues/13420") flakytest.Mark(t, "https://github.com/tailscale/tailscale/issues/13420")
tstest.ResourceCheck(t) tstest.ResourceCheck(t)
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second) ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
defer cancel() defer cancel()
controlURL, c := startControl(t) controlURL, c := startControl(t)
@ -996,14 +996,6 @@ func TestUserMetrics(t *testing.T) {
mustDirect(t, t.Logf, lc1, lc2) 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 // Wait for the routes to be propagated to node 1 to ensure
// that the metrics are up-to-date. // that the metrics are up-to-date.
waitForCondition(t, "primary routes available for node1", 90*time.Second, func() bool { 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) t.Logf("getting status: %s", err)
return false return false
} }
// if runtime.GOOS == "windows" { t.Logf("status pr1: %v", status1.Self.PrimaryRoutes)
// return true t.Logf("status r1: %v", status1.Self.AllowedIPs.AsSlice())
// } else { return status1.Self.PrimaryRoutes != nil && status1.Self.PrimaryRoutes.Len() == 3
return status1.Self.PrimaryRoutes != nil && status1.Self.PrimaryRoutes.Len() == wantRoutes
// }
}) })
bytesToSend := 10 * 1024 * 1024 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()) t.Logf("Sent %d bytes from s1 to s2 in %s", bytesToSend, time.Since(start).String())
time.Sleep(5 * time.Second) ctxLc, cancelLc := context.WithTimeout(context.Background(), 5*time.Second)
defer cancelLc()
metrics1, err := lc1.UserMetrics(ctx) metrics1, err := lc1.UserMetrics(ctxLc)
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
status1, err := lc1.Status(ctx) status1, err := lc1.Status(ctxLc)
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
@ -1064,7 +1054,7 @@ func TestUserMetrics(t *testing.T) {
// - 192.0.2.0/24 // - 192.0.2.0/24
// - 192.0.5.1/32 // - 192.0.5.1/32
// - 0.0.0.0/0 // - 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) 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.2.0/24
// - 192.0.5.1/32 // - 192.0.5.1/32
// - 0.0.0.0/0 // - 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) t.Errorf("metrics1, tailscaled_primary_routes: got %v, want %v", got, want)
} }