Skip to content

Create new markers for requiring in process execution or docker #13003

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

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

dfangl
Copy link
Member

@dfangl dfangl commented Aug 13, 2025

Motivation

We currently have no way of marking tests as requiring docker or requiring to run in the same process as the LS instance (usually for monkeypatching / pytest http server usage).

This makes certain test scenarios harder, for example testing against a running LS instance, or testing against kubernetes.

With this PR, new markers are introduced:

  • requires_docker: This marker should be set if a test requires the docker daemon (or a compatible implementation, like podman with docker socket support) to run.
  • requires_in_process: This marker should be set if a test needs to run inside the same process (or network namespace) as LocalStack. Usually used for tests with monkeypatch or pytest-httpserver, with the latter hopefully fixed in the future.
  • requires_in_container: For better distinction between this marker and requires_docker this is a renamed only_in_docker - it requires LocalStack to run in a container (usually for system level dependency installation), no matter if it is a docker container or kubernetes pod.

Changes

  • Rename only_in_docker to requires_in_container
  • Add markers requires_docker and requires_in_process
  • Add markers to appropriate tests

@dfangl dfangl self-assigned this Aug 13, 2025
@dfangl dfangl requested a review from simonrw August 13, 2025 12:44
@dfangl dfangl added the semver: patch Non-breaking changes which can be included in patch releases label Aug 13, 2025
Copy link

github-actions bot commented Aug 13, 2025

Test Results - Preflight, Unit

22 107 tests   20 372 ✅  6m 56s ⏱️
     1 suites   1 735 💤
     1 files         0 ❌

Results for commit ff52d68.

♻️ This comment has been updated with latest results.

Copy link

github-actions bot commented Aug 13, 2025

Test Results (amd64) - Acceptance

7 tests   5 ✅  3m 12s ⏱️
1 suites  2 💤
1 files    0 ❌

Results for commit ff52d68.

♻️ This comment has been updated with latest results.

Copy link

github-actions bot commented Aug 13, 2025

Test Results (amd64) - Integration, Bootstrap

    5 files      5 suites   2h 20m 28s ⏱️
4 987 tests 4 395 ✅ 592 💤 0 ❌
4 993 runs  4 395 ✅ 598 💤 0 ❌

Results for commit ff52d68.

♻️ This comment has been updated with latest results.

Copy link

github-actions bot commented Aug 13, 2025

LocalStack Community integration with Pro

    2 files      2 suites   1h 42m 9s ⏱️
4 628 tests 4 188 ✅ 440 💤 0 ❌
4 630 runs  4 188 ✅ 442 💤 0 ❌

Results for commit ff52d68.

♻️ This comment has been updated with latest results.

@dfangl dfangl force-pushed the k8s/non-root-tests branch from e4dcd34 to 1f0d400 Compare August 13, 2025 14:39
Copy link

github-actions bot commented Aug 13, 2025

S3 Image Test Results (AMD64 / ARM64)

    2 files  ±0    2 suites  ±0   8m 11s ⏱️ +9s
  515 tests ±0  465 ✅ ±0   50 💤 ±0  0 ❌ ±0 
1 030 runs  ±0  930 ✅ ±0  100 💤 ±0  0 ❌ ±0 

Results for commit ff52d68. ± Comparison against base commit 617f230.

♻️ This comment has been updated with latest results.

@dfangl dfangl marked this pull request as ready for review August 13, 2025 15:26
@dfangl dfangl removed the request for review from dominikschubert August 13, 2025 15:26
Copy link
Contributor

@simonrw simonrw left a comment

Choose a reason for hiding this comment

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

These are a great step forwards to enabling "external" testing for LocalStack, and gives us a TODO list for what we need to update, great!

Just a couple of questions/suggestions

@@ -62,7 +62,12 @@ class Markers:
only_on_amd64 = pytest.mark.only_on_amd64
only_on_arm64 = pytest.mark.only_on_arm64
resource_heavy = pytest.mark.resource_heavy
only_in_docker = pytest.mark.only_in_docker
# Tests require LocalStack to be run inside a container
requires_in_container = pytest.mark.requires_in_container
Copy link
Contributor

Choose a reason for hiding this comment

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

suggestion: is there a way to add a docstring for these? So we can hover over the definition to get this comment?

Suggested change
requires_in_container = pytest.mark.requires_in_container
requires_in_container = pytest.mark.requires_in_container
"""Tests require LocalStack to be run inside a container"""

This would be good to add to the other markers as well

Copy link
Member Author

Choose a reason for hiding this comment

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

Good point, will add them!

Copy link
Member Author

Choose a reason for hiding this comment

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

Added them, and the IDE shows them as expected:
image

if not is_in_docker and "only_in_docker" in item.keywords:
item.add_marker(only_in_docker)
if not is_in_docker and "requires_in_container" in item.keywords:
item.add_marker(requires_in_container)
if is_in_ci and not is_amd64 and "only_on_amd64" in item.keywords:
item.add_marker(only_on_amd64)
if is_in_ci and not is_arm64 and "only_on_arm64" in item.keywords:
Copy link
Contributor

Choose a reason for hiding this comment

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

suggestion: could we do something like:

requires_in_process = pytest.mark.skip(
    reason="..."
)

# ...

if localstack_config.is_env_true("TEST_SKIP_LOCALSTACK_START") and "requires_in_process" in item.keywords:
    item.add_marker(requires_in_process)

?

Copy link
Member Author

@dfangl dfangl Aug 14, 2025

Choose a reason for hiding this comment

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

Yes we can, but I am not entirely confident we should, it might get confusing to have these skips. In the k8s pipeline we manually skip them for now, and there was no other usecase until now. I'm happy with adding it, but I think this can wait until we actually encounter a problem this will solve, WDYT?

Copy link
Contributor

Choose a reason for hiding this comment

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

Makes sense. You are right, we don't want to (silently) skip these specific tests without warning the user and the CI will opt in. If we execute tests against a running container and look at the failures, we will clearly see the new marker which will explain why the test fails easily. I'm ok with this 👍

Copy link
Contributor

@simonrw simonrw left a comment

Choose a reason for hiding this comment

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

I think a few tests are missing, from my recent investigation into parallelising the CFn tests, I found these three tests require in-process access:

  • tests/aws/services/cloudformation/api/test_stacks.py::TestStacksApi::test_create_stack_with_custom_id (requires in memory access to the provider, however it's not super clear. It uses the set_resource_custom_id fixture)
  • tests/aws/services/cloudformation/resources/test_apigateway.py::test_cfn_apigateway_swagger_import (uses echo_http_server_post)
  • tests/aws/services/cloudformation/resources/test_lambda.py::test_lambda_cfn_run_with_non_empty_string_replacement_deny_list (uses monkeypatch)

Have we verified these markers in this community PR?

@dfangl
Copy link
Member Author

dfangl commented Aug 14, 2025

They have been verified as part of our Compile list of services that we think won’t work backlog task. I did not test the cloudformation tests personally, and you are right, we don't execute them in the pipeline.
I'd vote for moving this to a follow up PR, where we enable the community tests and tag the remaining missing ones, if you are ok with it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
semver: patch Non-breaking changes which can be included in patch releases
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants