testcontainers / testcontainers/testcontainers-python

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

Ouverte
#101 3 commentaires 8 réactions 0 personnes assignées Voir sur GitHub

Personne n'a encore pris cette issue.

🍏 macos 🐛 bug 👀 requires attention 📦 package: postgres 🪟 windows
Langage dominant
Python
Étoiles
2.3k
Forks
386
Merge moyen
4 h 40 min
PR mergées (30 j)
1

Description

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) =====================================================================

Guide de contribution

Ouvrir le guide de contribution

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Piste de recherche

Commencez par test_db_containers.py et le chemin du gestionnaire de contexte PostgresContainer indiqué dans la trace, puis exécutez py.test -s pour reproduire le timeout. Comparez l’échec de connexion PostgreSQL signalé avec le comportement de démarrage du conteneur ; c’est terminé lorsque le test se connecte correctement et s’achève sans la TimeoutException de 120 secondes.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
docker, postgres, python
Domaine
databases, devops, testing
Type d'issue
Bug
Difficulté
3/5
Temps estimé
1-2 jours
Activité
À l'abandon
Clarté
À clarifier
Accessibilité débutants
25/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.