test: fix two flaky tests (darwin start_time regex, memstats HeapReleased drift)#2050
Merged
bwplotka merged 2 commits intoJul 8, 2026
Merged
Conversation
TestDarwinProcessCollector asserted process_start_time_seconds against [0-9.]{10,}, but expfmt renders large gauge values in scientific notation (for example 1.783414e+09), whose leading digit run is shorter than ten characters. The check then fails intermittently on macOS depending on the process start time. Match a leading digit like the sibling metric checks, which asserts the metric is present with a numeric value.
Signed-off-by: Kemal Akkoyun <kemal.akkoyun@datadoghq.com>
…ed drift The test read runtime.ReadMemStats and runtime/metrics separately and compared them within 5%, with the code itself noting it hoped no GC ran in between. HeapReleased is driven by the background scavenger and drifted between the two reads, failing intermittently (seen on Linux arm64). Force a full scavenge with debug.FreeOSMemory and disable GC for the measurement window so both reads observe the same runtime state. Signed-off-by: Kemal Akkoyun <kemal.akkoyun@datadoghq.com>
Member
Author
|
Blocked by #2051 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two pre-existing flaky tests, each fixed independently.
Darwin
process_start_time_seconds(process_collector_darwin_test.go): the check used[0-9.]{10,}, but expfmt renders large gauges in scientific notation (e.g.1.783414e+09), whose leading digit run is only eight characters, so it failed intermittently on macOS. Changed to[0-9], matching the sibling checks in the same test; that is a presence check that does not depend on float formatting.TestMemStatsEquivalence(go_collector_latest_test.go): the test readruntime.ReadMemStatsandruntime/metricsseparately and compared them within 5%, and the code itself noted it hoped no GC happened in between.HeapReleasedis driven by the background scavenger and drifted between the two reads, failing on Linux arm64. It now forces a full scavenge withdebug.FreeOSMemoryand disables GC for the measurement window, so both reads observe the same runtime state.Test plan:
go test -race ./prometheus/...passes;TestMemStatsEquivalencerun 200 times with-raceis stable.