testcontainers / testcontainers-hs

Docker containers for your integration tests! http://hackage.haskell.org/package/testcontainers
MIT License
58 stars 13 forks source link

Make it possible to customize 'ryuk' reaper config #50

Open rvem opened 5 months ago

rvem commented 5 months ago

I stumbled upon https://github.com/moby/moby/issues/42442 which periodically breaks tests that are based on testcontainers-hs.

One way to workaround this issue is to disable IPv6 altogether on the machine that runs tests, but IMO this doesn't sound like a nice solution since test suite results consistency will depend on local setup. Instead, it'd be better to run the ryuk container with --publish 127.0.0.1::8080 instead of --publish 8080, however, this is not viable with the current interface provided by testcontainers-hs.

What I propose to do is to add a version of withContainers function that will allow running the TestContainer action either with custom Config or with custom Reaper container.

rvem commented 5 months ago

I've looked at the code a bit more, and looks like the right way to solve the problem is to resolve this TODO

rvem commented 5 months ago

So the actual problem is that localhost is resolved to [::1] by head <$> getAddrInfo ..., while the first entry in the container port binding is IPv4, thus an attempt to query [::1] on IPv4 port fails. Ideally, we'd need to resolve the docker host before figuring out the mapped port

rvem commented 5 months ago

Hmm, judging by testcontainers-go and testcontainers-node, this is somewhat known problem and their solution is to either not use IPv6 or specify IPv4 addresses in port bind explicitly