Skip to content

Use an available port for gRPC integration tests - #4320

Open
MoChiUaena wants to merge 1 commit into
spring-cloud:mainfrom
MoChiUaena:codex/fix-grpc-test-port-collision
Open

MoChiUaena wants to merge 1 commit into
spring-cloud:mainfrom
MoChiUaena:codex/fix-grpc-test-port-collision

Conversation

@MoChiUaena

Copy link
Copy Markdown

The gRPC integration app starts HTTP on a random port, then tries to bind gRPC to the next port. That adjacent port can already be occupied, causing the integration tests to fail at startup.

Bind gRPC to an available port and have the route tests use the bound port. The Spring-managed gRPC server now stops when the application context closes. A regression test reserves the previously assumed adjacent port, then checks that the app starts and releases its gRPC port on shutdown. The module also excludes generated protobuf sources from Checkstyle while keeping handwritten code checked.

Validation: ./mvnw -pl spring-cloud-gateway-integration-tests/grpc validate passed Spring Java Format and Checkstyle. The three gRPC test classes passed (8 tests) with -pl spring-cloud-gateway-integration-tests/grpc -am -Ddisable.checks=true -Dtest=GRPCApplicationPortTests,GRPCApplicationTests,JsonToGrpcApplicationTests -Dsurefire.failIfNoSpecifiedTests=false verify. Checks are disabled only for that dependency-chain run because the unchanged WebFlux module currently reports 27 Checkstyle violations.

The test application currently binds gRPC to the HTTP port plus one, which can already be occupied. Let gRPC bind an available port and have the route tests use the bound port. Stop the server when the Spring context closes, and cover startup with the adjacent port occupied.

Signed-off-by: dlwlrma <965810157@qq.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants