Skip to content

Commit

Permalink
Trying to fix flakey tests
Browse files Browse the repository at this point in the history
  • Loading branch information
marcingrzejszczak committed Mar 9, 2023
1 parent 46f44a9 commit 182b9dd
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public final class TestObservationRegistry implements ObservationRegistry {

private final ObservationRegistry delegate = ObservationRegistry.create();

private final ArrayListObservationHandler handler = new ArrayListObservationHandler();
private final StoringObservationHandler handler = new StoringObservationHandler();

private TestObservationRegistry() {
observationConfig().observationHandler(this.handler);
Expand Down Expand Up @@ -73,7 +73,7 @@ Queue<TestObservationContext> getContexts() {
return this.handler.contexts;
}

private static class ArrayListObservationHandler implements ObservationHandler<Observation.Context> {
private static class StoringObservationHandler implements ObservationHandler<Observation.Context> {

final Queue<TestObservationContext> contexts = new ConcurrentLinkedQueue<>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ void should_not_break_on_multiple_threads() {
new Thread(() -> o2.start().stop()).start();
new Thread(() -> o3.start().stop()).start();

Awaitility.await()
.pollDelay(Duration.ofMillis(10))
.atMost(Duration.ofMillis(50))
.untilAsserted(() -> BDDAssertions.then(registry.getContexts()).hasSize(3));
Awaitility.await().pollDelay(Duration.ofMillis(10)).atMost(Duration.ofMillis(50)).untilAsserted(() -> {
System.out.println("Registry size [" + registry.getContexts().size() + "]");
BDDAssertions.then(registry.getContexts()).hasSize(3);
});
}

@Test
Expand Down

0 comments on commit 182b9dd

Please sign in to comment.