testcontainers / testcontainers-python

Testcontainers is a Python library that providing a friendly API to run Docker container. It is designed to create runtime environment to use during your automatic tests.
https://testcontainers-python.readthedocs.io/en/latest/
Apache License 2.0
1.44k stars 270 forks source link

fix(kafka): Add Kraft to Kafka containers #611

Closed jfmlima closed 1 month ago

jfmlima commented 1 month ago

Following a similar strategy as several other testcontainers implementations, this PR introduces the possibility to run Kafka in KRAft mode.

with KafkaContainer().with_kraft() as container:
    # Test something with/on KRaft mode
codecov[bot] commented 1 month ago

Codecov Report

Attention: Patch coverage is 0% with 20 lines in your changes missing coverage. Please review.

Please upload report for BASE (main@090bd0d). Learn more about missing BASE report.

:exclamation: Current head 7562f56 differs from pull request most recent head 7763552

Please upload reports for the commit 7763552 to get more accurate results.

Files Patch % Lines
core/testcontainers/core/version.py 0.00% 20 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #611 +/- ## ======================================= Coverage ? 76.91% ======================================= Files ? 11 Lines ? 602 Branches ? 86 ======================================= Hits ? 463 Misses ? 112 Partials ? 27 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

jfmlima commented 1 month ago

if you can make it pass, ill merge.

lmk if you need any help running the ci locally

Thanks, I'm using act and see how it goes, hopefully I've fixed all issues, but running locally now just in case 👍

jfmlima commented 1 month ago

if you can make it pass, ill merge.

lmk if you need any help running the ci locally

Hey @alexanderankin do you mind giving me some tips on how to run the ci locally please? act alone was not enough as it has some issues with the python setup. Thanks!

Edit: Got it, had to replace poetry installation with

- name: Install Poetry
  uses: snok/install-poetry@v1
jfmlima commented 1 month ago

@alexanderankin all sorted, feel free to re-run the ci 👍

alexanderankin commented 1 month ago

sorry for the delay in response, looks like you got it sorted. here it is anyway

python -m venv ~/.poetry-venv && source ~/.poetry-venv/bin/activate && pip install poetry && ln -s $(which poetry) ~/.local/bin # or wherever you put bins
deactivate

git clone.... && cd testcontainers-python

poetry install --with dev -E kafka
poetry shell # starts shell

make modules/kafka/tests
make modules/kafka/<tab to autocomplete>

or even just
pytest -s modules/kafka/tests

and then also remember to
pre-commit run -a