Skip to content

WebClientIntegrationTests are failing if port 80 is in use #28902

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

Closed
vpavic opened this issue Aug 1, 2022 · 5 comments
Closed

WebClientIntegrationTests are failing if port 80 is in use #28902

vpavic opened this issue Aug 1, 2022 · 5 comments
Assignees
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) status: backported An issue that has been backported to maintenance branches type: task A general task
Milestone

Comments

@vpavic
Copy link
Contributor

vpavic commented Aug 1, 2022

Several tests from WebClientIntegrationTests are failing for me locally when port 80 is in use. To reproduce this ensure the build is not pulling results from the cache.

$ nc -vz localhost 80
Connection to localhost (127.0.0.1) 80 port [tcp/http] succeeded!
$ ./gradlew clean --no-build-cache :spring-webflux:test --tests "org.springframework.web.reactive.function.client.WebClientIntegrationTests"

> Task :spring-beans:compileTestFixturesJava
/home/vpavic/dev/projects/spring-projects/spring-framework/worktree-main/spring-core/build/classes/java/main/org/springframework/lang/Nullable.class: warning: Cannot find annotation method 'when()' in type 'Nonnull': class file for javax.annotation.Nonnull not found
warning: unknown enum constant When.MAYBE
  reason: class file for javax.annotation.meta.When not found
/home/vpavic/dev/projects/spring-projects/spring-framework/worktree-main/spring-core/build/classes/java/main/org/springframework/lang/NonNullApi.class: warning: Cannot find annotation method 'value()' in type 'TypeQualifierDefault': class file for javax.annotation.meta.TypeQualifierDefault not found
/home/vpavic/dev/projects/spring-projects/spring-framework/worktree-main/spring-core/build/classes/java/main/org/springframework/lang/NonNullFields.class: warning: Cannot find annotation method 'value()' in type 'TypeQualifierDefault'
4 warnings

> Task :spring-webflux:test

WebClientIntegrationTests > malformedResponseChunksOnBodilessEntity(ClientHttpConnector) > org.springframework.web.reactive.function.client.WebClientIntegrationTests.malformedResponseChunksOnBodilessEntity(ClientHttpConnector)[3] FAILED
    java.lang.AssertionError at MessageFormatter.java:115

WebClientIntegrationTests > malformedResponseChunksOnEntityWithBody(ClientHttpConnector) > org.springframework.web.reactive.function.client.WebClientIntegrationTests.malformedResponseChunksOnEntityWithBody(ClientHttpConnector)[3] FAILED
    java.lang.AssertionError at MessageFormatter.java:115

WebClientIntegrationTests > exchangeWithRelativeUrl(ClientHttpConnector) > org.springframework.web.reactive.function.client.WebClientIntegrationTests.exchangeWithRelativeUrl(ClientHttpConnector)[1] FAILED
    java.lang.AssertionError at MessageFormatter.java:115

WebClientIntegrationTests > exchangeWithRelativeUrl(ClientHttpConnector) > org.springframework.web.reactive.function.client.WebClientIntegrationTests.exchangeWithRelativeUrl(ClientHttpConnector)[2] FAILED
    java.lang.AssertionError at MessageFormatter.java:115

WebClientIntegrationTests > exchangeWithRelativeUrl(ClientHttpConnector) > org.springframework.web.reactive.function.client.WebClientIntegrationTests.exchangeWithRelativeUrl(ClientHttpConnector)[3] FAILED
    java.lang.AssertionError at MessageFormatter.java:115

WebClientIntegrationTests > exchangeWithRelativeUrl(ClientHttpConnector) > org.springframework.web.reactive.function.client.WebClientIntegrationTests.exchangeWithRelativeUrl(ClientHttpConnector)[4] FAILED
    java.lang.AssertionError at MessageFormatter.java:115

165 tests completed, 6 failed

> Task :spring-webflux:test FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':spring-webflux:test'.
> There were failing tests. See the report at: file:///home/vpavic/dev/projects/spring-projects/spring-framework/worktree-main/spring-webflux/build/reports/tests/test/index.html

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 21s
93 actionable tasks: 74 executed, 19 up-to-date

A build scan was not published as you have not authenticated with server 'ge.spring.io'.
$ systemctl stop nginx.service
$ nc -vz localhost 80
nc: connect to localhost (127.0.0.1) port 80 (tcp) failed: Connection refused
$ ./gradlew clean --no-build-cache :spring-webflux:test --tests "org.springframework.web.reactive.function.client.WebClientIntegrationTests"

> Task :spring-beans:compileTestFixturesJava
/home/vpavic/dev/projects/spring-projects/spring-framework/worktree-main/spring-core/build/classes/java/main/org/springframework/lang/Nullable.class: warning: Cannot find annotation method 'when()' in type 'Nonnull': class file for javax.annotation.Nonnull not found
warning: unknown enum constant When.MAYBE
  reason: class file for javax.annotation.meta.When not found
/home/vpavic/dev/projects/spring-projects/spring-framework/worktree-main/spring-core/build/classes/java/main/org/springframework/lang/NonNullApi.class: warning: Cannot find annotation method 'value()' in type 'TypeQualifierDefault': class file for javax.annotation.meta.TypeQualifierDefault not found
/home/vpavic/dev/projects/spring-projects/spring-framework/worktree-main/spring-core/build/classes/java/main/org/springframework/lang/NonNullFields.class: warning: Cannot find annotation method 'value()' in type 'TypeQualifierDefault'
4 warnings

BUILD SUCCESSFUL in 20s
93 actionable tasks: 74 executed, 19 up-to-date

A build scan was not published as you have not authenticated with server 'ge.spring.io'.
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Aug 1, 2022
@sbrannen
Copy link
Member

sbrannen commented Aug 1, 2022

What happens if you add the following to org.springframework.web.reactive.function.client.WebClientIntegrationTests.startServer(ClientHttpConnector)?

try {
	this.server.start(0);
}
catch (IOException ex) {
	throw new UncheckedIOException(ex);
}

@vpavic
Copy link
Contributor Author

vpavic commented Aug 1, 2022

The outcome is the same.

Just to make sure I understood correctly what you meant, this is what I did locally:

$ git diff
diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/WebClientIntegrationTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/WebClientIntegrationTests.java
index 80e068a474..488a38b0d0 100644
--- a/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/WebClientIntegrationTests.java
+++ b/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/WebClientIntegrationTests.java
@@ -116,6 +116,12 @@ class WebClientIntegrationTests {
 
        private void startServer(ClientHttpConnector connector) {
                this.server = new MockWebServer();
+               try {
+                       this.server.start(0);
+               }
+               catch (IOException ex) {
+                       throw new UncheckedIOException(ex);
+               }
                this.webClient = WebClient
                                .builder()
                                .clientConnector(connector)

@sbrannen
Copy link
Member

sbrannen commented Aug 1, 2022

The outcome is the same.

OK. Thanks for trying it out.

Just to make sure I understood correctly what you meant, this is what I did locally:

Yes, that's what I meant. I hoped it would use an ephemeral port other than 80, but it was admittedly a shot in the dark since I don't really have time to investigate it at the moment.

Maybe you or somebody else from the Framework team can look into it.

@vpavic
Copy link
Contributor Author

vpavic commented Aug 1, 2022

I had a quick look and to me this doesn't look like an issue with the mock server.

Failures in WebClientIntegrationTests#exchangeWithRelativeUrl happen on all connector implementations, and it looks like the same (or at least similar) problem as #20337.

Regarding the other two failures, they look Jetty specific.

@sdeleuze sdeleuze self-assigned this Jan 20, 2023
@sdeleuze sdeleuze added in: web Issues in web modules (web, webmvc, webflux, websocket) and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Jan 20, 2023
@sdeleuze sdeleuze added this to the 6.0.5 milestone Jan 20, 2023
@sdeleuze sdeleuze added the type: task A general task label Jan 20, 2023
@sdeleuze
Copy link
Contributor

FYI the Jetty flaky tests have been fixed via #29862.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) status: backported An issue that has been backported to maintenance branches type: task A general task
Projects
None yet
Development

No branches or pull requests

4 participants