Skip to content

Commit

Permalink
Merge #3010 into 3.5.0-M2
Browse files Browse the repository at this point in the history
  • Loading branch information
simonbasle committed Apr 11, 2022
2 parents c758a36 + 0b0ed33 commit 55af384
Showing 1 changed file with 11 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
import reactor.util.Loggers;

import static org.assertj.core.api.Assertions.*;
import static org.awaitility.Awaitility.await;

/**
* @author Simon Baslé
Expand Down Expand Up @@ -757,7 +758,7 @@ void estimateRemainingTaskCapacityResetWhenDirectTaskIsExecuted() throws Interru

assertThat(boundedElasticScheduler.estimateRemainingTaskCapacity()).as("capacity when running").isZero();
latch.countDown();
Awaitility.await().untilTrue(taskRan);
await().untilTrue(taskRan);
assertThat(boundedElasticScheduler.estimateRemainingTaskCapacity()).as("capacity after run").isOne();
}

Expand Down Expand Up @@ -786,7 +787,7 @@ void estimateRemainingTaskCapacityResetWhenWorkerTaskIsExecuted() throws Interru

assertThat(boundedElasticScheduler.estimateRemainingTaskCapacity()).as("capacity when running").isZero();
latch.countDown();
Awaitility.await().untilTrue(taskRan);
await().untilTrue(taskRan);
assertThat(boundedElasticScheduler.estimateRemainingTaskCapacity()).as("capacity after run").isOne();
}

Expand Down Expand Up @@ -925,7 +926,7 @@ void taskPutInPendingQueueIsEventuallyExecuted() throws InterruptedException {
assertThat(boundedElasticScheduler.estimateRemainingTaskCapacity()).as("queue full").isZero();

latch.countDown();
Awaitility.await().atMost(100, TimeUnit.MILLISECONDS)
await().atMost(100, TimeUnit.MILLISECONDS)
.pollInterval(10, TimeUnit.MILLISECONDS)
.pollDelay(10, TimeUnit.MILLISECONDS)
.untilAsserted(() -> assertThat(ranSecond)
Expand Down Expand Up @@ -1463,13 +1464,16 @@ void toStringOfExecutorReflectsBoundedVsUnboundedAndCompletedVsQueued()
try {
bounded.submit(taskStartedLatch::countDown);
unbounded.submit(taskStartedLatch::countDown);
bounded.schedule(() -> {}, 100, TimeUnit.MILLISECONDS);
unbounded.schedule(() -> {}, 100, TimeUnit.MILLISECONDS);
bounded.schedule(() -> {}, 1, TimeUnit.SECONDS);
unbounded.schedule(() -> {}, 1, TimeUnit.SECONDS);

assertThat(taskStartedLatch.await(1, TimeUnit.SECONDS)).as("tasks picked").isTrue(); //give a small window for the task to be picked from the queue and completed

assertThat(bounded).hasToString("BoundedScheduledExecutorService{IDLE, queued=1/123, completed=1}");
assertThat(unbounded).hasToString("BoundedScheduledExecutorService{IDLE, queued=1/unbounded, completed=1}");
Awaitility.with().pollDelay(Duration.ofMillis(50))
.await().atMost(Duration.ofMillis(500)).untilAsserted(() -> {
assertThat(bounded).hasToString("BoundedScheduledExecutorService{IDLE, queued=1/123, completed=1}");
assertThat(unbounded).hasToString("BoundedScheduledExecutorService{IDLE, queued=1/unbounded, completed=1}");
});
}
finally {
bounded.shutdownNow();
Expand Down

0 comments on commit 55af384

Please sign in to comment.