Skip to content

Replace Thread.sleep and Testing.whileTimeout with Awaitility in tests#8455

Merged
rzo1 merged 1 commit intoapache:masterfrom
DigitalPebble:replace-thread-sleep-with-awaitility
Mar 30, 2026
Merged

Replace Thread.sleep and Testing.whileTimeout with Awaitility in tests#8455
rzo1 merged 1 commit intoapache:masterfrom
DigitalPebble:replace-thread-sleep-with-awaitility

Conversation

@jnioche
Copy link
Copy Markdown
Contributor

@jnioche jnioche commented Mar 30, 2026

Summary

  • Replace hand-rolled Thread.sleep polling loops and Testing.whileTimeout calls with Awaitility across 6 test files
  • Async waits now exit as soon as the condition is met instead of sleeping for a fixed duration, improving both test speed and reliability on slow CI machines

Files changed

File Before After
RocksDbStoreTest do { Thread.sleep(1) } while (...) loop with manual attempt counter Awaitility.await().until(...)
DRPCTest while (System.currentTimeMillis() < deadline) + Thread.sleep(1) Awaitility.await().until(...)
AsyncLocalizerTest while (...) Thread.sleep(1) waiting for file deletion Awaitility.await().until(() -> !file.exists())
AuthTest Testing.whileTimeout + Time.sleep(100) Awaitility.await().until(server::isServing)
MetricsIntegrationTest Testing.whileTimeout in waitForAtLeastNBuckets Awaitility.with().until(...) (now consistent with assertMetricRunningSum which already used Awaitility)
NettyTest 4 patterns: manual polling loop, sleep() helper, 3x Testing.whileTimeout Awaitility.await().until(...) throughout

Not changed

  • ServerUtilsTest.sleepInterrupted() — intentionally tests thread interrupt behavior
  • NettyTest.doTestServerDelayed Thread.sleep(100) — deliberate delay simulating a late server start, not polling
  • LocalFsBlobStoreTest Thread.sleep(2) — waits for filesystem timestamp resolution, not a polling pattern

Test plan

  • RocksDbStoreTest — 4 tests pass
  • DRPCTest — 6 tests pass
  • AsyncLocalizerTest — 17 tests pass
  • AuthTest — 13 tests pass
  • MetricsIntegrationTest — 2 tests pass
  • NettyTest — 13 tests pass

🤖 Generated with Claude Code

Replace hand-rolled polling loops and Testing.whileTimeout calls with
Awaitility across 6 test files. This makes async waits exit as soon as
the condition is met instead of sleeping for a fixed duration, improving
both test speed and reliability on slow CI machines.

Files changed:
- RocksDbStoreTest: polling loop in waitForInsertFinish
- DRPCTest: deadline loop in getNextAvailableRequest
- AsyncLocalizerTest: polling loop waiting for file deletion
- AuthTest: Testing.whileTimeout waiting for ThriftServer
- MetricsIntegrationTest: Testing.whileTimeout in waitForAtLeastNBuckets
- NettyTest: waitUntilReady, waitForNotNull, doTestLoad, doTestBatch

The deliberate Thread.sleep(100) in NettyTest.doTestServerDelayed is
left unchanged as it simulates a delayed server start, not polling.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@jnioche jnioche requested a review from rzo1 March 30, 2026 09:46
@jnioche jnioche added this to the 3.0.0 milestone Mar 30, 2026
@rzo1 rzo1 merged commit f65b970 into apache:master Mar 30, 2026
10 checks passed
@jnioche jnioche deleted the replace-thread-sleep-with-awaitility branch March 30, 2026 14:01
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.

3 participants