testcontainers-go
testcontainers-go copied to clipboard
chore: resolve IPv4-IPv6 issues
- 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
- Relates #1775
Deploy Preview for testcontainers-go ready!
| Name | Link |
|---|---|
| Latest commit | 81fcba6dafc9f306b113e9ff3b3d94a0d5a3e76d |
| 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...Use your smartphone camera to open QR code link. |
To edit notification comments on pull requests, go to your Netlify site configuration.
@cristianrgreco I ping you as you already implemented this for NodeJS, and I used it as reference. Could you please take a look? 🙏