Skip to content

Conversation

@gregfurman
Copy link
Contributor

Motivation

When doing ESM lifecycle tests, we need to validate that the ESM resource can be deleted during the test run while also ensuring that, if the test fails early, the resource is also cleaned up.

Currently, if the test passes, this delete-then-cleanup approach will always raise an exception on cleanup since the mapping should have been deleted already.

This PR uses the (proposed #13284) sync.once_func to guarantee that the deletion happens once and only once.

Changes

  • Makes ESM resource cleanup idempotent with utils.sync.once_func in the test_event_source_mapping_lifecycle_delete_function test.

Testing

  • Checkout main and run the test_event_source_mapping_lifecycle_delete_function test:
    make TEST_PATH="tests/aws/services/lambda_/test_lambda_api.py::TestLambdaEventSourceMappings::test_event_source_mapping_lifecycle_delete_function" test
  • Notice the following log(s) on teardown:
     localstack.testing.pytest.fixtures : Failed to execute cleanup
     # ...
     botocore.errorfactory.ResourceNotFoundException: An error occurred (ResourceNotFoundException) when calling the DeleteEventSourceMapping operation: The resource you requested does not exist.
  • Checkout add/util/sync-once-usage, run the test again, and notice no error logs.

@gregfurman gregfurman added this to the 4.10 milestone Oct 22, 2025
@gregfurman gregfurman self-assigned this Oct 22, 2025
@gregfurman gregfurman added semver: patch Non-breaking changes which can be included in patch releases aws:lambda:event-source-mapping AWS Lambda Event Source Mapping (ESM) docs: skip Pull request does not require documentation changes notes: skip Pull request does not have to be mentioned in the release notes labels Oct 22, 2025
@github-actions
Copy link

Test Results - Preflight, Unit

22 308 tests   - 68   20 565 ✅  - 61   16m 7s ⏱️ +7s
     1 suites ± 0    1 743 💤  -  7 
     1 files   ± 0        0 ❌ ± 0 

Results for commit 310bcbc. ± Comparison against base commit 3e99d09.

@github-actions
Copy link

Test Results (amd64) - Acceptance

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

Results for commit 310bcbc. ± Comparison against base commit 3e99d09.

@github-actions
Copy link

Test Results (amd64) - Integration, Bootstrap

    5 files  ±    0      5 suites  ±0   2h 4m 40s ⏱️ - 34m 57s
3 465 tests  - 1 787  3 240 ✅  - 1 497  225 💤  - 290  0 ❌ ±0 
3 471 runs   - 1 787  3 240 ✅  - 1 497  231 💤  - 290  0 ❌ ±0 

Results for commit 310bcbc. ± Comparison against base commit 3e99d09.

@github-actions
Copy link

LocalStack Community integration with Pro

    2 files  ±    0      2 suites  ±0   1h 33m 37s ⏱️ - 27m 42s
3 441 tests  - 1 437  3 212 ✅  - 1 311  229 💤  - 126  0 ❌ ±0 
3 443 runs   - 1 437  3 212 ✅  - 1 311  231 💤  - 126  0 ❌ ±0 

Results for commit 310bcbc. ± Comparison against base commit 3e99d09.

Base automatically changed from add/util/sync-once to main October 23, 2025 10:04
@gregfurman gregfurman modified the milestones: 4.10, Playground Oct 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

aws:lambda:event-source-mapping AWS Lambda Event Source Mapping (ESM) docs: skip Pull request does not require documentation changes notes: skip Pull request does not have to be mentioned in the release notes 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