testcontainers/testcontainers-python

Bug: ElasticSearchContainer raises urllib.error.URLError during startup, which is not caught

slahn opened this issue · 3 comments

Describe the bug

The ElasticSearchContainer._connect method raises a urllib.error.URLError (wrapping a ConnectionRefusedError) when the container is not yet ready.
This exception is not caught by the @wait_container_is_ready decorator.

Fixed by adding urllib.error.URLError to transient_exceptions parameter of @wait_container_is_ready decorator.

To Reproduce

from testcontainers.elasticsearch import ElasticSearchContainer

with ElasticSearchContainer(
    "docker.elastic.co/elasticsearch/elasticsearch:8.13.1"
) as elastic:
    print(elastic.get_url())

Runtime environment

$ uname -a
Darwin XXXXXXX 23.4.0 Darwin Kernel Version 23.4.0: Fri Mar 15 00:10:42 PDT 2024; root:xnu-10063.101.17~1/RELEASE_ARM64_T6000 arm64
$ poetry run python --version
Python 3.12.3
$ poetry run pip freeze | grep testcon
testcontainers-core==0.0.1rc1
testcontainers-elasticsearch==0.0.1rc1

we don't control these packages:

testcontainers-core==0.0.1rc1
testcontainers-elasticsearch==0.0.1rc1

you can install testcontainers[elasticsearch] - this is maintained. i think you will be able to test sooner than i can with the updated package.

Oh!
I have no idea how we came to use the wrong packages, but thanks for letting me know.

This bug was fixed in commit 0f9ad24.

I have no idea how we came to use...

We don't control those packages anymore