From 58ace26fb8c627589df391cb93ab03f7f837f4eb Mon Sep 17 00:00:00 2001 From: Roger Zhang Date: Tue, 18 Aug 2026 09:34:59 -0700 Subject: [PATCH] tests: move provided.al2 to the deprecated lint list and stop rerunning a non-rerun-safe sync test Two failures from last night's integration runs (32094973517, 32122795247). The pytest 9.1 unblock landed cleanly -- sync-code passes, other-and-e2e went from 135 errors to 0 -- and these are the unrelated leftovers. 1. test_lint_supported_runtimes (failed in both runs) cfn-lint marks provided.al2 EOL as of 2026-07-31, so `sam validate --lint` now exits 1 while the test asserts 0: W2531 Runtime 'provided.al2' was deprecated on '2026-07-31'. Moved it out of supported_runtimes and into test_lint_deprecated_runtimes, which derives the expected code (W2531/E2531/E2533) from cfn-lint's LmbdRuntimeLifecycle.json by date and so does not need touching again as the runtime moves through create-block and update-block. Same treatment as ruby3.2 in #8883 and nodejs20.x in #8947, except those were deleted rather than moved. Checked the rest of the list: only provided.al2 is flagged; java8.al2 is still clean and is the likely next one. 2. TestSyncAdlCasesWithCodeParameter.test_sync_code_function_without_dependencies Reruns cannot help this test and actively hide why it failed. It edits test data in place (update_file writes over code/before/python_function_no_deps/app.py) and the class-scoped fixture that deploys the stack does not re-run, so once attempt 1 has mutated the tree the retries run against inconsistent state. That is what the reported error was: the function came back "Unable to import module 'app': No module named 'numpy'", so _get_lambda_response returned None (error payloads have no "body") and the failure surfaced as `TypeError: the JSON object must be str, bytes or bytearray, not NoneType` -- three wasted deploy cycles and none of the original cause. @pytest.mark.flaky(reruns=0) makes it report the real first-attempt failure immediately. Transient invoke flakes are still covered: _get_lambda_response retries internally. Worth flagging separately: 26 update_file calls across test_sync_adl.py (6), test_sync_code.py (2) and test_sync_watch.py (20) write into code/before, so the same rerun-unsafety applies wherever one of those fails after mutating. Only the test that actually failed is marked here; making them rerun-safe is a bigger change. Testing: with SAM_CLI_DEV=1 (as CI sets), test_lint_supported_runtimes and all 7 test_lint_deprecated_runtimes cases pass -- 8 passed. Verified reruns=0 is honoured (1 attempt versus 4 for an unmarked test). tests/integration/{sync,validate} collect 153 tests. black and ruff clean. --- tests/integration/sync/test_sync_adl.py | 4 ++++ tests/integration/validate/test_validate_command.py | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/integration/sync/test_sync_adl.py b/tests/integration/sync/test_sync_adl.py index 2d109ddb0d2..41fa7ec35c4 100644 --- a/tests/integration/sync/test_sync_adl.py +++ b/tests/integration/sync/test_sync_adl.py @@ -2,6 +2,8 @@ import os.path from unittest import skipIf +import pytest + from samcli.commands._utils.experimental import set_experimental, ExperimentalFlag from samcli.lib.utils.resources import AWS_LAMBDA_FUNCTION, AWS_LAMBDA_LAYERVERSION from tests.integration.sync.sync_integ_base import SyncIntegBase @@ -16,6 +18,8 @@ class TestSyncAdlCasesWithCodeParameter(TestSyncCodeBase): folder = "code" dependency_layer = True + # Not rerun-safe: it edits test data in place and the class-scoped infra sync is not redone. + @pytest.mark.flaky(reruns=0) def test_sync_code_function_without_dependencies(self): # CFN Api call here to collect all the stack resources self.stack_resources = self._get_stacks(TestSyncCode.stack_name) diff --git a/tests/integration/validate/test_validate_command.py b/tests/integration/validate/test_validate_command.py index dc1d1f415fe..990d13473e5 100644 --- a/tests/integration/validate/test_validate_command.py +++ b/tests/integration/validate/test_validate_command.py @@ -162,6 +162,7 @@ def test_lint_template(self, relative_folder: str, expected_file: TemplateFileTy ("ruby3.2",), ("dotnet6",), ("nodejs20.x"), + ("provided.al2",), ] ) def test_lint_deprecated_runtimes(self, runtime): @@ -215,7 +216,6 @@ def test_lint_supported_runtimes(self): "java8.al2", "nodejs22.x", "nodejs24.x", - "provided.al2", "provided.al2023", "python3.10", "python3.11",