Skip to content

Integrate poetry into devcontainers - #431

Merged
alexanderankin merged 1 commit into
testcontainers:mainfrom
bearrito:feature/poetry-devcontainers
Feb 29, 2024
Merged

Integrate poetry into devcontainers#431
alexanderankin merged 1 commit into
testcontainers:mainfrom
bearrito:feature/poetry-devcontainers

Conversation

@bearrito

@bearritobearrito commented Feb 29, 2024

Copy link
Copy Markdown
Contributor

Following discussions here - #430
As well as looking at recent changes. It seems as though the devcontainer workflow is broken.

This PR will get you a working(?) install.

From within the container

vscode ➜ /workspaces/testcontainers-python (feature/poetry-devcontainers) $ poetry shell
Spawning shell within /home/vscode/.cache/pypoetry/virtualenvs/testcontainers-_53phrdA-py3.11 

Core tests passed.

(testcontainers-py3.11) vscode ➜ /workspaces/testcontainers-python (feature/poetry-devcontainers) $ make tests
poetry run pytest -v --cov=testcontainers.core core/tests
===================================================================================== test session starts =====================================================================================
platform linux -- Python 3.11.8, pytest-7.4.3, pluggy-1.4.0 -- /home/vscode/.cache/pypoetry/virtualenvs/testcontainers-_53phrdA-py3.11/bin/python
cachedir: .pytest_cache
rootdir: /workspaces/testcontainers-python
configfile: pyproject.toml
plugins: cov-4.1.0
collected 9 items core/tests/test_core.py::test_timeout_is_raised_when_waiting_for_logs ---------------------------------------------------------------------------------------- live log call ----------------------------------------------------------------------------------------
INFO testcontainers.core.container:container.py:63 Pulling image alpine
INFO testcontainers.core.container:container.py:75 Container started: 9a5d98226c4d
PASSED [ 11%]
core/tests/test_core.py::test_garbage_collection_is_defensive ---------------------------------------------------------------------------------------- live log call ----------------------------------------------------------------------------------------
INFO testcontainers.core.container:container.py:63 Pulling image postgres:latest
INFO testcontainers.core.container:container.py:75 Container started: d458d5998619
PASSED [ 22%]
core/tests/test_core.py::test_wait_for_hello ---------------------------------------------------------------------------------------- live log call ----------------------------------------------------------------------------------------
INFO testcontainers.core.container:container.py:63 Pulling image hello-world
INFO testcontainers.core.container:container.py:75 Container started: 20e6376407b7
PASSED [ 33%]
core/tests/test_core.py::test_can_get_logs ---------------------------------------------------------------------------------------- live log call ----------------------------------------------------------------------------------------
INFO testcontainers.core.container:container.py:63 Pulling image hello-world
INFO testcontainers.core.container:container.py:75 Container started: 5c7199f19cfd
PASSED [ 44%]
core/tests/test_docker_client.py::test_docker_client_from_env PASSED [ 55%]
core/tests/test_docker_client.py::test_container_docker_client_kw PASSED [ 66%]
core/tests/test_docker_in_docker.py::test_wait_for_logs_docker_in_docker ---------------------------------------------------------------------------------------- live log call ----------------------------------------------------------------------------------------
INFO testcontainers.core.container:container.py:63 Pulling image hello-world
INFO testcontainers.core.container:container.py:75 Container started: dbe61a3b6bc9
XFAIL (https://github.com/docker/docker-py/issues/2717) [ 77%]
core/tests/test_new_docker_api.py::test_docker_custom_image ---------------------------------------------------------------------------------------- live log call ----------------------------------------------------------------------------------------
INFO testcontainers.core.container:container.py:63 Pulling image mysql:5.7.17
INFO testcontainers.core.container:container.py:75 Container started: 38d5486270ce
INFO testcontainers.core.waiting_utils:waiting_utils.py:52 Waiting for container <Container: 38d5486270ce> with image mysql:5.7.17 to be ready ...
PASSED [ 88%]
core/tests/test_new_docker_api.py::test_docker_kwargs ---------------------------------------------------------------------------------------- live log call ----------------------------------------------------------------------------------------
INFO testcontainers.core.container:container.py:63 Pulling image nginx:latest
INFO testcontainers.core.container:container.py:75 Container started: 300b3af04ef1
INFO testcontainers.core.container:container.py:63 Pulling image nginx:latest
INFO testcontainers.core.container:container.py:75 Container started: dc1f9626454b
PASSED [100%]
---------- coverage: platform linux, python 3.11.8-final-0 -----------
Name Stmts Miss Branch BrPart Cover
-----------------------------------------------------------------------------
core/testcontainers/core/__init__.py 0 0 0 0 100%
core/testcontainers/core/config.py 4 0 0 0 100%
core/testcontainers/core/container.py 97 15 26 8 80%
core/testcontainers/core/docker_client.py 56 17 16 5 64%
core/testcontainers/core/exceptions.py 2 0 0 0 100%
core/testcontainers/core/generic.py 23 23 2 0 0%
core/testcontainers/core/utils.py 46 22 10 0 43%
core/testcontainers/core/waiting_utils.py 45 8 16 4 80%
-----------------------------------------------------------------------------
TOTAL 273 85 70 17 65%
Coverage HTML written to dir htmlcov

However, some module based tests seemed to fail. Seems like this a known issue though - #428


---------- coverage: platform linux, python 3.11.8-final-0 -----------
=================================================================================== short test summary info ===================================================================================
FAILED modules/clickhouse/tests/test_clickhouse.py::test_docker_run_clickhouse - TimeoutError: Wait time (120s) exceeded for _connect(args: (), kwargs: {}). Exception: Code: 81.
================================================================================ 1 failed in 156.76s (0:02:36) ================================================================================
make: *** [Makefile:28: modules/clickhouse/tests] Error 1

Their is small downside to this. Poetry is installed as part of the post-create-command, which means everytime the container is spawned poetry has to be installed. This takes about 30 seconds. It is feasible to build another image inside devcontainers. However, that differs from current workflow. Let me know.

@alexanderankin

Copy link
Copy Markdown
Member

since were not shipping this code to users and the old code is truly non-functional (after #408), im going to just merge

@alexanderankin
alexanderankin merged commit fc11119 into testcontainers:mainFeb 29, 2024
alexanderankin added a commit that referenced this pull request Feb 29, 2024
alexanderankin added a commit that referenced this pull request Feb 29, 2024
fixes the #430 fix in #431: makes the linter happy?
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@bearrito@alexanderankin