test(lambda/esm): Make ESM cleanup idempotent #13295
Draft
+297
−4
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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_functo guarantee that the deletion happens once and only once.Changes
utils.sync.once_funcin thetest_event_source_mapping_lifecycle_delete_functiontest.Testing
mainand run thetest_event_source_mapping_lifecycle_delete_functiontest:add/util/sync-once-usage, run the test again, and notice no error logs.