Repository navigation
Conversation
getLivenessCheckPortNumbers() collected the mapped ports into a HashSet, so their order depended on the random host ports. HttpWaitStrategy uses the first one, so with several exposed ports it could probe the wrong port. Fixes testcontainers#12196
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
Fixes #12196
WaitStrategyTarget.getLivenessCheckPortNumbers()collected the mapped ports into aHashSet, so their order depended on the random host ports Docker picked, not on the order passed towithExposedPorts(...).HttpWaitStrategy(withoutforPort) uses the first element, so with two exposed ports it sometimes probed the second one, while the docs say it waits for the first mapped port. That's the intermittent startup failure from the issue (8090 for HTTP, 8091 for SMTP).The ports are now collected into a
LinkedHashSet, so they keep the exposed ports' order, followed by the bound ports. The return type is stillSet<Integer>, so there's no API change, andGenericContainer.getLivenessCheckPorts()gets the same order since it builds on this method.Tests
New
WaitStrategyTargetTest, which doesn't need Docker. It uses mapped ports that aHashSetiterates in the wrong order (8090 -> 50001, 8091 -> 50000), and checks that bound ports come after the exposed ones. Both tests fail onmainand pass with this change.Ran locally:
./gradlew :testcontainers:test --tests 'org.testcontainers.containers.wait.strategy.WaitStrategyTargetTest'./gradlew :testcontainers:checkstyleMain :testcontainers:checkstyleTest :testcontainers:spotlessCheck :testcontainers:japicmpI couldn't run the container-based wait strategy tests (
HttpWaitStrategyTest,HostPortWaitStrategyTest, ...) locally: my Docker's image store is read-only right now, so pullingtestcontainers/ryukfails for every container test, independent of this change. CI should cover those.Summary by CodeRabbit