-
Notifications
You must be signed in to change notification settings - Fork 1k
Fix testLatestDeps for spring-webflux 7 #15574
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
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
26fd7f4
fix first test
jaydeluca a5b5a0e
debugging
jaydeluca 76b9b26
spring notes
jaydeluca a3788e7
more test stuff
jaydeluca 39b823c
cleanup
jaydeluca 559d89f
more cleanup
jaydeluca 9c98489
handle issue with 5.0 testlatestdeps
jaydeluca b84954d
small cleanup
jaydeluca 6a78aca
remove unneeded plugin and jvmArgs
jaydeluca File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
743 changes: 2 additions & 741 deletions
743
...opentelemetry/javaagent/instrumentation/spring/webflux/v5_0/server/SpringWebfluxTest.java
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
instrumentation/spring/spring-webflux/spring-webflux-5.0/testing-webflux7/build.gradle.kts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| plugins { | ||
| id("otel.javaagent-testing") | ||
| } | ||
|
|
||
| dependencies { | ||
| testInstrumentation(project(":instrumentation:spring:spring-core-2.0:javaagent")) | ||
| testInstrumentation(project(":instrumentation:spring:spring-webflux:spring-webflux-5.0:javaagent")) | ||
| testInstrumentation(project(":instrumentation:netty:netty-4.1:javaagent")) | ||
| testInstrumentation(project(":instrumentation:reactor:reactor-3.1:javaagent")) | ||
| testInstrumentation(project(":instrumentation:reactor:reactor-netty:reactor-netty-1.0:javaagent")) | ||
|
|
||
| testImplementation(project(":instrumentation:spring:spring-webflux:spring-webflux-5.0:testing")) | ||
| testImplementation(project(":instrumentation:spring:spring-webflux:spring-webflux-5.3:testing")) | ||
|
|
||
| testImplementation("org.springframework.boot:spring-boot-starter-webflux:4.0.0") | ||
| testImplementation("org.springframework:spring-web:7.0.0") | ||
| testImplementation("org.springframework.boot:spring-boot-starter-test:4.0.0") | ||
| testImplementation("org.springframework.boot:spring-boot-starter-reactor-netty:4.0.0") | ||
| } | ||
|
|
||
| otelJava { | ||
| minJavaVersionSupported.set(JavaVersion.VERSION_17) | ||
| } | ||
|
|
||
| tasks.withType<Test>().configureEach { | ||
| jvmArgs("-Dotel.instrumentation.common.experimental.controller-telemetry.enabled=true") | ||
| } | ||
36 changes: 36 additions & 0 deletions
36
...nt/instrumentation/spring/webflux/v7_0/client/SpringWebfluxClientInstrumentationTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| /* | ||
| * Copyright The OpenTelemetry Authors | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| package io.opentelemetry.javaagent.instrumentation.spring.webflux.v7_0.client; | ||
|
|
||
| import io.opentelemetry.instrumentation.spring.webflux.client.AbstractSpringWebfluxClientInstrumentationTest; | ||
| import io.opentelemetry.instrumentation.testing.junit.InstrumentationExtension; | ||
| import io.opentelemetry.instrumentation.testing.junit.http.HttpClientInstrumentationExtension; | ||
| import io.opentelemetry.instrumentation.testing.junit.http.HttpClientTestOptions; | ||
| import org.junit.jupiter.api.condition.OS; | ||
| import org.junit.jupiter.api.extension.RegisterExtension; | ||
| import org.springframework.web.reactive.function.client.WebClient; | ||
|
|
||
| class SpringWebfluxClientInstrumentationTest | ||
| extends AbstractSpringWebfluxClientInstrumentationTest { | ||
|
|
||
| @RegisterExtension | ||
| static final InstrumentationExtension testing = HttpClientInstrumentationExtension.forAgent(); | ||
|
|
||
| @Override | ||
| protected WebClient.Builder instrument(WebClient.Builder builder) { | ||
| return builder; | ||
| } | ||
|
|
||
| @Override | ||
| protected void configure(HttpClientTestOptions.Builder optionsBuilder) { | ||
| super.configure(optionsBuilder); | ||
|
|
||
| // Disable remote connection tests on Windows due to reactor-netty creating extra spans | ||
| if (OS.WINDOWS.isCurrentOs()) { | ||
| optionsBuilder.setTestRemoteConnection(false); | ||
| } | ||
| } | ||
| } |
38 changes: 38 additions & 0 deletions
38
...javaagent/instrumentation/spring/webflux/v7_0/server/SpringThreadedSpringWebfluxTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| /* | ||
| * Copyright The OpenTelemetry Authors | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| package io.opentelemetry.javaagent.instrumentation.spring.webflux.v7_0.server; | ||
|
|
||
| import org.springframework.boot.reactor.netty.NettyReactiveWebServerFactory; | ||
| import org.springframework.boot.test.context.SpringBootTest; | ||
| import org.springframework.boot.test.context.TestConfiguration; | ||
| import org.springframework.context.annotation.Bean; | ||
| import reactor.netty.resources.LoopResources; | ||
| import server.SpringWebFluxTestApplication; | ||
|
|
||
| /** | ||
| * Run all Webflux tests under netty event loop having only 1 thread. Some of the bugs are better | ||
| * visible in this setup because same thread is reused for different requests. | ||
| */ | ||
| @SpringBootTest( | ||
| webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, | ||
| classes = { | ||
| SpringWebFluxTestApplication.class, | ||
| SpringThreadedSpringWebfluxTest.ForceSingleThreadedNettyAutoConfiguration.class | ||
| }) | ||
| class SpringThreadedSpringWebfluxTest extends SpringWebfluxTest { | ||
|
|
||
| @TestConfiguration | ||
| static class ForceSingleThreadedNettyAutoConfiguration { | ||
| @Bean | ||
| NettyReactiveWebServerFactory nettyFactory() { | ||
| NettyReactiveWebServerFactory factory = new NettyReactiveWebServerFactory(); | ||
| // Configure single-threaded event loop for Spring Boot 4 | ||
| factory.addServerCustomizers( | ||
| server -> server.runOn(LoopResources.create("my-http", 1, true))); | ||
| return factory; | ||
| } | ||
| } | ||
| } |
32 changes: 32 additions & 0 deletions
32
...opentelemetry/javaagent/instrumentation/spring/webflux/v7_0/server/SpringWebfluxTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| /* | ||
| * Copyright The OpenTelemetry Authors | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| package io.opentelemetry.javaagent.instrumentation.spring.webflux.v7_0.server; | ||
|
|
||
| import io.opentelemetry.instrumentation.spring.webflux.server.AbstractSpringWebfluxTest; | ||
| import org.junit.jupiter.api.extension.ExtendWith; | ||
| import org.springframework.boot.reactor.netty.NettyReactiveWebServerFactory; | ||
| import org.springframework.boot.test.context.SpringBootTest; | ||
| import org.springframework.boot.test.context.TestConfiguration; | ||
| import org.springframework.context.annotation.Bean; | ||
| import org.springframework.test.context.junit.jupiter.SpringExtension; | ||
| import server.SpringWebFluxTestApplication; | ||
|
|
||
| @ExtendWith(SpringExtension.class) | ||
| @SpringBootTest( | ||
| webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, | ||
| classes = { | ||
| SpringWebFluxTestApplication.class, | ||
| SpringWebfluxTest.ForceNettyAutoConfiguration.class | ||
| }) | ||
| class SpringWebfluxTest extends AbstractSpringWebfluxTest { | ||
| @TestConfiguration | ||
| static class ForceNettyAutoConfiguration { | ||
| @Bean | ||
| NettyReactiveWebServerFactory nettyFactory() { | ||
| return new NettyReactiveWebServerFactory(); | ||
| } | ||
| } | ||
| } |
61 changes: 61 additions & 0 deletions
61
...rumentation/spring/webflux/v7_0/server/base/DelayedControllerSpringWebFluxServerTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| /* | ||
| * Copyright The OpenTelemetry Authors | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| package io.opentelemetry.javaagent.instrumentation.spring.webflux.v7_0.server.base; | ||
|
|
||
| import io.opentelemetry.instrumentation.spring.webflux.server.AbstractControllerSpringWebFluxServerTest; | ||
| import io.opentelemetry.instrumentation.spring.webflux.server.ServerTestController; | ||
| import io.opentelemetry.instrumentation.testing.junit.http.ServerEndpoint; | ||
| import java.time.Duration; | ||
| import java.util.function.Supplier; | ||
| import org.springframework.boot.autoconfigure.EnableAutoConfiguration; | ||
| import org.springframework.boot.reactor.netty.NettyReactiveWebServerFactory; | ||
| import org.springframework.context.annotation.Bean; | ||
| import org.springframework.context.annotation.Configuration; | ||
| import org.springframework.http.HttpStatusCode; | ||
| import org.springframework.http.server.reactive.ServerHttpResponse; | ||
| import org.springframework.web.bind.annotation.RestController; | ||
| import reactor.core.publisher.Mono; | ||
|
|
||
| /** | ||
| * Tests the case which uses annotated controller methods, and where "controller" span is created | ||
| * within a Mono map step, which follows a delay step. For exception endpoint, the exception is | ||
| * thrown within the last map step. | ||
| */ | ||
| class DelayedControllerSpringWebFluxServerTest extends AbstractControllerSpringWebFluxServerTest { | ||
| @Override | ||
| protected Class<?> getApplicationClass() { | ||
| return Application.class; | ||
| } | ||
|
|
||
| @Configuration | ||
| @EnableAutoConfiguration | ||
| static class Application { | ||
| @Bean | ||
| Controller controller() { | ||
| return new Controller(); | ||
| } | ||
|
|
||
| @Bean | ||
| NettyReactiveWebServerFactory nettyFactory() { | ||
| return new NettyReactiveWebServerFactory(); | ||
| } | ||
| } | ||
|
|
||
| @RestController | ||
| static class Controller extends ServerTestController { | ||
| @Override | ||
| protected <T> Mono<T> wrapControllerMethod(ServerEndpoint endpoint, Supplier<T> handler) { | ||
| return Mono.just("") | ||
| .delayElement(Duration.ofMillis(10)) | ||
| .map(unused -> controller(endpoint, handler::get)); | ||
| } | ||
|
|
||
| @Override | ||
| protected void setStatus(ServerHttpResponse response, ServerEndpoint endpoint) { | ||
| response.setStatusCode(HttpStatusCode.valueOf(endpoint.getStatus())); | ||
| } | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
javaagent-testingalready depends onjava-conventions