From 5b07b62a8d8ef2b6731eabe56ca05e0b8b4067ac Mon Sep 17 00:00:00 2001 From: Roger Zhang Date: Fri, 31 Jul 2026 15:09:05 -0700 Subject: [PATCH] tests: remove deprecated dotnet7 tests The dotnet7 integration tests have been failing on release builds (see run 30657529336). The build-dotnet7 image now installs Amazon.Lambda.Tools 7.0.0, which dropped net7.0: error NU1202: Package Amazon.Lambda.Tools 7.0.0 is not compatible with net7.0. Package Amazon.Lambda.Tools 7.0.0 supports: net10.0, net8.0 The Lambda dotnet7 runtime was deprecated May 14, 2024 and the public dotnet7 base image has not published since 2024, so these tests cannot be made to pass and are removed rather than pinned to an unsupported framework. The dotnet7 BuildMethod itself is intentionally left in place in samcli/lib/build/workflow_config.py; only the tests are removed. Removed: - test_dotnet_al2 dotnet7 params (plain + MountMode.WRITE) and the now-unreachable Finch skip that guarded one of them - TestBuildCommand_Dotnet_cli_package_interactive.test_dotnet_al2_in_container (dotnet7 was its only param) - tests/integration/testdata/buildcmd/Dotnet7/ and template_build_method_dotnet_7.yaml - test_must_work_for_provided_with_build_method_dotnet7 and the dotnet7 param of test_must_mount_with_write_for_dotnet_in_container - the now-unused USING_FINCH_RUNTIME import test_must_prompt_for_function_with_specified_workflow keeps its coverage by switching to BuildMethod "dotnet", which resolves to the same DOTNET_CLIPACKAGE_CONFIG and so still exercises the must-mount-with-write prompt path. Note this also fixes a latent bug: test_dotnet_al2 passed mode=None for all three cases, so `if mode == "Dotnet"` never matched and every case silently built the dotnet_7 template -- confirmed in the failing run, where all four sam build invocations used template_build_method_dotnet_7.yaml. The retained case now actually uses template_build_method_dotnet.yaml (net8.0). Testing: make pr passes (9345 passed, 25 skipped, coverage 94.11%). --- .../buildcmd/test_build_cmd_dotnet.py | 39 +------------------ .../buildcmd/Dotnet7/HelloWorld.csproj | 25 ------------ .../testdata/buildcmd/Dotnet7/Program.cs | 38 ------------------ .../Dotnet7/aws-lambda-tools-defaults.json | 18 --------- .../testdata/buildcmd/Dotnet7/rd.xml | 6 --- .../template_build_method_dotnet_7.yaml | 38 ------------------ tests/unit/commands/buildcmd/test_utils.py | 2 +- .../lib/build_module/test_workflow_config.py | 14 +------ 8 files changed, 3 insertions(+), 177 deletions(-) delete mode 100644 tests/integration/testdata/buildcmd/Dotnet7/HelloWorld.csproj delete mode 100755 tests/integration/testdata/buildcmd/Dotnet7/Program.cs delete mode 100644 tests/integration/testdata/buildcmd/Dotnet7/aws-lambda-tools-defaults.json delete mode 100644 tests/integration/testdata/buildcmd/Dotnet7/rd.xml delete mode 100644 tests/integration/testdata/buildcmd/template_build_method_dotnet_7.yaml diff --git a/tests/integration/buildcmd/test_build_cmd_dotnet.py b/tests/integration/buildcmd/test_build_cmd_dotnet.py index 6b02bc5b14a..7ee9cfd8ecb 100644 --- a/tests/integration/buildcmd/test_build_cmd_dotnet.py +++ b/tests/integration/buildcmd/test_build_cmd_dotnet.py @@ -9,7 +9,6 @@ SKIP_DOCKER_TESTS, SKIP_DOCKER_BUILD, SKIP_DOCKER_MESSAGE, - USING_FINCH_RUNTIME, run_command_with_input, ) from tests.integration.buildcmd.build_integ_base import ( @@ -23,25 +22,11 @@ class TestBuildCommand_Dotnet_cli_package(BuildIntegDotnetBase): @parameterized.expand( [ - ("provided.al2", "Dotnet7", None, None), - ("provided.al2", "Dotnet7", None, MountMode.WRITE), ("provided.al2", "Dotnet", None, None), ] ) @skipIf(SKIP_DOCKER_TESTS or SKIP_DOCKER_BUILD, SKIP_DOCKER_MESSAGE) def test_dotnet_al2(self, runtime, code_uri, mode, mount_mode): - # Skip specific test case when using Finch runtime - if ( - runtime == "provided.al2" - and code_uri == "Dotnet7" - and mode is None - and mount_mode is None - and USING_FINCH_RUNTIME - ): - self.skipTest( - "Skip test when using Finch runtime: Terraform uses Docker provider that connect to Finch daemon via Docker socket" - ) - overrides = { "Runtime": runtime, "CodeUri": code_uri, @@ -49,10 +34,7 @@ def test_dotnet_al2(self, runtime, code_uri, mode, mount_mode): "Architectures": "x86_64", } - if mode == "Dotnet": - self.template_path = self.template_path.replace("template.yaml", "template_build_method_dotnet.yaml") - else: - self.template_path = self.template_path.replace("template.yaml", "template_build_method_dotnet_7.yaml") + self.template_path = self.template_path.replace("template.yaml", "template_build_method_dotnet.yaml") self.validate_build_command(overrides, mode, mount_mode) self.validate_build_artifacts(self.EXPECTED_FILES_PROJECT_MANIFEST_PROVIDED) @@ -141,25 +123,6 @@ def test_tier1_dotnet_build_in_container(self): @pytest.mark.dotnet @skipIf(SKIP_DOCKER_TESTS or SKIP_DOCKER_BUILD, SKIP_DOCKER_MESSAGE) class TestBuildCommand_Dotnet_cli_package_interactive(BuildIntegDotnetBase): - @parameterized.expand( - [ - ("provided.al2", "Dotnet7", None), - ] - ) - def test_dotnet_al2_in_container(self, runtime, code_uri, mode): - overrides = { - "Runtime": runtime, - "CodeUri": code_uri, - "Handler": "HelloWorld::HelloWorld.Function::FunctionHandler", - "Architectures": "x86_64", - } - - self.template_path = self.template_path.replace("template.yaml", "template_build_method_dotnet_7.yaml") - - self.validate_build_command(overrides, mode, use_container=True, input="y") - self.validate_build_artifacts(self.EXPECTED_FILES_PROJECT_MANIFEST_PROVIDED) - self.validate_invoke_command(overrides, runtime) - @parameterized.expand( [ ("dotnet6", "Dotnet6", None), diff --git a/tests/integration/testdata/buildcmd/Dotnet7/HelloWorld.csproj b/tests/integration/testdata/buildcmd/Dotnet7/HelloWorld.csproj deleted file mode 100644 index 23eedf44166..00000000000 --- a/tests/integration/testdata/buildcmd/Dotnet7/HelloWorld.csproj +++ /dev/null @@ -1,25 +0,0 @@ - - - - net7.0 - true - true - true - exe - bootstrap - enable - - - - - - - - - - - - - - - diff --git a/tests/integration/testdata/buildcmd/Dotnet7/Program.cs b/tests/integration/testdata/buildcmd/Dotnet7/Program.cs deleted file mode 100755 index da7d128ea66..00000000000 --- a/tests/integration/testdata/buildcmd/Dotnet7/Program.cs +++ /dev/null @@ -1,38 +0,0 @@ -using Amazon.Lambda.APIGatewayEvents; -using Amazon.Lambda.Core; -using Amazon.Lambda.RuntimeSupport; -using Amazon.Lambda.Serialization.SystemTextJson; -using System.Text.Json.Serialization; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using System.Net.Http; -using System.Net.Http.Headers; - -namespace HelloWorld; - -public class Function -{ - /// - /// The main entry point for the custom runtime. - /// - /// - private static async Task Main(string[] args) - { - Func handler = FunctionHandler; - await LambdaBootstrapBuilder.Create(handler, new SourceGeneratorLambdaJsonSerializer()) - .Build() - .RunAsync(); - } - - public static string FunctionHandler(APIGatewayHttpApiV2ProxyRequest apigProxyEvent, ILambdaContext context) - { - return "{'message': 'Hello World'}"; - } -} - -[JsonSerializable(typeof(APIGatewayHttpApiV2ProxyRequest))] -public partial class MyCustomJsonSerializerContext : JsonSerializerContext -{ -} diff --git a/tests/integration/testdata/buildcmd/Dotnet7/aws-lambda-tools-defaults.json b/tests/integration/testdata/buildcmd/Dotnet7/aws-lambda-tools-defaults.json deleted file mode 100644 index 15c8399a215..00000000000 --- a/tests/integration/testdata/buildcmd/Dotnet7/aws-lambda-tools-defaults.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "Information" : [ - "This file provides default values for the deployment wizard inside Visual Studio and the AWS Lambda commands added to the .NET Core CLI.", - "To learn more about the Lambda commands with the .NET Core CLI execute the following command at the command line in the project root directory.", - - "dotnet lambda help", - - "All the command line options for the Lambda command can be specified in this file." - ], - - "profile":"", - "region" : "", - "configuration": "Release", - "function-runtime":"provided.al2", - "function-memory-size" : 256, - "function-timeout" : 30, - "function-handler" : "HelloWorld::HelloWorld.Function::FunctionHandler" -} diff --git a/tests/integration/testdata/buildcmd/Dotnet7/rd.xml b/tests/integration/testdata/buildcmd/Dotnet7/rd.xml deleted file mode 100644 index 6d35e8768c0..00000000000 --- a/tests/integration/testdata/buildcmd/Dotnet7/rd.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/tests/integration/testdata/buildcmd/template_build_method_dotnet_7.yaml b/tests/integration/testdata/buildcmd/template_build_method_dotnet_7.yaml deleted file mode 100644 index f2d8258707d..00000000000 --- a/tests/integration/testdata/buildcmd/template_build_method_dotnet_7.yaml +++ /dev/null @@ -1,38 +0,0 @@ -AWSTemplateFormatVersion : '2010-09-09' -Transform: AWS::Serverless-2016-10-31 - -Parameteres: - Runtime: - Type: String - CodeUri: - Type: String - Handler: - Type: String - -Resources: - - Function: - Type: AWS::Serverless::Function - Properties: - Handler: !Ref Handler - Runtime: !Ref Runtime - CodeUri: !Ref CodeUri - Timeout: 600 - Metadata: - BuildMethod: dotnet7 - - OtherRelativePathResource: - Type: AWS::ApiGateway::RestApi - Properties: - BodyS3Location: SomeRelativePath - - GlueResource: - Type: AWS::Glue::Job - Properties: - Command: - ScriptLocation: SomeRelativePath - - ExampleNestedStack: - Type: AWS::CloudFormation::Stack - Properties: - TemplateURL: https://s3.amazonaws.com/examplebucket/exampletemplate.yml diff --git a/tests/unit/commands/buildcmd/test_utils.py b/tests/unit/commands/buildcmd/test_utils.py index 2784f7c78c6..cea02549a6c 100644 --- a/tests/unit/commands/buildcmd/test_utils.py +++ b/tests/unit/commands/buildcmd/test_utils.py @@ -130,7 +130,7 @@ def test_must_prompt_for_function_with_specified_workflow(self, prompt_mock): metadata=metadata1, ) - metadata2 = {"BuildMethod": "dotnet7"} + metadata2 = {"BuildMethod": "dotnet"} function = Function( stack_path="somepath", diff --git a/tests/unit/lib/build_module/test_workflow_config.py b/tests/unit/lib/build_module/test_workflow_config.py index ec730750129..fbd2d39baeb 100644 --- a/tests/unit/lib/build_module/test_workflow_config.py +++ b/tests/unit/lib/build_module/test_workflow_config.py @@ -62,19 +62,7 @@ def test_must_work_for_provided(self, runtime): self.assertIn(Event("BuildWorkflowUsed", "provided-None"), EventTracker.get_tracked_events()) self.assertFalse(result.must_mount_with_write_in_container) - @parameterized.expand([("provided.al2",)]) - def test_must_work_for_provided_with_build_method_dotnet7(self, runtime): - result = get_workflow_config(runtime, self.code_dir, self.project_dir, specified_workflow="dotnet7") - self.assertEqual(result.language, "dotnet") - self.assertEqual(result.dependency_manager, "cli-package") - self.assertEqual(result.application_framework, None) - self.assertEqual(result.manifest_name, ".csproj") - self.assertIsNone(result.executable_search_paths) - self.assertEqual(len(EventTracker.get_tracked_events()), 1) - self.assertIn(Event("BuildWorkflowUsed", "dotnet-cli-package"), EventTracker.get_tracked_events()) - self.assertTrue(result.must_mount_with_write_in_container) - - @parameterized.expand([("dotnet6",), ("provided.al2", "dotnet7")]) + @parameterized.expand([("dotnet6",)]) def test_must_mount_with_write_for_dotnet_in_container(self, runtime, specified_workflow=None): result = get_workflow_config(runtime, self.code_dir, self.project_dir, specified_workflow) self.assertTrue(result.must_mount_with_write_in_container)