Skip to content

fix(test): fix timing flakes in ChronometerTest and ThroughputControlTestCase#678

Merged
ar merged 1 commit intomainfrom
fix/timing-flakes
Mar 13, 2026
Merged

fix(test): fix timing flakes in ChronometerTest and ThroughputControlTestCase#678
ar merged 1 commit intomainfrom
fix/timing-flakes

Conversation

@ar-agt
Copy link
Collaborator

@ar-agt ar-agt commented Mar 13, 2026

ChronometerTest

  • Add @BeforeAll warmUp() — 5 × sleep(20) + elapsed()/lap() iterations to prime JVM timer threads before assertions run
  • Increase TOLERANCE 200 ms → 1000 ms to absorb OS scheduler jitter when running under a loaded full-suite build; still reliably catches real bugs (elapsed returning 0, wrong units, negative values, etc.)

Root cause: Thread.sleep(25) measured 300–440 ms on a cold JVM due to timer-thread initialisation. Warmup alone is insufficient under full test-suite load (parallel worker contention), hence the wider ceiling.

ThroughputControlTestCase.testFifty

  • Widen upper bound 4500 ms → 6000 ms

The minimum (4000 ms for 10 tps × 50 tx) is deterministic; the 500 ms ceiling was too tight on a loaded machine (failed at 4586 ms).

…TestCase

ChronometerTest:
- Add @BeforeAll warmUp() (5 × sleep(20) iterations) to prime JVM timer
  threads before the actual assertions run
- Increase TOLERANCE 200ms → 1000ms to absorb OS scheduler jitter when
  running the full suite under load; still reliably catches real bugs
  (elapsed returning 0, wrong units, negative values, etc.)

ThroughputControlTestCase.testFifty:
- Widen upper bound 4500ms → 6000ms; 10 tps × 50 tx guarantees exactly
  4000ms minimum but the 500ms ceiling was too tight on a loaded machine
  (failed at 4586ms)
@ar ar merged commit 667151b into main Mar 13, 2026
2 of 4 checks passed
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.

2 participants