GeezerVison is showing github.com — fix(cratedb): add CrateDB community module by florinutz · Pull Request #1051 · testcontainers/testcontainers-python
Conversation
Add a CrateDB module under testcontainers.community.cratedb, ported from #888 and built on the generic SqlContainer base reintroduced in #892.
- CrateDBContainer extends community.generic.sql.SqlContainer; single-node command, HTTP (4200) wait strategy so startup needs no DB client library, crate:// SQLAlchemy connection URL
- deprecation shim at testcontainers.cratedb
- tests under tests/community/cratedb, docs, mkdocs nav entry, and the
cratedb optional-dependency (empty; sqlalchemy-cratedb is a test-group dep)
Supersedes #888
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
amotl reacted with thumbs up emoji
This was referenced Jun 11, 2026
Uh oh!
There was an error while loading. Please reload this page.
|
please add these changes, im unable to push to this branch:
ci running with these changes here - https://github.com/testcontainers/testcontainers-python/actions/runs/27472549593/job/81205981735?pr=1056 - should pass, if it does, means yours will pass with these changes too
diff --git a/pyproject.toml b/pyproject.toml
index 1ded7d2..caefa58 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -54,7 +54,10 @@ cassandra = []
clickhouse = ["clickhouse-driver"]
cosmosdb = ["azure-cosmos>=4"]
cockroachdb = []
-cratedb = ["sqlalchemy-cratedb"]
+cratedb = [
+ "httpx",
+ "sqlalchemy-cratedb"
+]
db2 = [
"sqlalchemy>=2",
"ibm_db_sa; platform_machine != 'aarch64' and platform_machine != 'arm64'",
diff --git a/src/testcontainers/community/cratedb/__init__.py b/src/testcontainers/community/cratedb/__init__.py
index 88cdcea..021f970 100644
--- a/src/testcontainers/community/cratedb/__init__.py
+++ b/src/testcontainers/community/cratedb/__init__.py
@@ -48,7 +48,7 @@ class CrateDBContainer(SqlContainer):
# Default command-line options. CrateDB needs single-node discovery to run
# as a one-node cluster suitable for testing.
- CMD_OPTS: ClassVar[dict[str, str]] = {"discovery.type": "single-node"}
+ CMD_OPTS: ClassVar[list[tuple[str, str]]] = [("discovery.type", "single-node")]
def __init__(
self,
@@ -57,7 +57,7 @@ class CrateDBContainer(SqlContainer):
username: Optional[str] = None,
password: Optional[str] = None,
dialect: str = "crate",
- cmd_opts: Optional[dict[str, str]] = None,
+ cmd_opts: Optional[list[tuple[str, str]]] = None,
**kwargs,
) -> None:
"""
@@ -73,12 +73,13 @@ class CrateDBContainer(SqlContainer):
merged over (and able to override) the defaults.
"""
raise_for_deprecated_parameter(kwargs, "user", "username")
- # Readiness is signalled by CrateDB's HTTP interface returning 200; this
+ # Readiness is signaled by CrateDB's HTTP interface returning 200; this
# keeps startup free of any database client library.
super().__init__(image, wait_strategy=HttpWaitStrategy(HTTP_PORT).for_status_code(200), **kwargs)
- cmd_opts = cmd_opts or {}
- self._command = self._build_cmd({**self.CMD_OPTS, **cmd_opts})
+ cmd_opts = cmd_opts or []
+ default_cmd_opts = [s for s in self.CMD_OPTS if s[0] not in {k[0] for k in cmd_opts}]
+ self._command = self._build_cmd([*default_cmd_opts, *cmd_opts])
self.username = username or os.environ.get("CRATEDB_USER", "crate")
self.password = password or os.environ.get("CRATEDB_PASSWORD", "crate")
@@ -88,10 +89,10 @@ class CrateDBContainer(SqlContainer):
self.with_exposed_ports(HTTP_PORT, PSQL_PORT)
@staticmethod
- def _build_cmd(opts: dict[str, str]) -> str:
+ def _build_cmd(opts: list[tuple[str, str]]) -> str:
"""Render a CrateDB ``-C<key>=<value> ...`` command-line string."""
cmd = []
- for key, val in opts.items():
+ for key, val in opts:
if isinstance(val, bool):
val = str(val).lower()
cmd.append(f"-C{key}={val}")
diff --git a/tests/community/cratedb/test_cratedb.py b/tests/community/cratedb/test_cratedb.py
index e9516d2..59132a4 100644
--- a/tests/community/cratedb/test_cratedb.py
+++ b/tests/community/cratedb/test_cratedb.py
@@ -30,12 +30,12 @@ def test_cratedb_connection_url():
"cmd_opts, expected",
[
pytest.param(
- {"indices.breaker.total.limit": "90%"},
+ [("indices.breaker.total.limit", "90%")],
"-Cdiscovery.type=single-node -Cindices.breaker.total.limit=90%",
id="add_cmd_option",
),
pytest.param(
- {"discovery.type": "zen", "indices.breaker.total.limit": "90%"},
+ [("discovery.type", "zen"), ("indices.breaker.total.limit", "90%")],
"-Cdiscovery.type=zen -Cindices.breaker.total.limit=90%",
id="override_defaults",
),
diff --git a/uv.lock b/uv.lock
index 1f7fca1..b9cbf1c 100644
--- a/uv.lock
+++ b/uv.lock
@@ -5466,6 +5466,10 @@ clickhouse = [
cosmosdb = [
{ name = "azure-cosmos" },
]
+cratedb = [
+ { name = "httpx" },
+ { name = "sqlalchemy-cratedb" },
+]
db2 = [
{ name = "ibm-db-sa", marker = "platform_machine != 'aarch64' and platform_machine != 'arm64'" },
{ name = "sqlalchemy" },
@@ -5655,6 +5659,7 @@ requires-dist = [
{ name = "google-cloud-datastore", marker = "extra == 'google'", specifier = ">=2" },
{ name = "google-cloud-pubsub", marker = "extra == 'google'", specifier = ">=2" },
{ name = "httpx", marker = "extra == 'aws'" },
+ { name = "httpx", marker = "extra == 'cratedb'" },
{ name = "httpx", marker = "extra == 'generic'" },
{ name = "httpx", marker = "extra == 'test-module-import'" },
{ name = "ibm-db-sa", marker = "platform_machine != 'aarch64' and platform_machine != 'arm64' and extra == 'db2'" },
@@ -5686,6 +5691,7 @@ requires-dist = [
{ name = "sqlalchemy", marker = "extra == 'mysql'", specifier = ">=2" },
{ name = "sqlalchemy", marker = "extra == 'oracle'", specifier = ">=2" },
{ name = "sqlalchemy", marker = "extra == 'oracle-free'", specifier = ">=2" },
+ { name = "sqlalchemy-cratedb", marker = "extra == 'cratedb'" },
{ name = "trino", marker = "extra == 'trino'" },
{ name = "typing-extensions" },
{ name = "urllib3" },
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Add a CrateDB module under testcontainers.community.cratedb, ported from
testcontainers#888 and built on the generic SqlContainer base reintroduced in testcontainers#892.
- CrateDBContainer extends community.generic.sql.SqlContainer; single-node
command, HTTP (4200) wait strategy so startup needs no DB client library,
crate:// SQLAlchemy connection URL
- deprecation shim at testcontainers.cratedb
- tests under tests/community/cratedb, docs, mkdocs nav entry, and the
`cratedb` optional-dependency (empty; sqlalchemy-cratedb is a test-group dep)
Supersedes testcontainers#888.
Co-authored-by: surister <[email protected]>
florinutz
commented
Jun 15, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Reviewers
amotl
Awaiting requested review from amotl
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
|