I want to test my endpoints using RedisContainer
from tescontainers
but I had a problem during testing. Since it does not respond I wrote a simple code to see whether it works fine but when I start the RedisContainer it stucks at waiting stage probably that is why I had a problem during tests.
My simple code:
from testcontainers.redis import RedisContainer
with RedisContainer('redis:latest') as re:
re.start()
print("Hello")
re.stop()
The output:
Pulling image redis:latest Container started: 381b7daed7 Waiting to be ready...` testcontainers.core.exceptions.TimeoutException: Wait time exceeded 120 sec. Method _connect, args () , kwargs {}. Exception Error 11001 connecting to localnpipe:64913. getaddrinfo failed.
I faced with the same issue with PostgresContainer
before and solved it like in this issue:
https://github.com/testcontainers/testcontainers-python/issues/108#issuecomment-660371568
Replacing host value prevented container from getting stuck:
class PostgresContainerX(PostgresContainer):
def get_connection_url(self):
return super().get_connection_url().replace('localnpipe', 'localhost')
But I don't know how to solve the problem with RedisContainer. I looked at code of redis container but I could not find any way to solve it. Any suggestions or comments would be great to help this issue.