Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: testcontainers/testcontainers-python
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: testcontainers-v4.2.0
Choose a base ref
...
head repository: testcontainers/testcontainers-python
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: testcontainers-v4.3.0
Choose a head ref

Commits on Mar 24, 2024

  1. fix(kafka): wait_for_logs in kafka container to reduce lib requirement (

    #377)
    
    Use `wait_for_logs` to wait for startup instead of waiting for
    successful connection via kafka-python. Also removes the dependency on
    kafka-python.
    
    Closes #351
    
    ---------
    
    Co-authored-by: Gudjon Ragnar Brynjarsson <gudjon.brynjarsson@controlant.com>
    gudjonragnar and Gudjon Ragnar Brynjarsson authored Mar 24, 2024
    Copy the full SHA
    909107b View commit details
  2. fix(keycloak): container should use dedicated API endpoints to determ…

    …ine container readiness (#490)
    
    As decided to support v18.0 image or newer, we should use these
    dedicated API endpoints to determine container readiness. These
    endpoints became introduced with v18.0.
    max-pfeiffer authored Mar 24, 2024
    Copy the full SHA
    2e27225 View commit details

Commits on Mar 27, 2024

  1. feat(client): Add custom User-Agent in Docker client as `tc-python/<v…

    …ersion>` (#507)
    
    Set User-Agent in format `tc-python/<version>`, `version` value is
    coming from `pyproject.toml`.
    
    The `User-Agent` header will allow to identify Testcontainers language
    implementation and the specific version. Also, track the usage of the
    library.
    eddumelendez authored Mar 27, 2024
    Copy the full SHA
    dd55082 View commit details
  2. fix: pass doctests, s/doctest/doctests/, run them in gha, s/asyncpg/p…

    …sycopg/ in doctest, fix keycloak flakiness: wait for first user (#505)
    
    Doctests are run as interpreted code from docstrings. In order to run
    these tests, libraries need to be available for the example code, and
    usage of async code either needs to be wrapped in an `asyncio` call or
    avoided completely.
    
    This PR fixes up all failing doctests and makes `make doctests` target
    run successfully again.
    Summary:
    - Renames Make target `doctest` to `doctests` to follow naming
    convention from `tests` target
    - Adds `doctests` step to Github Action workflow runs
    - Replaces `asyncpg` example from `index.rst` with `psycopg` to be able
    to run as a doctest. Also added `psycopg` as dev dependency (`asyncpg`
    was already missing from here)
    - Fixes Keycloak doctest by providing expected output, also did the same
    for regular test
    - Also: Fixed `wait_for_container` method in `Keycloak` module to
    actually wait for the first user to be created (in order to be able to
    authenticate at all) before returning the started container, if the
    command is `dev-start`. This is needed in order to prevent race
    conditions in flaky tests and for the sample usage code.
    santi authored Mar 27, 2024
    Copy the full SHA
    545240d View commit details

Commits on Mar 29, 2024

  1. fix(core): allow setting docker command path for docker compose (#512)

    fix #306
    
    the original request was to remedy tc-python's dependency on
    docker-compose.
    
    this is something totally different but its what was asked for, so oh
    well. ¯\_(ツ)_/¯.
    alexanderankin authored Mar 29, 2024
    Copy the full SHA
    63fcd52 View commit details

Commits on Mar 30, 2024

  1. chore(build): improve devcontainers setup with poetry (#506)

    1. Replaces uses an image directly.
    2. Creates a custom image, still based off the original Image.
    3. Installs poetry inside the container. This saves the user about 20
    seconds every container load.
    4. Installs `pre-commit` in the container. Saves more time.
    5. Enables `pre-commit`. From inside the container the user cannot
    commit without `pre-commit` running.
    6. Adds in git autocomplete to the container (see screenshot)
    7. Adds in poetry autocomplete to the container (see screenshot)
    
    ![devcontainer-completion](https://github.com/testcontainers/testcontainers-python/assets/1908139/11446f78-4fbf-4d08-a997-043ae1632919)
    
    ---------
    
    Co-authored-by: bstrausser <bstrausser@locusrobotics.com>
    Co-authored-by: David Ankin <daveankin@gmail.com>
    Co-authored-by: Bálint Bartha <39852431+totallyzen@users.noreply.github.com>
    4 people authored Mar 30, 2024
    Copy the full SHA
    8fb4bcc View commit details
  2. fix: pass updated keyword args to Publisher/Subscriber client in goog…

    …le/pubsub #161 (#164)
    
    …le/pubsub
    
    ---------
    
    Co-authored-by: David Ankin <daveankin@gmail.com>
    Mohsin-Ul-Islam and alexanderankin authored Mar 30, 2024
    Copy the full SHA
    8addc11 View commit details
  3. fix(google): add support for Datastore emulator (#508)

    Expands the google module with a DatastoreContainer using the beta
    Datastore emulator using the same image as the PubSubContainer.
    
    Im already using a local copy of this in production. It would be nice to
    not have to support copy paste solutions and instead see it added to the
    google module. This is my first PR so please let me know what I need to
    do to get this over the line. Thanks.
    
    Looks like @tillahoffmann wrote the original PubSub emulator container
    
    ---------
    
    Co-authored-by: Matt Oates <matt.oates@biorelate.com>
    Co-authored-by: David Ankin <daveankin@gmail.com>
    3 people authored Mar 30, 2024
    Copy the full SHA
    3d891a5 View commit details
  4. fix: Add Weaviate module (#492)

    This PR adds Weaviate module.
    
    ---------
    
    Co-authored-by: David Ankin <daveankin@gmail.com>
    antas-marcin and alexanderankin authored Mar 30, 2024
    Copy the full SHA
    90762e8 View commit details
  5. fix(ryuk): Enable Ryuk test suite. Ryuk image 0.5.1 -> 0.7.0. Add RYU…

    …K_RECONNECTION_TIMEOUT env variable (#509)
    
    - Re-enables the Ryuk test suite
    - Bumps Ryuk container image from 0.5.1 - > 0.7.0
    - Add env variable `RYUK_RECONNECTION_TIMEOUT` (As documented in the
    [official Ryuk
    repo](https://github.com/testcontainers/moby-ryuk?tab=readme-ov-file#ryuk-configuration))
    santi authored Mar 30, 2024
    Copy the full SHA
    472b2c2 View commit details
  6. fix: inconsistent test runs for community modules (#497)

    - Fixed inconsistencies for community module test runs: using all
    supported Python versions
    - Pinned runner version (best practice)
    
    fixes #482
    max-pfeiffer authored Mar 30, 2024
    Copy the full SHA
    914f1e5 View commit details
  7. fix: add chroma container (#515)

    based on #477
    
    ---------
    
    Co-authored-by: Trayan Azarov <trayan.azarov@amikos.tech>
    alexanderankin and tazarov authored Mar 30, 2024
    Copy the full SHA
    0729bf4 View commit details

Commits on Mar 31, 2024

  1. fix: Add CassandraContainer (#476)

    Co-authored-by: David Ankin <daveankin@gmail.com>
    cbornet and alexanderankin authored Mar 31, 2024
    Copy the full SHA
    507e466 View commit details
  2. fix: Qdrant module (#463)

    This PR adds a module to spawn a [Qdrant](https://qdrant.tech) test
    container.
    
    ---------
    
    Co-authored-by: David Ankin <daveankin@gmail.com>
    Anush008 and alexanderankin authored Mar 31, 2024
    Copy the full SHA
    e8876f4 View commit details
  3. fix(nats): Client-Free(ish) NATS container (#462)

    Co-authored-by: bstrausser <bstrausser@locusrobotics.com>
    Co-authored-by: David Ankin <daveankin@gmail.com>
    3 people authored Mar 31, 2024
    Copy the full SHA
    302c73d View commit details
  4. fix(kafka): Add redpanda testcontainer module (#441)

    Co-authored-by: Gudjon Ragnar Brynjarsson <gudjon.brynjarsson@controlant.com>
    Co-authored-by: Dave Ankin <daveankin@gmail.com>
    3 people authored Mar 31, 2024
    Copy the full SHA
    451d278 View commit details
  5. fix(new): add a new Docker Registry test container (#389)

    I added a new test container for spinning up a [Docker
    registry](https://hub.docker.com/_/registry).
    max-pfeiffer authored Mar 31, 2024
    Copy the full SHA
    0f554fb View commit details
  6. fix: Improved Oracle DB module (#363)

    Hi,
    
    I took the liberty to improve the Oracle DB module for Testcontainers
    Python. The PR has several enhancements:
    
    * Leveraging `oracledb` thin Python driver
        * This makes Oracle DB tests on CI/CD now possible too
    * Usage of `gvenzl/oracle-free` image with the latest and greatest
    Oracle DB version
    * DB version independent readiness check
    * Support for various `gvenzl/oracle-free` image features
    (`ORACLE_DATABASE`, `APP_USER`, `APP_USER_PASSWORD`, etc)
    * Tests for Oracle DB for the various combinations
    
    Ideally, some more documentation on how the Container is supposed to be
    used would be handy but I couldn't really find a good example of how
    such a ReadMe should be structured.
    Any things are gladly appreciated!
    
    ---------
    
    Signed-off-by: gvenzl <gerald.venzl@gmail.com>
    Signed-off-by: Gerald Venzl <gerald.venzl@gmail.com>
    Co-authored-by: David Ankin <daveankin@gmail.com>
    gvenzl and alexanderankin authored Mar 31, 2024
    Copy the full SHA
    6e6d8e3 View commit details
  7. Copy the full SHA
    dee20a7 View commit details

Commits on Apr 1, 2024

  1. Copy the full SHA
    bddbaeb View commit details
  2. chore(main): release testcontainers 4.3.0 (#500)

    🤖 I have created a release *beep* *boop*
    ---
    
    
    ##
    [4.3.0](testcontainers-v4.2.0...testcontainers-v4.3.0)
    (2024-04-01)
    
    
    ### Features
    
    * **client:** Add custom User-Agent in Docker client as
    `tc-python/&lt;version&gt;`
    ([#507](#507))
    ([dd55082](dd55082))
    
    
    ### Bug Fixes
    
    * Add CassandraContainer
    ([#476](#476))
    ([507e466](507e466))
    * add chroma container
    ([#515](#515))
    ([0729bf4](0729bf4))
    * Add Weaviate module
    ([#492](#492))
    ([90762e8](90762e8))
    * **cassandra:** make cassandra dependency optional/test-only
    ([#518](#518))
    ([bddbaeb](bddbaeb))
    * **core:** allow setting docker command path for docker compose
    ([#512](#512))
    ([63fcd52](63fcd52))
    * **google:** add support for Datastore emulator
    ([#508](#508))
    ([3d891a5](3d891a5))
    * Improved Oracle DB module
    ([#363](#363))
    ([6e6d8e3](6e6d8e3))
    * inconsistent test runs for community modules
    ([#497](#497))
    ([914f1e5](914f1e5))
    * **kafka:** Add redpanda testcontainer module
    ([#441](#441))
    ([451d278](451d278))
    * **kafka:** wait_for_logs in kafka container to reduce lib requirement
    ([#377](#377))
    ([909107b](909107b))
    * **keycloak:** container should use dedicated API endpoints to
    determine container readiness
    ([#490](#490))
    ([2e27225](2e27225))
    * **nats:** Client-Free(ish) NATS container
    ([#462](#462))
    ([302c73d](302c73d))
    * **new:** add a new Docker Registry test container
    ([#389](#389))
    ([0f554fb](0f554fb))
    * pass doctests, s/doctest/doctests/, run them in gha,
    s/asyncpg/psycopg/ in doctest, fix keycloak flakiness: wait for first
    user
    ([#505](#505))
    ([545240d](545240d))
    * pass updated keyword args to Publisher/Subscriber client in
    google/pubsub
    [#161](#161)
    ([#164](#164))
    ([8addc11](8addc11))
    * Qdrant module
    ([#463](#463))
    ([e8876f4](e8876f4))
    * remove accidentally added pip in dev dependencies
    ([#516](#516))
    ([dee20a7](dee20a7))
    * **ryuk:** Enable Ryuk test suite. Ryuk image 0.5.1 -&gt; 0.7.0. Add
    RYUK_RECONNECTION_TIMEOUT env variable
    ([#509](#509))
    ([472b2c2](472b2c2))
    
    ---
    This PR was generated with [Release
    Please](https://github.com/googleapis/release-please). See
    [documentation](https://github.com/googleapis/release-please#release-please).
    
    Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
    github-actions[bot] authored Apr 1, 2024
    Copy the full SHA
    f819c7a View commit details
Showing with 2,549 additions and 189 deletions.
  1. +20 −0 .devcontainer/Dockerfile
  2. +1 −2 .devcontainer/commands/post-create-command.sh
  3. +7 −1 .devcontainer/devcontainer.json
  4. +1 −1 .github/.release-please-manifest.json
  5. +1 −0 .github/settings.yml
  6. +5 −3 .github/workflows/ci-community.yml
  7. +3 −2 .github/workflows/ci-core.yml
  8. +1 −1 .github/workflows/ci-lint.yml
  9. +1 −1 .github/workflows/docs.yml
  10. +1 −1 .github/workflows/pr-lint.yml
  11. +2 −2 .github/workflows/release-please.yml
  12. +29 −0 CHANGELOG.md
  13. +3 −3 Makefile
  14. +7 −6 README.md
  15. +6 −1 conf.py
  16. +2 −1 core/testcontainers/compose/compose.py
  17. +2 −1 core/testcontainers/core/config.py
  18. +14 −3 core/testcontainers/core/container.py
  19. +2 −0 core/testcontainers/core/docker_client.py
  20. +40 −19 core/tests/test_ryuk.py
  21. +20 −14 index.rst
  22. +2 −0 modules/cassandra/README.rst
  23. +62 −0 modules/cassandra/testcontainers/cassandra/__init__.py
  24. +14 −0 modules/cassandra/tests/test_cassandra.py
  25. +2 −0 modules/chroma/README.rst
  26. +81 −0 modules/chroma/testcontainers/chroma/__init__.py
  27. +9 −0 modules/chroma/tests/test_chroma.py
  28. +2 −0 modules/google/README.rst
  29. +1 −0 modules/google/testcontainers/google/__init__.py
  30. +68 −0 modules/google/testcontainers/google/datastore.py
  31. +8 −0 modules/google/testcontainers/google/pubsub.py
  32. +48 −1 modules/google/tests/test_google.py
  33. +1 −0 modules/kafka/README.rst
  34. +9 −12 modules/kafka/testcontainers/kafka/__init__.py
  35. +82 −0 modules/kafka/testcontainers/kafka/_redpanda.py
  36. +54 −0 modules/kafka/tests/test_redpanda.py
  37. +18 −7 modules/keycloak/testcontainers/keycloak/__init__.py
  38. +5 −3 modules/keycloak/tests/test_keycloak.py
  39. +2 −0 modules/nats/README.rst
  40. +75 −0 modules/nats/testcontainers/nats/__init__.py
  41. +87 −0 modules/nats/tests/test_nats.py
  42. 0 modules/{oracle → oracle-free}/README.rst
  43. +76 −0 modules/oracle-free/testcontainers/oracle/__init__.py
  44. +81 −0 modules/oracle-free/tests/test_oracle.py
  45. +0 −33 modules/oracle/testcontainers/oracle/__init__.py
  46. +0 −20 modules/oracle/tests/test_oracle.py
  47. +1 −2 modules/postgres/testcontainers/postgres/__init__.py
  48. +0 −2 modules/postgres/tests/test_postgres.py
  49. +2 −0 modules/qdrant/README.rst
  50. +156 −0 modules/qdrant/testcontainers/qdrant/__init__.py
  51. +6 −0 modules/qdrant/tests/test_config.yaml
  52. +80 −0 modules/qdrant/tests/test_qdrant.py
  53. +8 −0 modules/registry/README.rst
  54. +77 −0 modules/registry/testcontainers/registry/__init__.py
  55. +27 −0 modules/registry/tests/test_registry.py
  56. +2 −0 modules/weaviate/README.rst
  57. +178 −0 modules/weaviate/testcontainers/weaviate/__init__.py
  58. +55 −0 modules/weaviate/tests/test_weaviate.py
  59. +968 −37 poetry.lock
  60. +34 −10 pyproject.toml
20 changes: 20 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
FROM mcr.microsoft.com/devcontainers/python:1-3.11-bookworm


RUN \
apt update && apt install bash-completion -y && \
pip install pre-commit && \
curl -sSL https://install.python-poetry.org | POETRY_HOME=/home/vscode/.local python3 -


RUN \
echo >> /home/vscode/.bashrc && \
# add completions to bashrc
# see how ubuntu does it for reference:
# https://git.launchpad.net/ubuntu/+source/base-files/tree/share/dot.bashrc
# https://stackoverflow.com/a/68566555
echo 'if [ -f /etc/bash_completion ] && ! shopt -oq posix; then' >> /home/vscode/.bashrc && \
echo ' . /etc/bash_completion' >> /home/vscode/.bashrc && \
echo 'fi' >> /home/vscode/.bashrc && \
echo >> /home/vscode/.bashrc && \
echo '. <(poetry completions)' >> /home/vscode/.bashrc
3 changes: 1 addition & 2 deletions .devcontainer/commands/post-create-command.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
echo "Running post-create-command.sh"

curl -sSL https://install.python-poetry.org | python3 -

pre-commit install
poetry install --all-extras
8 changes: 7 additions & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -3,7 +3,13 @@
{
"name": "Python 3",
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
"image": "mcr.microsoft.com/devcontainers/python:1-3.11-bookworm",
"build": {
// Path is relative to the devcontainer.json file.
// We prebuild the image to get poetry into the image
// This saves the user a bit of time, when re-opening containers
"dockerfile": "Dockerfile"
},

"features": {
"ghcr.io/devcontainers/features/docker-in-docker:2": {
"version": "latest",
2 changes: 1 addition & 1 deletion .github/.release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "4.2.0"
".": "4.3.0"
}
1 change: 1 addition & 0 deletions .github/settings.yml
Original file line number Diff line number Diff line change
@@ -63,6 +63,7 @@ labels:
- { name: '🐧 linux', color: '#3ED4D',, description: '' }
- { name: '👀 requires attention', color: '#fef2c0', description: '' }
- { name: '📖 documentation', color: '#d93f0b', description: '' }
- { name: '📦 package: cassandra', color: '#0052CC', description: '' }
- { name: '📦 package: clickhouse', color: '#0052CC', description: '' }
- { name: '📦 package: compose', color: '#0052CC', description: '' }
- { name: '📦 package: core', color: '#0052CC', description: '' }
8 changes: 5 additions & 3 deletions .github/workflows/ci-community.yml
Original file line number Diff line number Diff line change
@@ -14,7 +14,7 @@ on:

jobs:
track-modules:
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
steps:
- name: Checkout contents
uses: actions/checkout@v4
@@ -38,14 +38,14 @@ jobs:
outputs:
changed_modules: ${{ steps.compute-changes.outputs.computed_modules }}
test:
runs-on: ubuntu-22.04
needs: [track-modules]
if: ${{ needs.track-modules.outputs.changed_modules != '[]' }}
strategy:
fail-fast: false
matrix:
python-version: [ "3.11" ]
python-version: ["3.9", "3.10", "3.11", "3.12"]
module: ${{ fromJSON(needs.track-modules.outputs.changed_modules) }}
runs-on: ubuntu-latest
steps:
- name: Checkout contents
uses: actions/checkout@v4
@@ -57,3 +57,5 @@ jobs:
run: poetry install -E ${{ matrix.module }}
- name: Run tests
run: make modules/${{ matrix.module }}/tests
- name: Run doctests
run: make modules/${{ matrix.module }}/doctests
5 changes: 3 additions & 2 deletions .github/workflows/ci-core.yml
Original file line number Diff line number Diff line change
@@ -10,12 +10,11 @@ on:

jobs:
test:
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
os: [ ubuntu ]
python-version: ["3.9", "3.10", "3.11", "3.12"]
runs-on: ${{ matrix.os }}-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
@@ -28,3 +27,5 @@ jobs:
run: poetry build && poetry run twine check dist/*.tar.gz
- name: Run tests
run: make core/tests
- name: Run doctests
run: make core/doctests
2 changes: 1 addition & 1 deletion .github/workflows/ci-lint.yml
Original file line number Diff line number Diff line change
@@ -10,7 +10,7 @@ on:

jobs:
python:
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- name: Setup Env
2 changes: 1 addition & 1 deletion .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@ on:

jobs:
build:
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- name: Set up Python
2 changes: 1 addition & 1 deletion .github/workflows/pr-lint.yml
Original file line number Diff line number Diff line change
@@ -13,7 +13,7 @@ permissions:
jobs:
validate:
name: validate-pull-request-title
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
steps:
- name: validate pull request title
uses: kontrolplane/pull-request-title-validator@ab2b54babb5337246f4b55cf8e0a1ecb0575e46d #v1
4 changes: 2 additions & 2 deletions .github/workflows/release-please.yml
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@ on:

jobs:
release:
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
outputs:
release_created: ${{ steps.track-release.outputs.release_created }}
steps:
@@ -16,7 +16,7 @@ jobs:
manifest-file: .github/.release-please-manifest.json
config-file: .github/release-please-config.json
publish:
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
environment: release
permissions:
id-token: write
29 changes: 29 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,34 @@
# Changelog

## [4.3.0](https://github.com/testcontainers/testcontainers-python/compare/testcontainers-v4.2.0...testcontainers-v4.3.0) (2024-04-01)


### Features

* **client:** Add custom User-Agent in Docker client as `tc-python/&lt;version&gt;` ([#507](https://github.com/testcontainers/testcontainers-python/issues/507)) ([dd55082](https://github.com/testcontainers/testcontainers-python/commit/dd55082991b3405038a90678a39e8c815f0d1fc8))


### Bug Fixes

* Add CassandraContainer ([#476](https://github.com/testcontainers/testcontainers-python/issues/476)) ([507e466](https://github.com/testcontainers/testcontainers-python/commit/507e466a1fa9ac64c254ceb9ae0d57f6bfd8c89d))
* add chroma container ([#515](https://github.com/testcontainers/testcontainers-python/issues/515)) ([0729bf4](https://github.com/testcontainers/testcontainers-python/commit/0729bf4af957f8b6638cc204b108358745c0cfc9))
* Add Weaviate module ([#492](https://github.com/testcontainers/testcontainers-python/issues/492)) ([90762e8](https://github.com/testcontainers/testcontainers-python/commit/90762e817bf49de6d6366212fb48e7edb67ab0c6))
* **cassandra:** make cassandra dependency optional/test-only ([#518](https://github.com/testcontainers/testcontainers-python/issues/518)) ([bddbaeb](https://github.com/testcontainers/testcontainers-python/commit/bddbaeb20cbd147c429f8020395355402b8a7268))
* **core:** allow setting docker command path for docker compose ([#512](https://github.com/testcontainers/testcontainers-python/issues/512)) ([63fcd52](https://github.com/testcontainers/testcontainers-python/commit/63fcd52ec2d6ded5f6413166a3690c1138e4dae0))
* **google:** add support for Datastore emulator ([#508](https://github.com/testcontainers/testcontainers-python/issues/508)) ([3d891a5](https://github.com/testcontainers/testcontainers-python/commit/3d891a5ec62944d01d1bf3d6f70e6aec83f6e516))
* Improved Oracle DB module ([#363](https://github.com/testcontainers/testcontainers-python/issues/363)) ([6e6d8e3](https://github.com/testcontainers/testcontainers-python/commit/6e6d8e3c919be3efa581704868193e66da54acf3))
* inconsistent test runs for community modules ([#497](https://github.com/testcontainers/testcontainers-python/issues/497)) ([914f1e5](https://github.com/testcontainers/testcontainers-python/commit/914f1e55bcb3b10260788c3affb8426f77eb9036))
* **kafka:** Add redpanda testcontainer module ([#441](https://github.com/testcontainers/testcontainers-python/issues/441)) ([451d278](https://github.com/testcontainers/testcontainers-python/commit/451d27865873bb75f4a09a26442572745408d013))
* **kafka:** wait_for_logs in kafka container to reduce lib requirement ([#377](https://github.com/testcontainers/testcontainers-python/issues/377)) ([909107b](https://github.com/testcontainers/testcontainers-python/commit/909107b221417a39516f961364beb518d2756f45))
* **keycloak:** container should use dedicated API endpoints to determine container readiness ([#490](https://github.com/testcontainers/testcontainers-python/issues/490)) ([2e27225](https://github.com/testcontainers/testcontainers-python/commit/2e272253148797759748bd40c42f797697d3163f))
* **nats:** Client-Free(ish) NATS container ([#462](https://github.com/testcontainers/testcontainers-python/issues/462)) ([302c73d](https://github.com/testcontainers/testcontainers-python/commit/302c73ddaa7a6b5bc071ab0cc36d15461cae348b))
* **new:** add a new Docker Registry test container ([#389](https://github.com/testcontainers/testcontainers-python/issues/389)) ([0f554fb](https://github.com/testcontainers/testcontainers-python/commit/0f554fbaa9511e0221806f57de971abedf1c0bf2))
* pass doctests, s/doctest/doctests/, run them in gha, s/asyncpg/psycopg/ in doctest, fix keycloak flakiness: wait for first user ([#505](https://github.com/testcontainers/testcontainers-python/issues/505)) ([545240d](https://github.com/testcontainers/testcontainers-python/commit/545240dfdcb2a565ad7cef0e9813f03b9b6f910e))
* pass updated keyword args to Publisher/Subscriber client in google/pubsub [#161](https://github.com/testcontainers/testcontainers-python/issues/161) ([#164](https://github.com/testcontainers/testcontainers-python/issues/164)) ([8addc11](https://github.com/testcontainers/testcontainers-python/commit/8addc111c94826c2a619a0880d48550673f4d7b9))
* Qdrant module ([#463](https://github.com/testcontainers/testcontainers-python/issues/463)) ([e8876f4](https://github.com/testcontainers/testcontainers-python/commit/e8876f422abeb29a7236f2174f7e7a324b7d26cb))
* remove accidentally added pip in dev dependencies ([#516](https://github.com/testcontainers/testcontainers-python/issues/516)) ([dee20a7](https://github.com/testcontainers/testcontainers-python/commit/dee20a76c88445b911d38b4704c2380114a66794))
* **ryuk:** Enable Ryuk test suite. Ryuk image 0.5.1 -&gt; 0.7.0. Add RYUK_RECONNECTION_TIMEOUT env variable ([#509](https://github.com/testcontainers/testcontainers-python/issues/509)) ([472b2c2](https://github.com/testcontainers/testcontainers-python/commit/472b2c24aec232a04c00dd7dcd9a9f05f2dfaa66))

## [4.2.0](https://github.com/testcontainers/testcontainers-python/compare/testcontainers-v4.1.0...testcontainers-v4.2.0) (2024-03-24)


6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -11,7 +11,7 @@ UPLOAD = $(addsuffix /upload,${PACKAGES})
# All */tests folders for each of the test suites.
TESTS = $(addsuffix /tests,$(filter-out meta,${PACKAGES}))
TESTS_DIND = $(addsuffix -dind,${TESTS})
DOCTESTS = $(addsuffix /doctest,$(filter-out meta,${PACKAGES}))
DOCTESTS = $(addsuffix /doctests,$(filter-out modules/README.md,${PACKAGES}))
# All linting targets.
LINT = $(addsuffix /lint,${PACKAGES})

@@ -56,10 +56,10 @@ ${TESTS_DIND} : %/tests-dind : image
docs :
poetry run sphinx-build -nW . docs/_build

doctest : ${DOCTESTS}
doctests : ${DOCTESTS}
poetry run sphinx-build -b doctest . docs/_build

${DOCTESTS} : %/doctest :
${DOCTESTS} : %/doctests :
poetry run sphinx-build -b doctest -c doctests $* docs/_build

# Remove any generated files.
13 changes: 7 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -25,9 +25,10 @@ The snippet above will spin up a postgres database in a container. The `get_conn

## Configuration

| Env Variable | Example | Description |
| ----------------------------------------- | ----------------------------- | ---------------------------------------- |
| `TESTCONTAINERS_DOCKER_SOCKET_OVERRIDE` | `/var/run/docker.sock` | Path to Docker's socket used by ryuk |
| `TESTCONTAINERS_RYUK_PRIVILEGED` | `false` | Run ryuk as a privileged container |
| `TESTCONTAINERS_RYUK_DISABLED` | `false` | Disable ryuk |
| `RYUK_CONTAINER_IMAGE` | `testcontainers/ryuk:0.5.1` | Custom image for ryuk |
| Env Variable | Example | Description |
| --------------------------------------- | --------------------------- | ---------------------------------------------------------------------------------- |
| `TESTCONTAINERS_DOCKER_SOCKET_OVERRIDE` | `/var/run/docker.sock` | Path to Docker's socket used by ryuk |
| `TESTCONTAINERS_RYUK_PRIVILEGED` | `false` | Run ryuk as a privileged container |
| `TESTCONTAINERS_RYUK_DISABLED` | `false` | Disable ryuk |
| `RYUK_CONTAINER_IMAGE` | `testcontainers/ryuk:0.7.0` | Custom image for ryuk |
| `RYUK_RECONNECTION_TIMEOUT` | `10s` | Reconnection timeout for Ryuk TCP socket before Ryuk reaps all dangling containers |
7 changes: 6 additions & 1 deletion conf.py
Original file line number Diff line number Diff line change
@@ -31,6 +31,7 @@
extensions = [
"sphinx.ext.autodoc",
"sphinx.ext.doctest",
"sphinx.ext.intersphinx",
"sphinx.ext.napoleon",
]

@@ -74,7 +75,7 @@
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This patterns also effect to html_static_path and html_extra_path
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store", "meta/README.rst", ".venv"]
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store", ".venv", ".git"]

# The name of the Pygments (syntax highlighting) style to use.
pygments_style = "sphinx"
@@ -156,3 +157,7 @@
"Miscellaneous",
),
]

intersphinx_mapping = {
"python": ("https://docs.python.org/3", None),
}
3 changes: 2 additions & 1 deletion core/testcontainers/compose/compose.py
Original file line number Diff line number Diff line change
@@ -158,6 +158,7 @@ class DockerCompose:
wait: bool = True
env_file: Optional[str] = None
services: Optional[list[str]] = None
docker_command_path: Optional[str] = None

def __post_init__(self):
if isinstance(self.compose_file_name, str):
@@ -181,7 +182,7 @@ def docker_compose_command(self) -> list[str]:

@cached_property
def compose_command_property(self) -> list[str]:
docker_compose_cmd = ["docker", "compose"]
docker_compose_cmd = [self.docker_command_path or "docker", "compose"]
if self.compose_file_name:
for file in self.compose_file_name:
docker_compose_cmd += ["-f", file]
3 changes: 2 additions & 1 deletion core/testcontainers/core/config.py
Original file line number Diff line number Diff line change
@@ -4,7 +4,8 @@
SLEEP_TIME = int(environ.get("TC_POOLING_INTERVAL", 1))
TIMEOUT = MAX_TRIES * SLEEP_TIME

RYUK_IMAGE: str = environ.get("RYUK_CONTAINER_IMAGE", "testcontainers/ryuk:0.5.1")
RYUK_IMAGE: str = environ.get("RYUK_CONTAINER_IMAGE", "testcontainers/ryuk:0.7.0")
RYUK_PRIVILEGED: bool = environ.get("TESTCONTAINERS_RYUK_PRIVILEGED", "false") == "true"
RYUK_DISABLED: bool = environ.get("TESTCONTAINERS_RYUK_DISABLED", "false") == "true"
RYUK_DOCKER_SOCKET: str = environ.get("TESTCONTAINERS_DOCKER_SOCKET_OVERRIDE", "/var/run/docker.sock")
RYUK_RECONNECTION_TIMEOUT: str = environ.get("RYUK_RECONNECTION_TIMEOUT", "10s")
17 changes: 14 additions & 3 deletions core/testcontainers/core/container.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
import contextlib
from platform import system
from socket import socket
from typing import TYPE_CHECKING, Optional

from testcontainers.core.config import RYUK_DISABLED, RYUK_DOCKER_SOCKET, RYUK_IMAGE, RYUK_PRIVILEGED
import docker.errors

from testcontainers.core.config import (
RYUK_DISABLED,
RYUK_DOCKER_SOCKET,
RYUK_IMAGE,
RYUK_PRIVILEGED,
RYUK_RECONNECTION_TIMEOUT,
)
from testcontainers.core.docker_client import DockerClient
from testcontainers.core.exceptions import ContainerStartException
from testcontainers.core.labels import LABEL_SESSION_ID, SESSION_ID
@@ -177,8 +186,9 @@ def delete_instance(cls) -> None:
Reaper._socket.close()
Reaper._socket = None

if Reaper._container is not None:
Reaper._container.stop()
if Reaper._container is not None and Reaper._container._container is not None:
with contextlib.suppress(docker.errors.NotFound):
Reaper._container.stop()
Reaper._container = None

if Reaper._instance is not None:
@@ -194,6 +204,7 @@ def _create_instance(cls) -> "Reaper":
.with_exposed_ports(8080)
.with_volume_mapping(RYUK_DOCKER_SOCKET, "/var/run/docker.sock", "rw")
.with_kwargs(privileged=RYUK_PRIVILEGED, auto_remove=True)
.with_env("RYUK_RECONNECTION_TIMEOUT", RYUK_RECONNECTION_TIMEOUT)
.start()
)
wait_for_logs(Reaper._container, r".* Started!")
2 changes: 2 additions & 0 deletions core/testcontainers/core/docker_client.py
Original file line number Diff line number Diff line change
@@ -11,6 +11,7 @@
# License for the specific language governing permissions and limitations
# under the License.
import functools as ft
import importlib.metadata
import ipaddress
import os
import urllib
@@ -44,6 +45,7 @@ def __init__(self, **kwargs) -> None:
else:
self.client = docker.from_env(**kwargs)
self.client.api.headers["x-tc-sid"] = SESSION_ID
self.client.api.headers["User-Agent"] = "tc-python/" + importlib.metadata.version("testcontainers")

@ft.wraps(ContainerCollection.run)
def run(
Loading