Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions cratedb_toolkit/testing/testcontainers/cratedb.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ def __init__(
password: Optional[str] = None,
dbname: Optional[str] = None,
cmd_opts: Optional[dict] = None,
name: Optional[str] = None,
**kwargs,
) -> None:
"""
Expand All @@ -89,7 +90,7 @@ def __init__(
"""
super().__init__(image=image, **kwargs)

self._name = "testcontainers-cratedb"
self._name = name or "testcontainers-cratedb"

cmd_opts = cmd_opts or {}
self._command = self._build_cmd({**self.CMD_OPTS, **cmd_opts})
Expand Down Expand Up @@ -162,16 +163,17 @@ class CrateDBTestAdapter:
CrateDB Toolkit's `DatabaseAdapter`, agnostic of the test framework.
"""

def __init__(self, crate_version: str = "nightly", **kwargs):
def __init__(self, crate_version: str = "nightly", name: str = None, **kwargs):
self.cratedb: Optional[CrateDBContainer] = None
self.database: Optional[DatabaseAdapter] = None
self.image: str = "crate/crate:{}".format(crate_version)
self.name = name

def start(self, **kwargs):
"""
Start testcontainer, used for tests set up
"""
self.cratedb = CrateDBContainer(image=self.image, **kwargs)
self.cratedb = CrateDBContainer(image=self.image, name=self.name, **kwargs)
self.cratedb.start()
self.database = DatabaseAdapter(dburi=self.get_connection_url())

Expand Down
2 changes: 1 addition & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def cratedb_service():
"""
Provide a CrateDB service instance to the test suite.
"""
db = CrateDBTestAdapter()
db = CrateDBTestAdapter(name="testcontainers-cratedb-custom")
db.start(ports={CRATEDB_HTTP_PORT: None}, cmd_opts=CRATEDB_SETTINGS)
db.reset(tables=RESET_TABLES)
yield db
Expand Down