Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

4.x: Intermittent failure (WebClient tracing test) #5755

Merged
merged 2 commits into from
Dec 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion tests/integration/webclient/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
-->
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>helidon-tests-integration</artifactId>
<groupId>io.helidon.tests.integration</groupId>
Expand Down Expand Up @@ -95,5 +95,10 @@
<artifactId>opentracing-mock</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<artifactId>helidon-common-testing-junit5</artifactId>
<groupId>io.helidon.common.testing</groupId>
<scope>test</scope>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,12 @@
import java.util.List;
import java.util.Map;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;

import io.helidon.common.context.Context;
import io.helidon.common.http.Http;
import io.helidon.common.testing.junit5.MatcherWithRetry;
import io.helidon.config.Config;
import io.helidon.reactive.media.jsonp.JsonpSupport;
import io.helidon.reactive.webclient.WebClient;
import io.helidon.reactive.webclient.WebClientResponse;
import io.helidon.reactive.webserver.WebServer;
Expand All @@ -32,14 +34,15 @@
import io.opentracing.mock.MockSpan;
import io.opentracing.mock.MockTracer;
import io.opentracing.tag.Tags;
import jakarta.json.JsonObject;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;

import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.notNullValue;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.empty;
import static org.hamcrest.Matchers.greaterThanOrEqualTo;
import static org.hamcrest.Matchers.hasSize;

/**
* Test tracing integration.
Expand All @@ -48,7 +51,6 @@ class TracingPropagationTest {
private static final Duration TIMEOUT = Duration.ofSeconds(10);

@Test
@Disabled // intermittently failing on pipeline, issue 5754
void testTracingSuccess() throws ExecutionException, InterruptedException {
MockTracer mockTracer = new MockTracer();

Expand All @@ -63,18 +65,23 @@ void testTracingSuccess() throws ExecutionException, InterruptedException {
.baseUri(uri)
.context(context)
.config(Config.create().get("client"))
.addMediaSupport(JsonpSupport.create())
.build();

client.get()
WebClientResponse response = client.get()
.queryParam("some", "value")
.fragment("fragment")
.request()
.forSingle(WebClientResponse::close)
.await(TIMEOUT);
assertThat(response.status(), is(Http.Status.OK_200));
assertThat(response.content().as(JsonObject.class).await(TIMEOUT), notNullValue());
response.close();

// the server traces asynchronously, some spans may be written after we receive the response.
// we need to try to wait for such spans
MatcherWithRetry.assertThatWithRetry("There should be 3 spans reported", mockTracer::finishedSpans, hasSize(3));

TimeUnit.MILLISECONDS.sleep(1);
List<MockSpan> mockSpans = mockTracer.finishedSpans();
assertThat("At least one client and one server span expected", mockSpans.size(), greaterThanOrEqualTo(2));

// we need the first span - parentId 0
MockSpan clientSpan = findSpanWithParentId(mockSpans, 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class TracingTest extends TestParent {
private static final Duration TIMEOUT = Duration.ofSeconds(30);

@Test
void testTracingNoServerSuccess() throws ExecutionException, InterruptedException {
void testTracingNoServerSuccess() {
MockTracer mockTracer = new MockTracer();
String uri = "http://localhost:" + webServer.port() + "/greet";
Context context = Context.builder().id("tracing-unit-test").build();
Expand Down