Skip to content

fix: stabilize flaky timer and thread count tests#1973

Open
zeitlinger wants to merge 1 commit intomainfrom
fix/flaky-tests
Open

fix: stabilize flaky timer and thread count tests#1973
zeitlinger wants to merge 1 commit intomainfrom
fix/flaky-tests

Conversation

@zeitlinger
Copy link
Member

Summary

  • GaugeTest.testTimer: Thread.sleep(12) can take 100ms+ on CI.
    Assert > 10ms instead of closeTo(12ms, 5ms)
  • JvmThreadsMetricsTest.testInvalidThreadIds: background threads
    can start between scrapes. Assert only that UNKNOWN count increased
    by the expected amount, ignore other states

Fixes #1971, fixes #1972

Test plan

  • Both tests pass locally
  • mise run build passes
  • CI passes

GaugeTest.testTimer: Thread.sleep(12) can take 100ms+ on CI due to
scheduling delays. Assert only that the timer measured > 10ms, not
that it's close to exactly 12ms.

JvmThreadsMetricsTest.testInvalidThreadIds: background threads can
start between scrapes, changing counts for arbitrary states. Assert
only that the UNKNOWN count increased by the expected amount.

Fixes #1971, fixes #1972

Signed-off-by: Gregor Zeitlinger <gregor.zeitlinger@grafana.com>
@zeitlinger zeitlinger marked this pull request as ready for review March 19, 2026 18:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Flaky test: GaugeTest.testTimer on Java 25 Flaky test: JvmThreadsMetricsTest.testInvalidThreadIds

1 participant