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

chore: netty flaky tests fix #598

Merged
merged 6 commits into from
Nov 26, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,8 @@ public void stop() {
bossGroup.shutdownGracefully();
workerGroup.shutdownGracefully();
}

public boolean isReady() {
return channelFuture != null && channelFuture.channel().isActive();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
*/
package io.lumigo.javaagent.instrumentation.netty.v4_1;

import static org.awaitility.Awaitility.await;
import static org.junit.jupiter.api.Assertions.assertEquals;

import io.netty.handler.codec.http.HttpResponseStatus;
Expand All @@ -27,6 +28,7 @@
import io.opentelemetry.sdk.testing.assertj.TracesAssert;
import io.opentelemetry.semconv.SemanticAttributes;
import java.nio.charset.StandardCharsets;
import java.util.concurrent.TimeUnit;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
Expand All @@ -45,7 +47,7 @@ public static void setup() throws InterruptedException {
serverPort = PortUtils.findOpenPort();
server = new NettyServer(serverPort);
server.start();
Thread.sleep(1000); // Wait briefly to ensure the server is fully initialized
await().atMost(5, TimeUnit.SECONDS).until(() -> server.isReady());
}

@Test
Expand All @@ -58,6 +60,7 @@ public void testGetResponse() throws InterruptedException {
String responseBody = response.content().toString(StandardCharsets.UTF_8);
assertEquals("Hello, World!", responseBody);

Thread.sleep(1000); // Wait briefly to ensure the spans are captured
TracesAssert.assertThat(instrumentation.waitForTraces(1))
.hasSize(1)
.hasTracesSatisfyingExactly(
Expand Down
Loading