3

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.

limewmint
  • 35
  • 3
  • 5
  • Are you using Windows by any chance? What are the versions of Docker Desktop and Windows you're using? – Oleg Šelajev Apr 04 '22 at 09:43
  • @OlegŠelajev I'm using Windows10 and Docker Desktop 4.6.1. By the way, I was using `testcontainers` version 3.4.2 and a few days ago I saw 3.5 version came out and I tried it but I got still errors + even changing connection url to "localhost" did not work so I'm still using 3.4.2 to work with `PostgresContainer`. – limewmint Apr 05 '22 at 15:05

0 Answers0