Skip to content

fix: remove fallback in count_running_containers that causes flaky warm container tests - #5

Merged
bnusunny merged 6 commits into
developfrom
fix/warm-containers-count
Feb 13, 2026
Merged

fix: remove fallback in count_running_containers that causes flaky warm container tests#5
bnusunny merged 6 commits into
developfrom
fix/warm-containers-count

Conversation

@bnusunny

Copy link
Copy Markdown
Owner

Problem

The count_running_containers() method in warm container integration tests had a fallback that returned the count of ALL SAM CLI containers when the MODE env var filtering found no matches. This caused AssertionError: 3 != 2 when stale containers from other tests or parallel runs were present.

Fix

  • Removed the fallback return len(sam_containers) — now strictly returns only the count of containers matching this test's unique MODE UUID
  • Changed from substring matching to exact string matching on the env var
  • Applied fix to both test_start_api.py and test_start_lambda.py

Testing

Added a focused workflow (test-warm-containers-fix.yml) that runs the warm container test suites to verify the fix.

seshubaws and others added 3 commits February 12, 2026 19:19
…8647)

Docker's images.list(name='samcli/lambda') does exact repository matching
and won't match repositories like 'samcli/lambda-python'. This caused
stale images to persist across parameterized test classes, leading to
flaky test_download_two_layers failures where Layer2 should overwrite
Layer1 but the image was never rebuilt.

Fix by:
1. Adding _cleanup_samcli_images() that lists all images and filters by
   'samcli/lambda-' tag prefix
2. Using this method in both tearDown and tearDownClass
3. Fixing the same pattern in TestLayerVersionThatDoNotCreateCache
…rm container tests

The count_running_containers method had a fallback that returned the count
of ALL SAM CLI containers when MODE env var filtering found no matches.
This caused AssertionError: 3 != 2 when stale containers from other tests
were present. Now it strictly counts only containers matching this test's
unique MODE UUID and uses exact string matching.
@bnusunny
bnusunny merged commit b51bdf6 into develop Feb 13, 2026
10 checks passed
@bnusunny
bnusunny deleted the fix/warm-containers-count branch February 13, 2026 03:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants