testcontainers-rs icon indicating copy to clipboard operation
testcontainers-rs copied to clipboard

Unable to provide timeout for waiting

Open ctron opened this issue 4 years ago • 6 comments

When using "wait for" there seems to be no timeout.

While you can add a timeout to tests in general, it would make more sense for me to put a much shorter timeout for the startup of a container.

ctron avatar Jan 26 '21 15:01 ctron

When using "wait for" there seems to be no timeout.

Correct.

Generally, we try to ship testcontainers in a way that works out-of-the-box, i.e. with pinned versions of containers and statically-encoded parameters and env variables. Green tests on our side should therefore ensure that this particular image will always work for the end user.

What is the usecase in which you would have needed a timeout?

While it would certainly be possible to pass or configure one, I'd be more interested in making it harder / impossible to use a docker image through testcontainers in a way that it wouldn't successfully start up.

thomaseizinger avatar Jan 27 '21 03:01 thomaseizinger

What is the usecase in which you would have needed a timeout?

The issue I ran into is that it looks like Postgres containers fail to start up properly on GitHub actions. So the expected line doesn't show up in the logs, and the whole job is stuck.

While it would certainly be possible to pass or configure one, I'd be more interested in making it harder / impossible to use a docker image through testcontainers in a way that it wouldn't successfully start up.

I think there will always be a case you didn't think about. Allowing to put in a timeout make total sense to me.

ctron avatar Jan 27 '21 08:01 ctron

That makes sense, thanks for sharing!

thomaseizinger avatar Feb 01 '21 04:02 thomaseizinger

Do you think we should have a fixed timeout or something that is configurable per container?

I am leaning towards a global one that can maybe be overridden through an env variable to keep the images themselves simple.

thomaseizinger avatar Feb 02 '21 00:02 thomaseizinger

I am leaning towards a global one that can maybe be overridden through an env variable to keep the images themselves simple.

Sounds reasonable to me. If additional requirements come up, it should be easy to extend. But it should also cover most cases already.

ctron avatar Feb 02 '21 08:02 ctron

I propose a default timeout of 1 minute for now.

If we want to make this configurable, https://github.com/testcontainers/testcontainers-rs/pull/259 should be a good foundation for that. I am thinking of something like:

TESTCONTAINERS=ready_timeout=2m,keep

thomaseizinger avatar Feb 03 '21 00:02 thomaseizinger