Skip to content

fix(cratedb): add CrateDB community module - #1051

Merged
alexanderankin merged 3 commits into
testcontainers:mainfrom
florinutz:cratedb
Jun 15, 2026
Merged

fix(cratedb): add CrateDB community module#1051
alexanderankin merged 3 commits into
testcontainers:mainfrom
florinutz:cratedb

Conversation

@florinutz

Copy link
Copy Markdown
Contributor

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

Comment threadpyproject.toml Outdated
@alexanderankin

Copy link
Copy Markdown
Member

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" },

florinutzand others added 3 commits June 15, 2026 10:58
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 <surister98@gmail.com>
Co-authored-by: Andreas Motl <andreas.motl@elmyra.de>
@florinutz

florinutz commented Jun 15, 2026

Copy link
Copy Markdown
ContributorAuthor

pushed the changes.

thank you @alexanderankin

@florinutz
florinutz requested a review from amotlJune 15, 2026 09:02
@alexanderankin
alexanderankin merged commit 0976c7e into testcontainers:mainJun 15, 2026
12 checks passed
alexanderankin added a commit that referenced this pull request Jul 24, 2026
🤖 I have created a release *beep* *boop*
---
##
[4.15.0](testcontainers-v4.15.0-rc4...testcontainers-v4.15.0)
(2026-07-24)
### Bug Fixes
* **cratedb:** add CrateDB community module
([#1051](#1051))
([0976c7e](0976c7e))
---
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: David Ankin <daveankin@gmail.com>
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

@florinutz@alexanderankin@amotl@Tranquility2