Skip to content
Closed
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
14 changes: 14 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ jobs:
"3.9",
"3.14",
]
include:
- os: "macos-latest"
python-version: "3.14"
- os: "windows-latest"
python-version: "3.14"

env:
OS: ${{ matrix.os }}
Expand All @@ -52,6 +57,15 @@ jobs:
- name: Acquire sources
uses: actions/checkout@v6

- name: Set up Docker
uses: docker-practice/actions-setup-docker@master
timeout-minutes: 12

- name: Probe Docker
run: |
docker version
docker run --rm hello-world
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
Expand Down
31 changes: 31 additions & 0 deletions cratedb_toolkit/testing/testcontainers/cratedb.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
from typing import Optional

from testcontainers.core.config import MAX_TRIES
from testcontainers.core.docker_client import DockerClient
from testcontainers.core.generic import DbContainer
from testcontainers.core.wait_strategies import LogMessageWaitStrategy
from testcontainers.core.waiting_utils import wait_for_logs
Expand Down Expand Up @@ -133,6 +134,12 @@ def _configure(self) -> None:
self._configure_credentials()
self._configure_wait_condition()

"""
if "CI" in os.environ:
docker_host = get_docker_host()
self.with_env("DOCKER_HOST", docker_host).with_env("DOCKER_CERT_PATH", "").with_env("DOCKER_TLS_VERIFY", "")
"""

def get_connection_url(self, dialect: str = "crate", host: Optional[str] = None) -> str:
"""
Return a connection URL to the DB
Expand Down Expand Up @@ -220,3 +227,27 @@ def http_url(self):
Used to stay backward compatible with the downstream code.
"""
return self.get_http_url()


def get_docker_host():
"""
https://github.com/testcontainers/testcontainers-python/blob/main/core/tests/test_docker_in_docker.py
"""
# real dind isn't possible (AFAIK) in CI
# forwarding the socket to a container port is at least somewhat the same
client = DockerClient()
not_really_dind = client.run(
image="alpine/socat",
command="tcp-listen:2375,fork,reuseaddr unix-connect:/var/run/docker.sock",
volumes={"/var/run/docker.sock": {"bind": "/var/run/docker.sock"}},
detach=True,
)

not_really_dind.start()

# get ip address for DOCKER_HOST
# avoiding DockerContainer class here to prevent code changes affecting the test
specs = client.get_container(not_really_dind.id)
docker_host_ip = specs["NetworkSettings"]["Networks"]["bridge"]["IPAddress"]
docker_host = f"tcp://{docker_host_ip}:2375"
return docker_host
Loading