Skip to content

Commit

Permalink
Fix observation race condition in WebFlux test
Browse files Browse the repository at this point in the history
There is a race condition when we already have a reply,
but the span in the last channel is not closed yet.
  • Loading branch information
artembilan committed Jun 7, 2023
1 parent 7655d97 commit 79408d7
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
import org.springframework.web.server.adapter.WebHttpHandlerBuilder;

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

/**
* @author Artem Bilan
Expand Down Expand Up @@ -123,7 +124,8 @@ void observationIsPropagatedWebFluxRequestReply() {
.expectBody(String.class)
.isEqualTo(testData.toLowerCase());

assertThat(SPANS.spans()).hasSize(3);
// There is a race condition when we already have a reply, but the span in the last channel is not closed yet.
await().untilAsserted(() -> assertThat(SPANS.spans()).hasSize(3));
SpansAssert.assertThat(SPANS.spans().stream().map(BraveFinishedSpan::fromBrave).collect(Collectors.toList()))
.haveSameTraceId();
}
Expand Down

0 comments on commit 79408d7

Please sign in to comment.