Skip to content

Convert netty 4.0 test to java#9976

Merged
laurit merged 38 commits into
open-telemetry:mainfrom
heyams:heya/convert-netty-4.0-test-to-java
Feb 26, 2024
Merged

Convert netty 4.0 test to java#9976
laurit merged 38 commits into
open-telemetry:mainfrom
heyams:heya/convert-netty-4.0-test-to-java

Conversation

@heyams

@heyams heyams commented Nov 30, 2023

Copy link
Copy Markdown
Contributor

part of #7195

@CsvSource({"by instance", "by class", "by name", "first"})
void testRemoveOurHandler(String testName) throws Exception {
EmbeddedChannel channel = new EmbeddedChannel(new NoopChannelHandler());
ChannelPipeline channelPipeline = channel.pipeline();

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DefaultChannelPipeline' is package protected in io.netty:netty-transport-4.0.0.Final. calling channel.pipeline()' will automatically add two default HeadHandler and TailHandler

that's why channelPipeline.first() and last() are not null anymore.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you could get around this by creating the instance with reflection or by placing a helper class in the same package as DefaultChannelPipeline and call the constructor using that class

@heyams heyams Feb 9, 2024

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@laurit i tried Class.forName("io.netty.channel.DefaultChannelPipeline"), but it returned the wrong class though.
There are a few of this class with the same package name..
such as org.asynchttpclient:netty-resolver-dns:2.0.0-RC9
or from different netty-transport ..

is there a way i can force it to retrieve it directly from netty-transport-4.0.0.FInal, which is used in the build.gradle.kts. but when i ran the test in intellij, it always retrieved from the wrong dependencies./

It's just an issue with IntelliJ.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated with reflection @laurit

// regression test for
// https://github.com/open-telemetry/opentelemetry-java-instrumentation/issues/4056
@Test
void shouldAddAfterAndRemoveLastHandler() {

@heyams heyams Dec 7, 2023

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i modified this test based on the current implementation. please let me know if this is not the case, might be regression?
i might need to update netty 4.0 instrumentation for this. but i need some feedback first.

assertEquals(httpHandler, channelPipeline.first());
assertEquals(noopHandler, channelPipeline.last());

// removeLast will remove everything after http

@heyams heyams Dec 7, 2023

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removeLast will remove everything after http including noopHandler.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is the same though using reflection

@heyams heyams marked this pull request as ready for review December 7, 2023 21:50
@heyams heyams requested a review from a team December 7, 2023 21:50
@heyams

heyams commented Dec 8, 2023

Copy link
Copy Markdown
Contributor Author

need some help here:

image

Netty40ServerTest is green locally, but CI complained about KtorHttpServerTest:

KtorHttpServerTest > requestWithException() STANDARD_OUT
2023-12-08T23:21:58.5351175Z 23:21:55.534 [eventLoopGroupProxy-4-4 @call-handler#1829] ERROR ktor.application - Unhandled: GET - /exception
2023-12-08T23:21:58.5352525Z java.lang.Exception: controller exception
2023-12-08T23:21:58.5353395Z at _COROUTINE.BOUNDARY.(CoroutineDebugging.kt:46)
2023-12-08T23:21:58.5355015Z at io.opentelemetry.instrumentation.ktor.v2_0.server.AbstractKtorHttpServerTest.controller(AbstractKtorHttpServerTest.kt:109)
2023-12-08T23:21:58.5357449Z at io.opentelemetry.instrumentation.ktor.v2_0.server.AbstractKtorHttpServerTest$setupServer$1$1$4.invokeSuspend(AbstractKtorHttpServerTest.kt:59)
2023-12-08T23:21:58.5359435Z at io.ktor.server.routing.Route$buildPipeline$1$1.invokeSuspend(Route.kt:116)
2023-12-08T23:21:58.5360836Z at io.ktor.util.pipeline.PipelineKt$execute$2.invokeSuspend(Pipeline.kt:478)

is this sporadic?

@heyams

heyams commented Dec 9, 2023

Copy link
Copy Markdown
Contributor Author

rerun failed jobs button is nowhere to be found. do i need additional permission to get access to it?

@laurit

laurit commented Dec 9, 2023

Copy link
Copy Markdown
Contributor

rerun failed jobs button is nowhere to be found. do i need additional permission to get access to it?

I believe so, you can push an empty commit to trigger checks. Closing and reopening the pr should also work.

@jaydeluca

Copy link
Copy Markdown
Member

@heyams I suspect the test failures might not be the ktor tests you referenced. Your screenshot shows passing tests when running the Netty40ServerTest, but have you tried running the Client tests? I ran your tests locally and the Netty40ClientTest hangs forever

image

There are also different variations of the tests

image

When trying to run some of those (:instrumentation:netty:netty-4.0:javaagent:testConnectionSpan) I am seeing some failures there as well:

image

Comment on lines +172 to +173
// http and instrumentation handlers will be remained; noop handler will be removed
// but in reality, line 162 will remove http, instrumentation, and noop handlers

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please read my comments here.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The issue is in something else. Also note that using line numbers in the comment that way isn't the best idea as the line numbers can easily change.

@heyams heyams closed this Feb 13, 2024
@heyams heyams reopened this Feb 13, 2024
@laurit laurit enabled auto-merge (squash) February 26, 2024 18:34
@laurit laurit merged commit 9a2bad6 into open-telemetry:main Feb 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants