Skip to content

Conversation

@rw4lll
Copy link
Collaborator

@rw4lll rw4lll commented May 24, 2025

  • Added support for dynamic port for WaitForHttp.php
    This pull request introduces changes to improve container startup reliability and enhance the HTTP wait strategy in the codebase. Key updates include adding a delay to ensure containers are fully started, making the HTTP wait strategy more robust by handling dynamic port resolution and exceptions, and minor adjustments to improve code clarity.

Container Startup Reliability:

  • Added a 300ms delay in the getBoundPorts method of StartedGenericContainer to address potential issues with containers not being fully started in recent Docker releases. A TODO comment suggests finding a better long-term solution. (src/Container/StartedGenericContainer.php, src/Container/StartedGenericContainer.phpR201-R207)

HTTP Wait Strategy Enhancements:

  • Updated the WaitForHttp class to allow the port parameter to be nullable, enabling dynamic port resolution. (src/Wait/WaitForHttp.php, src/Wait/WaitForHttp.phpL34-R34)
  • Introduced a resolvePort method in WaitForHttp to dynamically determine the port if not explicitly provided. This method is invoked in the wait method. (src/Wait/WaitForHttp.php, [1] [2]
  • Added exception handling in the wait method to gracefully retry on port resolution or HTTP request failures until the timeout is reached. (src/Wait/WaitForHttp.php, src/Wait/WaitForHttp.phpR113-R115)

Minor Improvements:

  • Tmp fix for getBoundPorts() strange fails on the latest Docker releases.

- Tmp fix for getBoundPorts() strange fails on the latest Docker releases.
@shyim shyim merged commit ac50b06 into testcontainers:main May 25, 2025
2 of 3 checks passed
@shyim
Copy link
Collaborator

shyim commented May 25, 2025

Thank you. I gonna fix the phpstan in a different PR

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants