#19303·prometheus

CI: Fix flaky `TestStartupInterrupt` and `FuzzParseOpenMetric` timeouts on contended runners

Author: sarthaksarthak9Created Jul 31, 2026Updated Sep 23, 2026

1. TestStartupInterrupt

Location: cmd/prometheus/main_unix_test.go

Failure

Should be true
prometheus didn't start in the specified timeout

Root Cause

The test launches a real prometheus binary as a subprocess and polls:

http://localhost:<port>/graph

every 500 ms for 10 attempts (5 seconds total) before failing.

The test also uses t.Parallel(), so during go test -race ./... it competes with other tests for CPU time.

In the failing CI run, the environment reported:

GOMAXPROCS=4: CPU quota undefined

meaning the runner's cgroup CPU limit was not detected, increasing scheduling contention on shared runners.

A fixed 5-second startup budget for:

  • spawning the process,
  • initializing TSDB,
  • replaying WAL (if applicable), and
  • binding the HTTP listener

can occasionally be insufficient under -race on a heavily loaded CI runner, resulting in a timeout despite Prometheus functioning correctly.

Suggested Fix

Increase the startup polling budget to provide more headroom on contended CI runners, for example by:

  • increasing the number of polling attempts (e.g. from 10 to 20–30), or
  • increasing the overall timeout.

2. FuzzParseOpenMetric

Location: util/fuzzing/fuzz_test.go

Failure

context deadline exceeded

Root Cause

The failure is a timeout rather than a discovered crashing input.

Verification performed:

  • Running the fuzz target standalone locally completed successfully.
  • No crash reproducer exists under testdata/fuzz/, which Go would automatically generate if a failing input had been found.

During the failing CI run:

  • FuzzParseOpenMetric and FuzzParseMetricText both executed for approximately four minutes.
  • Both continued discovering new coverage until the end of execution.
  • One target completed just before the deadline and passed.
  • The other exceeded the deadline slightly and was terminated with context deadline exceeded.

This pattern is consistent with the overall test timeout being configured too close to the fuzzing duration (for example, -timeout=4m together with -fuzztime=4m), leaving little or no time for corpus write-out and cleanup after fuzzing completes.

Suggested Fix

Configure the overall test timeout to provide headroom beyond the fuzzing duration, for example:

bash
-fuzztime=4m
-timeout=5m

(or a larger timeout if appropriate).