Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Disable/fix docker tests failing after migration to GH Actions #12625

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 19, 2025
Merged
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
7 changes: 2 additions & 5 deletions tests/cli/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from localstack import config, constants
from localstack.cli.localstack import localstack as cli
from localstack.config import Directories, in_docker
from localstack.constants import MODULE_MAIN_PATH, TRUE_STRINGS
from localstack.constants import MODULE_MAIN_PATH
from localstack.utils import bootstrap
from localstack.utils.bootstrap import in_ci
from localstack.utils.common import poll_condition
Expand Down Expand Up @@ -272,9 +272,7 @@ def test_prepare_host_hook_called_with_correct_dirs(self, runner, monkeypatch):

def _prepare_host(*args, **kwargs):
# store the configs that will be passed to prepare_host hooks (Docker status, infra process, dirs layout)
result_configs.append(
(config.is_in_docker, os.getenv(constants.LOCALSTACK_INFRA_PROCESS), config.dirs)
)
result_configs.append((config.is_in_docker, None, config.dirs))

# patch the prepare_host function which calls the hooks
monkeypatch.setattr(bootstrap, "prepare_host", _prepare_host)
Expand All @@ -294,7 +292,6 @@ def noop(*args, **kwargs):
dirs: Directories
in_docker, is_infra_process, dirs = result_configs[0]
assert in_docker is False
assert is_infra_process not in TRUE_STRINGS
# cache dir should exist and be writeable
assert os.path.exists(dirs.cache)
assert os.access(dirs.cache, os.W_OK)
Expand Down
13 changes: 10 additions & 3 deletions tests/integration/docker_utils/test_docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,10 @@ def test_create_with_port_mapping(self, docker_client: ContainerClient, create_c
ports.add(45180, 80)
create_container("alpine", ports=ports)

# TODO: This test must be fixed for SdkDockerClient
def test_create_with_exposed_ports(self, docker_client: ContainerClient, create_container):
if isinstance(docker_client, SdkDockerClient):
pytest.skip("Test skipped for SdkDockerClient")
Comment on lines +515 to +516
Copy link
Member

@silv-io silv-io May 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

q: Do we already know how this fix will look like and when it will be delivered?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don’t have many details. When I asked @dfangl , he said the SDK client and the command-line client behave a bit differently, even though the API response should be the same. He plans to look into it when he has time

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The python sdk sadly does not really allow us to send the exact same request as the docker cli would - so there is some difference in the output as well, and that difference might even change between API versions of docker.
A fix would be finding out the exact difference between the API requests of the CLI and the SDK, and then patching the sdk and filing an issue upstream.

exposed_ports = ["45000", "45001/udp"]
container = create_container(
"alpine",
Expand Down Expand Up @@ -1277,11 +1280,15 @@ def test_running_container_names(self, docker_client: ContainerClient, dummy_con
def test_is_container_running(self, docker_client: ContainerClient, dummy_container):
docker_client.start_container(dummy_container.container_id)
name = dummy_container.container_name
assert docker_client.is_container_running(name)

def _assert_container_state(is_running: bool):
assert docker_client.is_container_running(name) == is_running

retry(lambda: _assert_container_state(is_running=True), sleep=2, retries=5)
docker_client.restart_container(name)
assert docker_client.is_container_running(name)
retry(lambda: _assert_container_state(is_running=True), sleep=2, retries=5)
docker_client.stop_container(name)
assert not docker_client.is_container_running(name)
retry(lambda: _assert_container_state(is_running=False), sleep=2, retries=5)

@markers.skip_offline
def test_docker_image_names(self, docker_client: ContainerClient):
Expand Down
Loading