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) {
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)
}