tests: capture the over-budget warning from the cold view on
Under -race the cold app-page view can itself go over budget, and the warning is once a minute per route, so capturing only from the warm view missed it. The log is captured before the cold view and each screen is held to exactly one warning.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 file changed,
+12
−11
internal/console/perflatency_test.go+12 −11
CI failed — run details
diff --git a/internal/console/perflatency_test.go b/internal/console/perflatency_test.go| index b6ed92231..877b6e886 100644 |
| --- a/internal/console/perflatency_test.go |
| +++ b/internal/console/perflatency_test.go |
| @@ -187,6 +187,16 @@ func TestFixtureOverTheS3FakeServesAppPage(t *testing.T) { |
| return s1 - s0, pageCalls() - p0, fx.srv.PerfBackground()["s3"] - b0, h1 - h0 |
| } |
| + // With the delays on the views go over budget, and the console says |
| + // so in its log: capture the lines rather than let them reach the |
| + // test's output, and hold them to the screens. Captured from the cold |
| + // view on: under -race even that one can go over, and the warning is |
| + // once a minute per route, so whichever view crossed first logged it. |
| + logs := &syncBuffer{} |
| + prev := log.Writer() |
| + log.SetOutput(logs) |
| + t.Cleanup(func() { log.SetOutput(prev) }) |
| + |
| fake, sample, background, host := view() |
| if fake <= 0 { |
| t.Fatalf("the app page made %d S3 requests, want some (is the server on the fake?)", fake) |
| @@ -198,14 +208,6 @@ func TestFixtureOverTheS3FakeServesAppPage(t *testing.T) { |
| t.Errorf("the app page made %d app-host calls, want none", host) |
| } |
| - // With the delays on the views go over budget, and the console says |
| - // so in its log: capture the lines rather than let them reach the |
| - // test's output, and hold them to the screens. |
| - logs := &syncBuffer{} |
| - prev := log.Writer() |
| - log.SetOutput(logs) |
| - t.Cleanup(func() { log.SetOutput(prev) }) |
| - |
| lat.Enable(true) |
| start := time.Now() |
| fake, sample, background, _ = view() |
| @@ -231,11 +233,10 @@ func TestFixtureOverTheS3FakeServesAppPage(t *testing.T) { |
| for _, want := range []string{`screen="GET /a/{sqid}/apps/{app}"`, `screen="GET /a/{sqid}/apps/{app}/instances"`} { |
| if !logs.waitFor(want, 2*time.Second) { |
| t.Errorf("no over-budget warning for %s; log:\n%s", want, logs.String()) |
| + } else if n := strings.Count(logs.String(), want+" "); n != 1 { |
| + t.Errorf("over-budget warnings for %s = %d, want 1 (once a minute per route); log:\n%s", want, n, logs.String()) |
| } |
| } |
| - if n := strings.Count(logs.String(), "request over performance budget"); n != 2 { |
| - t.Errorf("over-budget warnings = %d, want 2 (one per screen); log:\n%s", n, logs.String()) |
| - } |
| } |
| // syncBuffer is a log destination a test can read while the server writes. |