Skip to content

Commit

Permalink
Flaky test fix
Browse files Browse the repository at this point in the history
  • Loading branch information
danielkec committed Sep 24, 2023
1 parent 37750ae commit 56f59e6
Showing 1 changed file with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@
class TracingPropagationTest {
private static final Duration TIMEOUT = Duration.ofSeconds(15);
private static final AtomicReference<CountDownLatch> SPAN_COUNT_LATCH = new AtomicReference<>();
// 2+1 after re-introduction of content-write span
private static final int EXPECTED_NUMBER_OF_SPANS = 3;
private static MockTracer tracer;
private final Http1Client client;
private final URI uri;
Expand Down Expand Up @@ -92,7 +94,7 @@ protected void onSpanFinished(MockSpan mockSpan) {

@Test
void testTracingSuccess() throws InterruptedException {
SPAN_COUNT_LATCH.set(new CountDownLatch(2));
SPAN_COUNT_LATCH.set(new CountDownLatch(EXPECTED_NUMBER_OF_SPANS));
Context context = Context.builder().id("tracing-unit-test").build();
context.register(tracer);

Expand All @@ -110,10 +112,7 @@ void testTracingSuccess() throws InterruptedException {
List<MockSpan> mockSpans = tracer.finishedSpans();

// the server traces asynchronously, some spans may be written after we receive the response.
// we need to try to wait for such spans
// re-introduced content-write span
assertThat("There should be 3 spans reported", tracer.finishedSpans(), hasSize(3));

assertThat("There should be 3 spans reported", tracer.finishedSpans(), hasSize(EXPECTED_NUMBER_OF_SPANS));

// we need the first span - parentId 0
MockSpan clientSpan = findSpanWithParentId(mockSpans, 0);
Expand Down

0 comments on commit 56f59e6

Please sign in to comment.