Skip to content

Commit 2113561

Browse files
Merge branch 'main' into reusable_containers
2 parents 7c1e8e7 + b1642e9 commit 2113561

File tree

9 files changed

+39
-12
lines changed

9 files changed

+39
-12
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
".": "4.9.0"
2+
".": "4.9.1"
33
}

.github/CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ You need to have the following tools available to you:
3333
- Run `make install` to get `poetry` to install all dependencies and set up `pre-commit`
3434
- **Recommended**: Run `make` or `make help` to see other commands available to you.
3535
- After this, you should have a working virtual environment and proceed with writing code with your favourite IDE
36-
- **TIP**: You can run `make core/tests` or `make module/<my-module>/tests` to run the tests specifically for that to speed up feedback cycles
36+
- **TIP**: You can run `make core/tests` or `make modules/<my-module>/tests` to run the tests specifically for that to speed up feedback cycles
3737
- You can also run `make lint` to run the `pre-commit` for the entire codebase.
3838

3939

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
# Changelog
22

3+
## [4.9.1](https://github.com/testcontainers/testcontainers-python/compare/testcontainers-v4.9.0...testcontainers-v4.9.1) (2025-01-21)
4+
5+
6+
### Bug Fixes
7+
8+
* milvus healthcheck: use correct requests errors ([#759](https://github.com/testcontainers/testcontainers-python/issues/759)) ([78b137c](https://github.com/testcontainers/testcontainers-python/commit/78b137cfe53fc81eb8d5d858e98610fb6a8792ad))
9+
* **mysql:** add dialect parameter instead of hardcoded mysql dialect ([#739](https://github.com/testcontainers/testcontainers-python/issues/739)) ([8d77bd3](https://github.com/testcontainers/testcontainers-python/commit/8d77bd3541e1c5e73c7ed5d5bd3c0d7bb617f5c0))
10+
* **tests:** replace dind-test direct docker usage with sdk ([#750](https://github.com/testcontainers/testcontainers-python/issues/750)) ([ace2a7d](https://github.com/testcontainers/testcontainers-python/commit/ace2a7d143fb80576ddc0859a9106aa8652f2356))
11+
312
## [4.9.0](https://github.com/testcontainers/testcontainers-python/compare/testcontainers-v4.8.2...testcontainers-v4.9.0) (2024-11-26)
413

514

core/testcontainers/core/labels.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,15 @@ def create_labels(image: str, labels: Optional[dict[str, str]]) -> dict[str, str
2121
if k.startswith(TESTCONTAINERS_NAMESPACE):
2222
raise ValueError("The org.testcontainers namespace is reserved for internal use")
2323

24-
labels[LABEL_LANG] = "python"
25-
labels[LABEL_TESTCONTAINERS] = "true"
26-
labels[LABEL_VERSION] = importlib.metadata.version("testcontainers")
24+
tc_labels = {
25+
**labels,
26+
LABEL_LANG: "python",
27+
LABEL_TESTCONTAINERS: "true",
28+
LABEL_VERSION: importlib.metadata.version("testcontainers"),
29+
}
2730

2831
if image == c.ryuk_image:
29-
return labels
32+
return tc_labels
3033

31-
labels[LABEL_SESSION_ID] = SESSION_ID
32-
return labels
34+
tc_labels[LABEL_SESSION_ID] = SESSION_ID
35+
return tc_labels

core/tests/test_labels.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,10 @@ def test_session_are_module_import_scoped():
5656
assert LABEL_SESSION_ID in first_labels
5757
assert LABEL_SESSION_ID in second_labels
5858
assert first_labels[LABEL_SESSION_ID] == second_labels[LABEL_SESSION_ID]
59+
60+
61+
def test_create_no_side_effects():
62+
input_labels = {"key": "value"}
63+
expected_labels = input_labels.copy()
64+
create_labels("not-ryuk", {"key": "value"})
65+
assert input_labels == expected_labels, input_labels

modules/keycloak/testcontainers/keycloak/__init__.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@
2020
from testcontainers.core.waiting_utils import wait_container_is_ready, wait_for_logs
2121

2222
_DEFAULT_DEV_COMMAND = "start-dev"
23+
# Since Keycloak v26.0.0
24+
# See: https://www.keycloak.org/server/all-config#category-bootstrap_admin
25+
ADMIN_USERNAME_ENVIRONMENT_VARIABLE = "KC_BOOTSTRAP_ADMIN_USERNAME"
26+
ADMIN_PASSWORD_ENVIRONMENT_VARIABLE = "KC_BOOTSTRAP_ADMIN_PASSWORD"
2327

2428

2529
class KeycloakContainer(DockerContainer):
@@ -57,6 +61,9 @@ def __init__(
5761
self.cmd = cmd
5862

5963
def _configure(self) -> None:
64+
self.with_env(ADMIN_USERNAME_ENVIRONMENT_VARIABLE, self.username)
65+
self.with_env(ADMIN_PASSWORD_ENVIRONMENT_VARIABLE, self.password)
66+
# legacy env vars (<= 26.0.0)
6067
self.with_env("KEYCLOAK_ADMIN", self.username)
6168
self.with_env("KEYCLOAK_ADMIN_PASSWORD", self.password)
6269
# Enable health checks
@@ -89,7 +96,8 @@ def _readiness_probe(self) -> None:
8996
response = requests.get(f"{self.get_url()}/health/ready", timeout=1)
9097
response.raise_for_status()
9198
if _DEFAULT_DEV_COMMAND in self._command:
92-
wait_for_logs(self, "Added user .* to realm .*")
99+
wait_for_logs(self, "started in \\d+\\.\\d+s")
100+
wait_for_logs(self, "Created temporary admin user|Added user '")
93101

94102
def start(self) -> "KeycloakContainer":
95103
super().start()

modules/keycloak/tests/test_keycloak.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from testcontainers.keycloak import KeycloakContainer
33

44

5-
@pytest.mark.parametrize("image_version", ["25.0", "24.0.1", "18.0"])
5+
@pytest.mark.parametrize("image_version", ["26.0.0", "25.0", "24.0.1", "18.0"])
66
def test_docker_run_keycloak(image_version: str):
77
with KeycloakContainer(f"quay.io/keycloak/keycloak:{image_version}") as keycloak_admin:
88
assert keycloak_admin.get_client().users_count() == 1

modules/milvus/testcontainers/milvus/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def _get_healthcheck_url(self) -> str:
6969
port = self.get_exposed_port(self.healthcheck_port)
7070
return f"http://{ip}:{port}"
7171

72-
@wait_container_is_ready(requests.exceptions.HTTPError)
72+
@wait_container_is_ready(requests.exceptions.HTTPError, requests.exceptions.ConnectionError)
7373
def _healthcheck(self) -> None:
7474
healthcheck_url = self._get_healthcheck_url()
7575
response = requests.get(f"{healthcheck_url}/healthz", timeout=1)

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "testcontainers"
3-
version = "4.9.0" # auto-incremented by release-please
3+
version = "4.9.1" # auto-incremented by release-please
44
description = "Python library for throwaway instances of anything that can run in a Docker container"
55
authors = ["Sergey Pirogov <[email protected]>"]
66
maintainers = [

0 commit comments

Comments
 (0)