diff --git a/.github/workflows/ci-core.yml b/.github/workflows/ci-core.yml index 34aabc736..2171ca535 100644 --- a/.github/workflows/ci-core.yml +++ b/.github/workflows/ci-core.yml @@ -26,7 +26,14 @@ jobs: - name: Run twine check run: poetry build && poetry run twine check dist/*.tar.gz - name: Set up Docker - uses: docker/setup-docker-action@v4 + uses: docker/setup-docker-action@v4 - name: Display Docker and Compose Versions + run: | + echo "##[group]Docker Version" + docker --version || echo "Docker is not installed or misconfigured" + echo "##[endgroup]" + echo "##[group]Docker Compose Version" + docker compose version || docker-compose --version || echo "Docker Compose is not installed or misconfigured" + echo "##[endgroup]" - name: Run tests run: make core/tests - name: Rename coverage file diff --git a/core/tests/test_core_registry.py b/core/tests/test_core_registry.py index 384b06693..36e4730f9 100644 --- a/core/tests/test_core_registry.py +++ b/core/tests/test_core_registry.py @@ -18,8 +18,13 @@ from testcontainers.core.waiting_utils import wait_container_is_ready from testcontainers.registry import DockerRegistryContainer +from testcontainers.core.utils import is_mac +@pytest.mark.skipif( + is_mac(), + reason="Docker Desktop on macOS does not support insecure private registries without daemon reconfiguration", +) def test_missing_on_private_registry(monkeypatch): username = "user" password = "pass" @@ -41,6 +46,10 @@ def test_missing_on_private_registry(monkeypatch): wait_container_is_ready(test_container) +@pytest.mark.skipif( + is_mac(), + reason="Docker Desktop on macOS does not support local insecure registries over HTTP without modifying daemon settings", +) @pytest.mark.parametrize( "image,tag,username,password", [ diff --git a/core/tests/test_docker_in_docker.py b/core/tests/test_docker_in_docker.py index b07f80e9a..02b8e1fc4 100644 --- a/core/tests/test_docker_in_docker.py +++ b/core/tests/test_docker_in_docker.py @@ -15,6 +15,7 @@ from testcontainers.core.container import DockerContainer from testcontainers.core.docker_client import DockerClient, LOGGER from testcontainers.core.utils import inside_container +from testcontainers.core.utils import is_mac from testcontainers.core.waiting_utils import wait_for_logs @@ -36,6 +37,7 @@ def _wait_for_dind_return_ip(client, dind): return docker_host_ip +@pytest.mark.skipif(is_mac(), reason="Docker socket forwarding (socat) is unsupported on Docker Desktop for macOS") def test_wait_for_logs_docker_in_docker(): # real dind isn't possible (AFAIK) in CI # forwarding the socket to a container port is at least somewhat the same @@ -64,6 +66,9 @@ def test_wait_for_logs_docker_in_docker(): not_really_dind.remove() +@pytest.mark.skipif( + is_mac(), reason="Bridge networking and Docker socket forwarding are not supported on Docker Desktop for macOS" +) def test_dind_inherits_network(): client = DockerClient() try: @@ -158,6 +163,9 @@ def test_find_host_network_in_dood() -> None: assert DockerClient().find_host_network() == os.environ[EXPECTED_NETWORK_VAR] +@pytest.mark.skipif( + is_mac(), reason="Docker socket mounting and container networking do not work reliably on Docker Desktop for macOS" +) @pytest.mark.skipif(not Path(tcc.ryuk_docker_socket).exists(), reason="No docker socket available") def test_dood(python_testcontainer_image: str) -> None: """ diff --git a/core/tests/test_ryuk.py b/core/tests/test_ryuk.py index 5d6b208af..76556d4f4 100644 --- a/core/tests/test_ryuk.py +++ b/core/tests/test_ryuk.py @@ -8,9 +8,14 @@ from testcontainers.core.config import testcontainers_config from testcontainers.core.container import Reaper from testcontainers.core.container import DockerContainer +from testcontainers.core.utils import is_mac from testcontainers.core.waiting_utils import wait_for_logs +@pytest.mark.skipif( + is_mac(), + reason="Ryuk container reaping is unreliable on Docker Desktop for macOS due to VM-based container lifecycle handling", +) @pytest.mark.inside_docker_check def test_wait_for_reaper(monkeypatch: MonkeyPatch): Reaper.delete_instance() @@ -41,6 +46,9 @@ def test_wait_for_reaper(monkeypatch: MonkeyPatch): Reaper.delete_instance() +@pytest.mark.skipif( + is_mac(), reason="Ryuk disabling behavior is unreliable on Docker Desktop for macOS due to Docker socket emulation" +) @pytest.mark.inside_docker_check def test_container_without_ryuk(monkeypatch: MonkeyPatch): Reaper.delete_instance() diff --git a/modules/cosmosdb/tests/test_cosmosdb_emulator.py b/modules/cosmosdb/tests/test_cosmosdb_emulator.py index 542ddd11c..41653cd4a 100644 --- a/modules/cosmosdb/tests/test_cosmosdb_emulator.py +++ b/modules/cosmosdb/tests/test_cosmosdb_emulator.py @@ -1,7 +1,10 @@ import pytest from testcontainers.cosmosdb._emulator import CosmosDBEmulatorContainer +from testcontainers.core.utils import is_arm + +@pytest.mark.skipif(is_arm(), reason="db2 container not available for ARM") def test_runs(): with CosmosDBEmulatorContainer(partition_count=1, bind_ports=False) as emulator: assert emulator.server_certificate_pem is not None diff --git a/modules/cosmosdb/tests/test_cosmosdb_mongodb.py b/modules/cosmosdb/tests/test_cosmosdb_mongodb.py index a50ee82ea..3c10ee19f 100644 --- a/modules/cosmosdb/tests/test_cosmosdb_mongodb.py +++ b/modules/cosmosdb/tests/test_cosmosdb_mongodb.py @@ -1,7 +1,10 @@ import pytest from testcontainers.cosmosdb import CosmosDBMongoEndpointContainer +from testcontainers.core.utils import is_arm + +@pytest.mark.skipif(is_arm(), reason="db2 container not available for ARM") def test_requires_a_version(): with pytest.raises(AssertionError, match="A MongoDB version is required"): CosmosDBMongoEndpointContainer(mongodb_version=None) @@ -10,6 +13,7 @@ def test_requires_a_version(): CosmosDBMongoEndpointContainer(mongodb_version="4.0") +@pytest.mark.skipif(is_arm(), reason="db2 container not available for ARM") def test_runs(): with CosmosDBMongoEndpointContainer(mongodb_version="4.0", partition_count=1, bind_ports=False) as emulator: assert emulator.env["AZURE_COSMOS_EMULATOR_ENABLE_MONGODB_ENDPOINT"] == "4.0" diff --git a/modules/cosmosdb/tests/test_cosmosdb_nosql.py b/modules/cosmosdb/tests/test_cosmosdb_nosql.py index a9460a1b0..a48a52ac8 100644 --- a/modules/cosmosdb/tests/test_cosmosdb_nosql.py +++ b/modules/cosmosdb/tests/test_cosmosdb_nosql.py @@ -1,7 +1,10 @@ import pytest from testcontainers.cosmosdb import CosmosDBNoSQLEndpointContainer +from testcontainers.core.utils import is_arm + +@pytest.mark.skipif(is_arm(), reason="db2 container not available for ARM") def test_runs(): with CosmosDBNoSQLEndpointContainer(partition_count=1, bind_ports=False) as emulator: assert emulator.get_exposed_port(8081) is not None, "The NoSQL endpoint's port should be exposed" diff --git a/modules/db2/tests/test_db2.py b/modules/db2/tests/test_db2.py index 7b6ea844a..c354832ff 100644 --- a/modules/db2/tests/test_db2.py +++ b/modules/db2/tests/test_db2.py @@ -26,6 +26,7 @@ def test_docker_run_db2(version: str): # - sqlserver # - mongodb # - db2 +@pytest.mark.skipif(is_arm(), reason="db2 container not available for ARM") def test_quoted_password(): user = "db2inst1" dbname = "testdb" diff --git a/modules/elasticsearch/tests/test_elasticsearch.py b/modules/elasticsearch/tests/test_elasticsearch.py index 661a550c6..5108bb40f 100644 --- a/modules/elasticsearch/tests/test_elasticsearch.py +++ b/modules/elasticsearch/tests/test_elasticsearch.py @@ -3,11 +3,13 @@ import pytest +from testcontainers.core.utils import is_arm from testcontainers.elasticsearch import ElasticSearchContainer # The versions below should reflect the latest stable releases @pytest.mark.parametrize("version", ["7.17.18", "8.12.2"]) +@pytest.mark.skipif(is_arm(), reason="db2 container not available for ARM") def test_docker_run_elasticsearch(version): with ElasticSearchContainer(f"elasticsearch:{version}", mem_limit="3G") as es: resp = urllib.request.urlopen(es.get_url()) diff --git a/modules/google/tests/test_google.py b/modules/google/tests/test_google.py index c91793741..e2dd55014 100644 --- a/modules/google/tests/test_google.py +++ b/modules/google/tests/test_google.py @@ -1,6 +1,7 @@ from queue import Queue from google.cloud.datastore import Entity +import time from testcontainers.core.waiting_utils import wait_for_logs from testcontainers.google import PubSubContainer, DatastoreContainer @@ -25,7 +26,8 @@ def test_pubsub_container(): # Receive the message queue = Queue() subscriber.subscribe(subscription_path, queue.put) - message = queue.get(timeout=1) + # timeout 10 is needed to account for slower arm machines + message = queue.get(timeout=10) assert message.data == b"Hello world!" message.ack() diff --git a/poetry.lock b/poetry.lock index d80fa130a..653a13e2d 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1907,7 +1907,7 @@ description = "Python DBI driver for DB2 (LUW, zOS, i5) and IDS" optional = true python-versions = "*" groups = ["main"] -markers = "extra == \"db2\"" +markers = "platform_machine != \"aarch64\" and platform_machine != \"arm64\" and extra == \"db2\"" files = [ {file = "ibm_db-3.2.3-cp310-cp310-macosx_10_15_x86_64.whl", hash = "sha256:3399466141c29704f4e8ba709a67ba27ab413239c0244c3c4510126e946ff603"}, {file = "ibm_db-3.2.3-cp310-cp310-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:e12ff6426d4f718e1ff6615e64a2880bd570826f19a031c82dbf296714cafd7d"}, @@ -1954,7 +1954,7 @@ description = "SQLAlchemy support for IBM Data Servers" optional = true python-versions = "*" groups = ["main"] -markers = "extra == \"db2\"" +markers = "platform_machine != \"aarch64\" and platform_machine != \"arm64\" and extra == \"db2\"" files = [ {file = "ibm_db_sa-0.4.1-py3-none-any.whl", hash = "sha256:49926ba9799e6ebd9ddd847141537c83d179ecf32fe24b7e997ac4614d3f616a"}, {file = "ibm_db_sa-0.4.1.tar.gz", hash = "sha256:a46df130a3681646490925cf4e1bca12b46283f71eea39b70b4f9a56e95341ac"}, @@ -5951,4 +5951,4 @@ weaviate = ["weaviate-client"] [metadata] lock-version = "2.1" python-versions = ">=3.9,<4.0" -content-hash = "bacae2cc8c7947dae5d1f6f05bc1a98d488470a5947f95479edabe75cf036f41" +content-hash = "24c7e4335574e67bef9fac3bbb2b17a3199449734010d7931a60efa679529235" diff --git a/pyproject.toml b/pyproject.toml index 1ec495d02..219a1e171 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -118,7 +118,7 @@ httpx = { version = "*", optional = true } azure-cosmos = { version = "*", optional = true } cryptography = { version = "*", optional = true } trino = { version = "*", optional = true } -ibm_db_sa = { version = "*", optional = true } +ibm_db_sa = { version = "*", optional = true, markers = "platform_machine != 'aarch64' and platform_machine != 'arm64'" } [tool.poetry.extras] arangodb = ["python-arango"]