testcontainers / testcontainers/testcontainers-python

test is stuck at waiting and then times out : postgres container

Aperta
#101 3 commenti 8 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

🍏 macos 🐛 bug 👀 requires attention 📦 package: postgres 🪟 windows
Lingua principale
Python
Stelle
2.3k
Fork
386
Merge medio
4h 40m
PR unite (30g)
1

Descrizione

Can someone please help fix this issue? Not sure what to do. Container starts up fine. But my test is timing out.

py.test -s
========================================================================== test session starts ==========================================================================
platform darwin -- Python 3.8.3, pytest-5.4.3, py-1.8.1, pluggy-0.13.1
rootdir: /Users/ypatel/postgres
collecting ... testing
collected 1 item                                                                                                                                                        

test_db_containers.py 
Pulling image localhost/opensource/postgres/postgresql12:12.3
⠴
Container started:  d21da7fa95
Waiting to be ready...
F

=============================================================================== FAILURES ================================================================================
_______________________________________________________________________ test_docker_run_postgress _______________________________________________________________________

    def test_docker_run_postgress():
        postgres_container = PostgresContainer("localhost/opensource/postgres/postgresql12:12.3")
    
>       with postgres_container as postgres:

test_db_containers.py:21: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/testcontainers/core/container.py:64: in __enter__
    return self.start()
/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/testcontainers/core/generic.py:42: in start
    self._connect()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

wrapped = <bound method DbContainer._connect of <testcontainers.postgres.PostgresContainer object at 0x7fcb692b6700>>
instance = <testcontainers.postgres.PostgresContainer object at 0x7fcb692b6700>, args = (), kwargs = {}

    @wrapt.decorator
    def wrapper(wrapped, instance, args, kwargs):
        exception = None
        print(crayons.yellow("Waiting to be ready..."))
        with blindspin.spinner():
            for _ in range(0, config.MAX_TRIES):
                try:
                    return wrapped(*args, **kwargs)
                except Exception as e:
                    time.sleep(config.SLEEP_TIME)
                    exception = e
>           raise TimeoutException(
                """Wait time exceeded {0} sec.
                    Method {1}, args {2} , kwargs {3}.
                     Exception {4}""".format(config.MAX_TRIES,
                                             wrapped.__name__,
                                             args, kwargs, exception))
E           testcontainers.core.exceptions.TimeoutException: Wait time exceeded 120 sec.
E                               Method _connect, args () , kwargs {}.
E                                Exception (psycopg2.OperationalError) server closed the connection unexpectedly
E               This probably means the server terminated abnormally
E               before or while processing the request.
E           
E           (Background on this error at: http://sqlalche.me/e/e3q8)

/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/testcontainers/core/waiting_utils.py:46: TimeoutException
======================================================================== short test summary info ========================================================================
FAILED test_db_containers.py::test_docker_run_postgress - testcontainers.core.exceptions.TimeoutException: Wait time exceeded 120 sec.
===================================================================== 1 failed in 124.21s (0:02:04) =====================================================================

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia con test_db_containers.py e il percorso del context manager PostgresContainer mostrato nel traceback, quindi esegui py.test -s per riprodurre il timeout. Confronta il problema di connessione a PostgreSQL segnalato con il comportamento di avvio del container; il lavoro è completato quando il test si connette correttamente e termina senza la TimeoutException di 120 secondi.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
docker, postgres, python
Ambito
databases, devops, testing
Tipo di issue
Bug
Difficoltà
3/5
Tempo stimato
1-2 giorni
Stato di attività
Ferma
Chiarezza
Da chiarire
Idoneità per principianti
25/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.