Skip to content
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

chore: resolve IPv4-IPv6 issues #2403

Open
wants to merge 21 commits into
base: main
Choose a base branch
from

Conversation

mdelapenya
Copy link
Collaborator

@mdelapenya mdelapenya commented Mar 19, 2024

  • feat: detect IPv4 and IPv6
  • chore: get container host from the hostIPs
  • chore: simplify
  • chore: resolve host port bindings
  • chore: get bound ports from port bindings
  • chore: update wait strategies to use bound ports
  • chore: lint
  • fix: use a fixed port

What does this PR do?

It looks up the bounded ports every time a container needs to get a mapped port. It also improves the wait strategies (http and host-port) to get the bound port.

To get the bound port, we'll get the host IP addresses from the current Docker Host, and with that list of values, and the ports from a container, we will get the bound ports.

Finally, we are deprecating the ForceIPv4LocalHost field from the HTTPStrategy, as it's not needed anymore. The example test is updated to fix the port in the wait strategy.

Why is it important?

Resolves flakiness in the CI, as the testable example is failing in a non consistent manner: because the test exposes two ports, 8080 and 80, the way Docker is retrieving them from the JSON representation is not deterministic (it's a port map), therefore, the test is sometimes returning the 80 port for getting the HTTP endpoint and others, the 8080 port.

At the same time, it adds a more consistent manner of getting the host and the port, relying on the Docker host, taking into consideration the IPv4 and IPv6 families.

Related issues

@mdelapenya mdelapenya added the chore Changes that do not impact the existing functionality label Mar 19, 2024
@mdelapenya mdelapenya self-assigned this Mar 19, 2024
Copy link

netlify bot commented Mar 19, 2024

Deploy Preview for testcontainers-go ready!

Name Link
🔨 Latest commit 81fcba6
🔍 Latest deploy log https://app.netlify.com/sites/testcontainers-go/deploys/663c984d0945110008b81049
😎 Deploy Preview https://deploy-preview-2403--testcontainers-go.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@mdelapenya mdelapenya marked this pull request as ready for review March 22, 2024 11:33
@mdelapenya mdelapenya requested a review from a team as a code owner March 22, 2024 11:33
@mdelapenya mdelapenya removed the request for review from cristianrgreco April 18, 2024 21:10
@mdelapenya
Copy link
Collaborator Author

@cristianrgreco I ping you as you already implemented this for NodeJS, and I used it as reference. Could you please take a look? 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
chore Changes that do not impact the existing functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant