From b9aaa15d59e348cb06c00806dafc4ad600cdf25e Mon Sep 17 00:00:00 2001 From: Antoine Toulme Date: Sun, 6 Jun 2021 15:26:38 -0700 Subject: [PATCH] Fix flaky OpenTelemetry acceptance test (#2375) Signed-off-by: Antoine Toulme --- .../tests/acceptance/OpenTelemetryAcceptanceTest.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/OpenTelemetryAcceptanceTest.java b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/OpenTelemetryAcceptanceTest.java index 17bd010c2e..3a54cd92ba 100644 --- a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/OpenTelemetryAcceptanceTest.java +++ b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/OpenTelemetryAcceptanceTest.java @@ -24,6 +24,7 @@ import org.hyperledger.besu.tests.acceptance.dsl.WaitUtils; import org.hyperledger.besu.tests.acceptance.dsl.node.BesuNode; import org.hyperledger.besu.tests.acceptance.dsl.node.configuration.BesuNodeConfigurationBuilder; +import java.time.Duration; import java.util.ArrayList; import java.util.List; @@ -190,8 +191,13 @@ public class OpenTelemetryAcceptanceTest extends AcceptanceTestBase { @Test public void traceReportingWithTraceId() { - - OkHttpClient okClient = new OkHttpClient(); + Duration timeout = Duration.ofSeconds(1); + OkHttpClient okClient = + new OkHttpClient.Builder() + .connectTimeout(timeout) + .readTimeout(timeout) + .writeTimeout(timeout) + .build(); WaitUtils.waitFor( 30, () -> { @@ -213,6 +219,7 @@ public class OpenTelemetryAcceptanceTest extends AcceptanceTestBase { .build(); Response response = client.newCall(request).execute(); assertThat(response.code()).isEqualTo(200); + response.close(); List spans = new ArrayList<>(fakeTracesCollector.getReceivedSpans()); fakeTracesCollector.getReceivedSpans().clear(); assertThat(spans.isEmpty()).isFalse();