feat: add getMappedPort(int, InternetProtocol) overload#11916
Open
glasses-and-hat wants to merge 1 commit into
Open
feat: add getMappedPort(int, InternetProtocol) overload#11916glasses-and-hat wants to merge 1 commit into
glasses-and-hat wants to merge 1 commit into
Conversation
Allows retrieving the host-mapped port for a container port that is exposed over UDP (or explicitly over TCP) instead of always assuming TCP, so containers that expose the same port number for both protocols (e.g. Jaeger's UDP ports) can be queried unambiguously. Fixes testcontainers#554
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
ContainerState#getMappedPort(int originalPort, InternetProtocol protocol), allowing the host-mapped port to be looked up for a specific protocol (TCP or UDP) instead of always assuming TCP.getMappedPort(int)now delegates to the new overload withInternetProtocol.TCP, so behavior is unchanged for existing callers.Fixes #554
Test plan
ContainerStateTest#getMappedPortDistinguishesTcpAndUdpBindingsForSamePortverifying TCP vs UDP bindings on the same port number resolve independently, and thatgetMappedPort(int)still defaults to TCP.ContainerStateTest#getMappedPortThrowsWhenPortNotMappedForProtocolverifying the error message reflects the requested protocol when no binding exists../gradlew :testcontainers:compileJava :testcontainers:compileTestJavasucceeds../gradlew :testcontainers:test --tests "org.testcontainers.containers.ContainerStateTest"passes (8/8)../gradlew :testcontainers:spotlessCheckpasses.