Skip to content

Commit c685988

Browse files
authored
Merge branch 'main' into main
2 parents 88cf9a8 + b10d916 commit c685988

File tree

63 files changed

+2604
-753
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+2604
-753
lines changed

.github/.release-please-manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
".": "3.7.1"
2+
".": "4.1.0"
33
}

.github/release-please-config.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
{
22
"release-type": "python",
3-
"bootstrap-sha": "28e3a471c32c1036dd5e37df13cdde3b1ba91000",
43
"packages": {
54
".": {
65
"package-name": "testcontainers"

.github/workflows/ci-community.yml

Lines changed: 30 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -4,63 +4,51 @@ name: modules
44

55
on:
66
push:
7-
branches: [main]
7+
branches: [ main ]
88
paths:
99
- "modules/**"
1010
pull_request:
11-
branches: [main]
11+
branches: [ main ]
1212
paths:
1313
- "modules/**"
1414

15-
permissions:
16-
actions: write # needed for self-cancellation
17-
1815
jobs:
19-
test:
20-
strategy:
21-
fail-fast: false
22-
matrix:
23-
python-version: ["3.11"]
24-
module:
25-
- arangodb
26-
- azurite
27-
- clickhouse
28-
- elasticsearch
29-
- google
30-
- kafka
31-
- keycloak
32-
- localstack
33-
- minio
34-
- mongodb
35-
- mssql
36-
- mysql
37-
- neo4j
38-
- nginx
39-
- opensearch
40-
- oracle
41-
- postgres
42-
- rabbitmq
43-
- redis
44-
- selenium
45-
- k3s
16+
track-modules:
4617
runs-on: ubuntu-latest
4718
steps:
4819
- name: Checkout contents
4920
uses: actions/checkout@v4
21+
with:
22+
fetch-depth: 0 # recommended by tj-actions/changed-files
5023
- name: Get changed files
51-
id: changes-for-module
24+
id: changed-files
5225
uses: tj-actions/changed-files@v42
5326
with:
54-
files: |
55-
modules/${{ matrix.module }}/**
56-
- name: Exit early, nothing to do
57-
if: ${{ steps.changes-for-module.outputs.any_changed == 'false' }}
27+
path: "./modules"
28+
diff_relative: true
29+
dir_names: true
30+
dir_names_exclude_current_dir: true
31+
json: true
32+
- name: Compute modules from files
33+
id: compute-changes
5834
run: |
59-
# cancel and wait for run to end
60-
gh run cancel ${{ github.run_id }}
61-
gh run watch ${{ github.run_id }}
62-
env:
63-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
35+
modules=$(echo "${{ steps.changed-files.outputs.all_changed_files }}" | jq '.[] | split("/") | first' | jq -s -c '. | unique')
36+
echo "computed_modules=$modules"
37+
echo "computed_modules=$modules" >> $GITHUB_OUTPUT
38+
outputs:
39+
changed_modules: ${{ steps.compute-changes.outputs.computed_modules }}
40+
test:
41+
needs: [track-modules]
42+
if: ${{ needs.track-modules.outputs.changed_modules != '[]' }}
43+
strategy:
44+
fail-fast: false
45+
matrix:
46+
python-version: [ "3.11" ]
47+
module: ${{ fromJSON(needs.track-modules.outputs.changed_modules) }}
48+
runs-on: ubuntu-latest
49+
steps:
50+
- name: Checkout contents
51+
uses: actions/checkout@v4
6452
- name: Set up Python
6553
uses: ./.github/actions/setup-env
6654
with:

.github/workflows/ci-lint.yml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ jobs:
1818
with:
1919
python-version: "3.9" # the pre-commit is hooked in as 3.9
2020
- name: Install Python dependencies
21-
run: poetry install
22-
- name: Install pre-commit
23-
run: pip install pre-commit
24-
- name: Run linter
25-
run: pre-commit run -a
21+
run: poetry install --no-interaction
22+
- name: Execute pre-commit handler
23+
run: poetry run pre-commit run -a

.pre-commit-config.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
default_language_version:
2-
python: python3.9
2+
python: python3
33

44
repos:
55
- repo: https://github.com/pre-commit/pre-commit-hooks
@@ -10,13 +10,13 @@ repos:
1010
- id: end-of-file-fixer
1111

1212
- repo: https://github.com/psf/black-pre-commit-mirror
13-
rev: '24.1.1'
13+
rev: '24.2.0'
1414
hooks:
1515
- id: black
1616
args: [ '--config', 'pyproject.toml' ]
1717

1818
- repo: https://github.com/astral-sh/ruff-pre-commit
19-
rev: 'v0.1.14'
19+
rev: 'v0.3.0'
2020
hooks:
2121
- id: ruff
2222
# Explicitly setting config to prevent Ruff from using `pyproject.toml` in sub packages.

CHANGELOG.md

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
# Changelog
2+
3+
## [4.1.0](https://github.com/testcontainers/testcontainers-python/compare/testcontainers-v4.0.1...testcontainers-v4.1.0) (2024-03-19)
4+
5+
6+
### Features
7+
8+
* **reliability:** integrate the ryuk container for better container cleanup ([#314](https://github.com/testcontainers/testcontainers-python/issues/314)) ([d019874](https://github.com/testcontainers/testcontainers-python/commit/d0198744c3bdc97a7fe41879b54acb2f5ee7becb))
9+
10+
11+
### Bug Fixes
12+
13+
* changelog after release-please ([#469](https://github.com/testcontainers/testcontainers-python/issues/469)) ([dcb4f68](https://github.com/testcontainers/testcontainers-python/commit/dcb4f6842cbfe6e880a77b0d4aabb3f396c6dc19))
14+
* **configuration:** strip whitespaces when reading .testcontainers.properties ([#474](https://github.com/testcontainers/testcontainers-python/issues/474)) ([ade144e](https://github.com/testcontainers/testcontainers-python/commit/ade144ee2888d4044ac0c1dc627f47da92789e06))
15+
* try to fix release-please by setting a bootstrap sha ([#472](https://github.com/testcontainers/testcontainers-python/issues/472)) ([ca65a91](https://github.com/testcontainers/testcontainers-python/commit/ca65a916b719168c57c174d2af77d45fd026ec05))
16+
17+
## [4.0.1](https://github.com/testcontainers/testcontainers-python/compare/testcontainers-v4.0.0...testcontainers-v4.0.1) (2024-03-11)
18+
19+
20+
### Features
21+
22+
* **postgres:** Remove SqlAlchemy dependency from postgres container ([#445](https://github.com/testcontainers/testcontainers-python/issues/445)) ([f30eb1d](https://github.com/testcontainers/testcontainers-python/commit/f30eb1d4c98d3cc20582573b5def76d533a38b80))
23+
24+
25+
### Bug Fixes
26+
27+
* **clickhouse:** clickhouse waiting ([#428](https://github.com/testcontainers/testcontainers-python/issues/428)) ([902a5a3](https://github.com/testcontainers/testcontainers-python/commit/902a5a3d5112317782db6a9a91d9fc4bfe5701af))
28+
* Close docker client when stopping the docker container ([#380](https://github.com/testcontainers/testcontainers-python/issues/380)) ([efb1683](https://github.com/testcontainers/testcontainers-python/commit/efb16832dc0be75014c7388f9b241ae0be36ddd4))
29+
* failing tests for elasticsearch on machines with ARM CPU ([#454](https://github.com/testcontainers/testcontainers-python/issues/454)) ([701b23a](https://github.com/testcontainers/testcontainers-python/commit/701b23a7a0e4632db13e29c52141f9efc67467a1))
30+
* go back to 4.0.1 ([#465](https://github.com/testcontainers/testcontainers-python/issues/465)) ([1ac8c24](https://github.com/testcontainers/testcontainers-python/commit/1ac8c24d58e93ead951342dcc36e6f8cee2b5fa7))
31+
* **mongodb:** waiting for container to start (it was not waiting at all before?) ([#461](https://github.com/testcontainers/testcontainers-python/issues/461)) ([2c4f171](https://github.com/testcontainers/testcontainers-python/commit/2c4f171b001f0c45ff84199adf419c7a70ed81c5))
32+
* unclosed socket warning in db containers ([#378](https://github.com/testcontainers/testcontainers-python/issues/378)) ([cd90aa7](https://github.com/testcontainers/testcontainers-python/commit/cd90aa7310142059cb00f66bbc3693aedf5ddcb2))
33+
* Update the copyright header for readthedocs ([#341](https://github.com/testcontainers/testcontainers-python/issues/341)) ([5bef18a](https://github.com/testcontainers/testcontainers-python/commit/5bef18a51360a2d74ba393f86b753abdf9ec5636))
34+
35+
## [4.0.1](https://github.com/testcontainers/testcontainers-python/compare/testcontainers-v4.0.0...testcontainers-v4.0.1) (2024-03-11)
36+
37+
38+
### Features
39+
40+
* **postgres:** Remove SqlAlchemy dependency from postgres container ([#445](https://github.com/testcontainers/testcontainers-python/issues/445)) ([f30eb1d](https://github.com/testcontainers/testcontainers-python/commit/f30eb1d4c98d3cc20582573b5def76d533a38b80))
41+
42+
43+
### Bug Fixes
44+
45+
* **clickhouse:** clickhouse waiting ([#428](https://github.com/testcontainers/testcontainers-python/issues/428)) ([902a5a3](https://github.com/testcontainers/testcontainers-python/commit/902a5a3d5112317782db6a9a91d9fc4bfe5701af))
46+
* Close docker client when stopping the docker container ([#380](https://github.com/testcontainers/testcontainers-python/issues/380)) ([efb1683](https://github.com/testcontainers/testcontainers-python/commit/efb16832dc0be75014c7388f9b241ae0be36ddd4))
47+
* failing tests for elasticsearch on machines with ARM CPU ([#454](https://github.com/testcontainers/testcontainers-python/issues/454)) ([701b23a](https://github.com/testcontainers/testcontainers-python/commit/701b23a7a0e4632db13e29c52141f9efc67467a1))
48+
* **mongodb:** waiting for container to start (it was not waiting at all before?) ([#461](https://github.com/testcontainers/testcontainers-python/issues/461)) ([2c4f171](https://github.com/testcontainers/testcontainers-python/commit/2c4f171b001f0c45ff84199adf419c7a70ed81c5))
49+
* unclosed socket warning in db containers ([#378](https://github.com/testcontainers/testcontainers-python/issues/378)) ([cd90aa7](https://github.com/testcontainers/testcontainers-python/commit/cd90aa7310142059cb00f66bbc3693aedf5ddcb2))
50+
* Update the copyright header for readthedocs ([#341](https://github.com/testcontainers/testcontainers-python/issues/341)) ([5bef18a](https://github.com/testcontainers/testcontainers-python/commit/5bef18a51360a2d74ba393f86b753abdf9ec5636))
51+
52+
## [4.0.0](https://github.com/testcontainers/testcontainers-python/compare/testcontainers-v3.7.1...testcontainers-v4.0.0) (2024-03-06)
53+
54+
55+
### ⚠ BREAKING CHANGES
56+
57+
* **compose:** implement compose v2 with improved typing ([#426](https://github.com/testcontainers/testcontainers-python/issues/426))
58+
* **core:** add support for `tc.host` and de-prioritise `docker:dind` ([#388](https://github.com/testcontainers/testcontainers-python/issues/388))
59+
60+
### Features
61+
62+
* **build:** use poetry and organise modules ([#408](https://github.com/testcontainers/testcontainers-python/issues/408)) ([6c69583](https://github.com/testcontainers/testcontainers-python/commit/6c695835520bdcbf9824e8cefa00f7613d2a7cb9))
63+
* **compose:** allow running specific services in compose ([f61dcda](https://github.com/testcontainers/testcontainers-python/commit/f61dcda8bd7ea329cd3c836b6d6e2f0bd990335d))
64+
* **compose:** implement compose v2 with improved typing ([#426](https://github.com/testcontainers/testcontainers-python/issues/426)) ([5356caf](https://github.com/testcontainers/testcontainers-python/commit/5356caf2de056313a5b3f2805ed80e6a23b027a8))
65+
* **core:** add support for `tc.host` and de-prioritise `docker:dind` ([#388](https://github.com/testcontainers/testcontainers-python/issues/388)) ([2db8e6d](https://github.com/testcontainers/testcontainers-python/commit/2db8e6d123d42b57309408dd98ba9a06acc05c4b))
66+
* **redis:** support AsyncRedisContainer ([#442](https://github.com/testcontainers/testcontainers-python/issues/442)) ([cc4cb37](https://github.com/testcontainers/testcontainers-python/commit/cc4cb3762802dc75b0801727d8b1f1a1c56b7f50))
67+
* **release:** automate release via release-please ([#429](https://github.com/testcontainers/testcontainers-python/issues/429)) ([30f859e](https://github.com/testcontainers/testcontainers-python/commit/30f859eb1535acd6e93c331213426e1319ee9a47))
68+
69+
70+
### Bug Fixes
71+
72+
* Added URLError to exceptions to wait for in elasticsearch ([0f9ad24](https://github.com/testcontainers/testcontainers-python/commit/0f9ad24f2c0df362ee15b81ce8d7d36b9f98e6e1))
73+
* **build:** add `pre-commit` as a dev dependency to simplify local dev and CI ([#438](https://github.com/testcontainers/testcontainers-python/issues/438)) ([1223583](https://github.com/testcontainers/testcontainers-python/commit/1223583d8fc3a1ab95441d82c7e1ece57f026fbf))
74+
* **build:** early exit strategy for modules ([#437](https://github.com/testcontainers/testcontainers-python/issues/437)) ([7358b49](https://github.com/testcontainers/testcontainers-python/commit/7358b4919c1010315a384a8f0fe2860e5a0ca6b4))
75+
* changed files breaks on main ([#422](https://github.com/testcontainers/testcontainers-python/issues/422)) ([3271357](https://github.com/testcontainers/testcontainers-python/commit/32713578dcf07f672a87818e00562b58874b4a52))
76+
* flaky garbage collection resulting in testing errors ([#423](https://github.com/testcontainers/testcontainers-python/issues/423)) ([b535ea2](https://github.com/testcontainers/testcontainers-python/commit/b535ea255bcaaa546f8cda7b2b17718c1cc7f3ca))
77+
* rabbitmq readiness probe ([#375](https://github.com/testcontainers/testcontainers-python/issues/375)) ([71cb75b](https://github.com/testcontainers/testcontainers-python/commit/71cb75b281df55ece4d5caf5d487059a7f38c34f))
78+
* **release:** prove that the release process updates the version ([#444](https://github.com/testcontainers/testcontainers-python/issues/444)) ([87b5873](https://github.com/testcontainers/testcontainers-python/commit/87b5873c1ec3a3e4e74742417d6068fa86cf1762))
79+
* test linting issue ([427c9b8](https://github.com/testcontainers/testcontainers-python/commit/427c9b841c2f6f516ec6cb74d5bd2839cb1939f4))
80+
81+
82+
### Documentation
83+
84+
* Sphinx - Add title to each doc page ([#443](https://github.com/testcontainers/testcontainers-python/issues/443)) ([750e12a](https://github.com/testcontainers/testcontainers-python/commit/750e12a41172ce4aaf045c61dec33d318dc3c2f6))

INDEX.rst

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ testcontainers-python facilitates the use of Docker containers for functional an
2020
modules/clickhouse/README
2121
modules/elasticsearch/README
2222
modules/google/README
23+
modules/influxdb/README
2324
modules/kafka/README
2425
modules/keycloak/README
2526
modules/localstack/README
@@ -45,15 +46,33 @@ Getting Started
4546
>>> from testcontainers.postgres import PostgresContainer
4647
>>> import sqlalchemy
4748

48-
>>> with PostgresContainer("postgres:9.5") as postgres:
49-
... engine = sqlalchemy.create_engine(postgres.get_connection_url())
49+
>>> with PostgresContainer("postgres:latest") as postgres:
50+
... psql_url = postgres.get_connection_url()
51+
... engine = sqlalchemy.create_engine(psql_url)
5052
... with engine.begin() as connection:
5153
... result = connection.execute(sqlalchemy.text("select version()"))
5254
... version, = result.fetchone()
5355
>>> version
54-
'PostgreSQL 9.5...'
56+
'PostgreSQL ...'
57+
58+
The snippet above will spin up the current latest version of a postgres database in a container. The :code:`get_connection_url()` convenience method returns a :code:`sqlalchemy` compatible url (using the :code:`psycopg2` driver per default) to connect to the database and retrieve the database version.
59+
60+
.. doctest::
61+
62+
>>> import asyncpg
63+
>>> from testcontainers.postgres import PostgresContainer
64+
65+
>>> with PostgresContainer("postgres:16", driver=None) as postgres:
66+
... psql_url = container.get_connection_url()
67+
... with asyncpg.create_pool(dsn=psql_url,server_settings={"jit": "off"}) as pool:
68+
... conn = await pool.acquire()
69+
... ret = await conn.fetchval("SELECT 1")
70+
... assert ret == 1
71+
72+
This snippet does the same, however using a specific version and the driver is set to None, to influence the :code:`get_connection_url()` convenience method to not include a driver in the URL (e.g. for compatibility with :code:`psycopg` v3).
73+
74+
Note, that the :code:`sqlalchemy` and :code:`psycopg2` packages are no longer a dependency of :code:`testcontainers[postgres]` and not needed to launch the Postgres container. Your project therefore needs to declare a dependency on the used driver and db access methods you use in your code.
5575

56-
The snippet above will spin up a postgres database in a container. The :code:`get_connection_url()` convenience method returns a :code:`sqlalchemy` compatible url we use to connect to the database and retrieve the database version.
5776

5877
Installation
5978
------------
@@ -74,6 +93,21 @@ When trying to launch a testcontainer from within a Docker container, e.g., in c
7493
1. The container has to provide a docker client installation. Either use an image that has docker pre-installed (e.g. the `official docker images <https://hub.docker.com/_/docker>`_) or install the client from within the `Dockerfile` specification.
7594
2. The container has to have access to the docker daemon which can be achieved by mounting `/var/run/docker.sock` or setting the `DOCKER_HOST` environment variable as part of your `docker run` command.
7695

96+
Configuration
97+
-------------
98+
99+
+-------------------------------------------+-------------------------------+------------------------------------------+
100+
| Env Variable | Example | Description |
101+
+===========================================+===============================+==========================================+
102+
| ``TESTCONTAINERS_DOCKER_SOCKET_OVERRIDE`` | ``/var/run/docker.sock`` | Path to Docker's socket used by ryuk |
103+
+-------------------------------------------+-------------------------------+------------------------------------------+
104+
| ``TESTCONTAINERS_RYUK_PRIVILEGED`` | ``false`` | Run ryuk as a privileged container |
105+
+-------------------------------------------+-------------------------------+------------------------------------------+
106+
| ``TESTCONTAINERS_RYUK_DISABLED`` | ``false`` | Disable ryuk |
107+
+-------------------------------------------+-------------------------------+------------------------------------------+
108+
| ``RYUK_CONTAINER_IMAGE`` | ``testcontainers/ryuk:0.5.1`` | Custom image for ryuk |
109+
+-------------------------------------------+-------------------------------+------------------------------------------+
110+
77111
Development and Contributing
78112
----------------------------
79113

README.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,22 @@ For more information, see [the docs][readthedocs].
1212
>>> from testcontainers.postgres import PostgresContainer
1313
>>> import sqlalchemy
1414

15-
>>> with PostgresContainer("postgres:9.5") as postgres:
15+
>>> with PostgresContainer("postgres:16") as postgres:
1616
... engine = sqlalchemy.create_engine(postgres.get_connection_url())
1717
... with engine.begin() as connection:
1818
... result = connection.execute(sqlalchemy.text("select version()"))
1919
... version, = result.fetchone()
2020
>>> version
21-
'PostgreSQL 9.5...'
21+
'PostgreSQL 16...'
2222
```
2323

2424
The snippet above will spin up a postgres database in a container. The `get_connection_url()` convenience method returns a `sqlalchemy` compatible url we use to connect to the database and retrieve the database version.
25+
26+
## Configuration
27+
28+
| Env Variable | Example | Description |
29+
| ----------------------------------------- | ----------------------------- | ---------------------------------------- |
30+
| `TESTCONTAINERS_DOCKER_SOCKET_OVERRIDE` | `/var/run/docker.sock` | Path to Docker's socket used by ryuk |
31+
| `TESTCONTAINERS_RYUK_PRIVILEGED` | `false` | Run ryuk as a privileged container |
32+
| `TESTCONTAINERS_RYUK_DISABLED` | `false` | Disable ryuk |
33+
| `RYUK_CONTAINER_IMAGE` | `testcontainers/ryuk:0.5.1` | Custom image for ryuk |

conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252

5353
# General information about the project.
5454
project = "testcontainers"
55-
copyright = "2017, Sergey Pirogov" # noqa: A001
55+
copyright = "2017-2024, Sergey Pirogov and Testcontainers Python contributors" # noqa: A001
5656
author = "Sergey Pirogov"
5757

5858
# The version info for the project you're documenting, acts as replacement for
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# flake8: noqa
2+
from testcontainers.compose.compose import (
3+
ContainerIsNotRunning,
4+
NoSuchPortExposed,
5+
PublishedPort,
6+
ComposeContainer,
7+
DockerCompose,
8+
)

0 commit comments

Comments
 (0)