Skip to content

Commit

Permalink
Make PoolIT test less flaky
Browse files Browse the repository at this point in the history
High sleep time in the test thread could cause the background allocation thread to run ahead and increase the allocation counter too much.
  • Loading branch information
chrisvest committed Jun 9, 2024
1 parent 3ece769 commit 3e7b0a4
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/test/java/blackbox/slow/PoolIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,14 @@ void mustGraduallyReduceAggressivenessInRepairingFailingAllocator() throws Excep
assertThrows(PoolException.class, () -> pool.claim(longTimeout).release());
long prev = 0, curr;
for (int i = 0; i < 50; i++) {
long start = System.nanoTime();
Thread.sleep(100);
long elapsedMillis = TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - start);
if (elapsedMillis >= 150) {
// Ignore outliers with very high sleep time.
i--;
continue;
}
curr = counter.get();
long delta = curr - prev;
prev = curr;
Expand Down

0 comments on commit 3e7b0a4

Please sign in to comment.