From 0443bf2756c575eaa876851238f0861cb818a3c3 Mon Sep 17 00:00:00 2001 From: Daniel Pinheiro Date: Wed, 2 Dec 2026 20:06:59 +0000 Subject: [PATCH 1/7] Fix integ test stall after deployment and RuntimeSupport unit test log race Integration tests: CommandLineWrapper.RunAsync waits for the child's stdout/stderr pipes to close. MSBuild worker nodes started by the deployment script inherit those pipes and stay alive for ~15 minutes, so the fixture blocked for that long after the script finished. Disable MSBuild node reuse and the MSBuild server for the child process. Unit tests: constructing a LogLevelLoggerWriter replaces static logging callbacks on LambdaLogger. Test classes doing this ran in parallel with HandlerTests, which asserts on output captured through those callbacks. Put all such classes in the RuntimeSupportStateCheck collection and fold the StructuredLogging collection into it. --- .../LambdaBootstrapMultiConcurrencyTests.cs | 2 +- ...pMultiConcurrencyThreadPoolStarvationTests.cs | 1 + .../LambdaContextSerializerTests.cs | 1 + .../LogMessageFormatterTests.cs | 2 +- .../SharedFormatterStructuredLoggingTests.cs | 4 ++-- .../SnapstartTests.cs | 1 + .../StreamingE2EWithMoq.cs | 8 ++++++++ .../StructuredLoggingCollection.cs | 16 ---------------- .../CommandLineWrapper.cs | 7 +++++++ 9 files changed, 22 insertions(+), 20 deletions(-) delete mode 100644 Libraries/test/Amazon.Lambda.RuntimeSupport.Tests/Amazon.Lambda.RuntimeSupport.UnitTests/StructuredLoggingCollection.cs diff --git a/Libraries/test/Amazon.Lambda.RuntimeSupport.Tests/Amazon.Lambda.RuntimeSupport.UnitTests/LambdaBootstrapMultiConcurrencyTests.cs b/Libraries/test/Amazon.Lambda.RuntimeSupport.Tests/Amazon.Lambda.RuntimeSupport.UnitTests/LambdaBootstrapMultiConcurrencyTests.cs index 8b5d4671c..fe3c06f39 100644 --- a/Libraries/test/Amazon.Lambda.RuntimeSupport.Tests/Amazon.Lambda.RuntimeSupport.UnitTests/LambdaBootstrapMultiConcurrencyTests.cs +++ b/Libraries/test/Amazon.Lambda.RuntimeSupport.Tests/Amazon.Lambda.RuntimeSupport.UnitTests/LambdaBootstrapMultiConcurrencyTests.cs @@ -19,7 +19,7 @@ namespace Amazon.Lambda.RuntimeSupport.UnitTests // structured-logging callback target. That is the same static state the StructuredLogging collection guards, so this // class must run serially with those tests to avoid overwriting each other's callback registration. See // https://github.com/aws/aws-lambda-dotnet/issues/2350. - [Collection("StructuredLogging")] + [Collection("RuntimeSupportStateCheck")] public class LambdaBootstrapMultiConcurrencyTests { JsonSerializer _serializer = new JsonSerializer(); diff --git a/Libraries/test/Amazon.Lambda.RuntimeSupport.Tests/Amazon.Lambda.RuntimeSupport.UnitTests/LambdaBootstrapMultiConcurrencyThreadPoolStarvationTests.cs b/Libraries/test/Amazon.Lambda.RuntimeSupport.Tests/Amazon.Lambda.RuntimeSupport.UnitTests/LambdaBootstrapMultiConcurrencyThreadPoolStarvationTests.cs index 1e64c75c8..4dc6f56fa 100644 --- a/Libraries/test/Amazon.Lambda.RuntimeSupport.Tests/Amazon.Lambda.RuntimeSupport.UnitTests/LambdaBootstrapMultiConcurrencyThreadPoolStarvationTests.cs +++ b/Libraries/test/Amazon.Lambda.RuntimeSupport.Tests/Amazon.Lambda.RuntimeSupport.UnitTests/LambdaBootstrapMultiConcurrencyThreadPoolStarvationTests.cs @@ -24,6 +24,7 @@ namespace Amazon.Lambda.RuntimeSupport.UnitTests /// Without both changes, blocking handlers (Thread.Sleep, .Result, .Wait()) exhaust the /// ThreadPool, preventing polling tasks from cycling back to /next. /// + [Collection("RuntimeSupportStateCheck")] public class LambdaBootstrapMultiConcurrencyThreadPoolStarvationTests { private readonly JsonSerializer _serializer = new JsonSerializer(); diff --git a/Libraries/test/Amazon.Lambda.RuntimeSupport.Tests/Amazon.Lambda.RuntimeSupport.UnitTests/LambdaContextSerializerTests.cs b/Libraries/test/Amazon.Lambda.RuntimeSupport.Tests/Amazon.Lambda.RuntimeSupport.UnitTests/LambdaContextSerializerTests.cs index 034ccc530..f9cc6769f 100644 --- a/Libraries/test/Amazon.Lambda.RuntimeSupport.Tests/Amazon.Lambda.RuntimeSupport.UnitTests/LambdaContextSerializerTests.cs +++ b/Libraries/test/Amazon.Lambda.RuntimeSupport.Tests/Amazon.Lambda.RuntimeSupport.UnitTests/LambdaContextSerializerTests.cs @@ -29,6 +29,7 @@ namespace Amazon.Lambda.RuntimeSupport.UnitTests /// is exposed on the per-invocation /// via . /// + [Collection("RuntimeSupportStateCheck")] public class LambdaContextSerializerTests { private static readonly JsonSerializer SharedSerializer = new JsonSerializer(); diff --git a/Libraries/test/Amazon.Lambda.RuntimeSupport.Tests/Amazon.Lambda.RuntimeSupport.UnitTests/LogMessageFormatterTests.cs b/Libraries/test/Amazon.Lambda.RuntimeSupport.Tests/Amazon.Lambda.RuntimeSupport.UnitTests/LogMessageFormatterTests.cs index 92adaeedc..fa237f307 100644 --- a/Libraries/test/Amazon.Lambda.RuntimeSupport.Tests/Amazon.Lambda.RuntimeSupport.UnitTests/LogMessageFormatterTests.cs +++ b/Libraries/test/Amazon.Lambda.RuntimeSupport.Tests/Amazon.Lambda.RuntimeSupport.UnitTests/LogMessageFormatterTests.cs @@ -12,7 +12,7 @@ namespace Amazon.Lambda.RuntimeSupport.UnitTests { - [Collection("StructuredLogging")] + [Collection("RuntimeSupportStateCheck")] public class LogMessageFormatterTests { [Fact] diff --git a/Libraries/test/Amazon.Lambda.RuntimeSupport.Tests/Amazon.Lambda.RuntimeSupport.UnitTests/SharedFormatterStructuredLoggingTests.cs b/Libraries/test/Amazon.Lambda.RuntimeSupport.Tests/Amazon.Lambda.RuntimeSupport.UnitTests/SharedFormatterStructuredLoggingTests.cs index e056e8932..94ea4295d 100644 --- a/Libraries/test/Amazon.Lambda.RuntimeSupport.Tests/Amazon.Lambda.RuntimeSupport.UnitTests/SharedFormatterStructuredLoggingTests.cs +++ b/Libraries/test/Amazon.Lambda.RuntimeSupport.Tests/Amazon.Lambda.RuntimeSupport.UnitTests/SharedFormatterStructuredLoggingTests.cs @@ -20,10 +20,10 @@ namespace Amazon.Lambda.RuntimeSupport.UnitTests /// share a single formatter instance. /// /// The test injects an IEnvironmentVariables so it never mutates the process-wide AWS_LAMBDA_LOG_FORMAT (which - /// would race with other tests). It is placed in the serial "StructuredLogging" collection because + /// would race with other tests). It is placed in the serial "RuntimeSupportStateCheck" collection because /// ConfigureStructuredLogging mutates a process-wide static on LambdaLogger. /// - [Collection("StructuredLogging")] + [Collection("RuntimeSupportStateCheck")] public class SharedFormatterStructuredLoggingTests { /// A value type that serializes to "{}" under default options (mirrors NodaTime.Instant). diff --git a/Libraries/test/Amazon.Lambda.RuntimeSupport.Tests/Amazon.Lambda.RuntimeSupport.UnitTests/SnapstartTests.cs b/Libraries/test/Amazon.Lambda.RuntimeSupport.Tests/Amazon.Lambda.RuntimeSupport.UnitTests/SnapstartTests.cs index a10f8229c..430b51702 100644 --- a/Libraries/test/Amazon.Lambda.RuntimeSupport.Tests/Amazon.Lambda.RuntimeSupport.UnitTests/SnapstartTests.cs +++ b/Libraries/test/Amazon.Lambda.RuntimeSupport.Tests/Amazon.Lambda.RuntimeSupport.UnitTests/SnapstartTests.cs @@ -5,6 +5,7 @@ using static Amazon.Lambda.RuntimeSupport.Bootstrap.Constants; namespace Amazon.Lambda.RuntimeSupport.UnitTests; +[Collection("RuntimeSupportStateCheck")] public class SnapstartTests { readonly TestHandler _testFunction; diff --git a/Libraries/test/Amazon.Lambda.RuntimeSupport.Tests/Amazon.Lambda.RuntimeSupport.UnitTests/StreamingE2EWithMoq.cs b/Libraries/test/Amazon.Lambda.RuntimeSupport.Tests/Amazon.Lambda.RuntimeSupport.UnitTests/StreamingE2EWithMoq.cs index c93b49430..534f14604 100644 --- a/Libraries/test/Amazon.Lambda.RuntimeSupport.Tests/Amazon.Lambda.RuntimeSupport.UnitTests/StreamingE2EWithMoq.cs +++ b/Libraries/test/Amazon.Lambda.RuntimeSupport.Tests/Amazon.Lambda.RuntimeSupport.UnitTests/StreamingE2EWithMoq.cs @@ -26,6 +26,14 @@ namespace Amazon.Lambda.RuntimeSupport.UnitTests { + /// + /// Serializes every test class that mutates process-wide state on Amazon.Lambda.Core.LambdaLogger. + /// Constructing a LogLevelLoggerWriter (which every test runtime API client does) or calling + /// LambdaLogger.ConfigureStructuredLogging replaces LambdaLogger's static logging callbacks, so the + /// last one constructed wins. Tests that assert on captured log output fail intermittently if another + /// class replaces the callbacks in parallel, so all such classes must be in this single collection. + /// See https://github.com/aws/aws-lambda-dotnet/issues/2350. + /// [CollectionDefinition("RuntimeSupportStateCheck")] public class RuntimeSupportStateCheckCollection { } diff --git a/Libraries/test/Amazon.Lambda.RuntimeSupport.Tests/Amazon.Lambda.RuntimeSupport.UnitTests/StructuredLoggingCollection.cs b/Libraries/test/Amazon.Lambda.RuntimeSupport.Tests/Amazon.Lambda.RuntimeSupport.UnitTests/StructuredLoggingCollection.cs deleted file mode 100644 index 2208bc94a..000000000 --- a/Libraries/test/Amazon.Lambda.RuntimeSupport.Tests/Amazon.Lambda.RuntimeSupport.UnitTests/StructuredLoggingCollection.cs +++ /dev/null @@ -1,16 +0,0 @@ -using Xunit; - -namespace Amazon.Lambda.RuntimeSupport.UnitTests -{ - /// - /// Tests that call Amazon.Lambda.Core.LambdaLogger.ConfigureStructuredLogging mutate a process-wide - /// static callback on LambdaLogger and construct JsonLogMessageFormatter instances that register themselves as - /// that callback's target. If such tests run in parallel across classes they interfere with each other (the - /// last formatter constructed wins the static registration). Placing every such test in this single collection - /// makes xUnit run them serially. See https://github.com/aws/aws-lambda-dotnet/issues/2350. - /// - [CollectionDefinition("StructuredLogging")] - public class StructuredLoggingCollection - { - } -} diff --git a/Libraries/test/IntegrationTests.Helpers/CommandLineWrapper.cs b/Libraries/test/IntegrationTests.Helpers/CommandLineWrapper.cs index 274246771..b434c6e34 100644 --- a/Libraries/test/IntegrationTests.Helpers/CommandLineWrapper.cs +++ b/Libraries/test/IntegrationTests.Helpers/CommandLineWrapper.cs @@ -25,6 +25,13 @@ public static async Task RunAsync(string command, string workingDirectory = "", WorkingDirectory = workingDirectory }; + // Build commands run by the child (dotnet restore, dotnet lambda deploy-serverless) can leave + // MSBuild worker nodes and build servers running after the command exits. Those processes + // inherit the redirected stdout/stderr pipes, and WaitForExitAsync does not return until the + // pipes close, so the caller would block for the ~15 minute idle lifetime of the nodes. + processStartInfo.Environment["MSBUILDDISABLENODEREUSE"] = "1"; + processStartInfo.Environment["DOTNET_CLI_USE_MSBUILD_SERVER"] = "0"; + var process = Process.Start(processStartInfo); if (null == process) throw new Exception("Process.Start failed to return a non-null process"); From ce559ab3ed62f3cd809a182eff97173c462d9623 Mon Sep 17 00:00:00 2001 From: Daniel Pinheiro Date: Wed, 2 Dec 2026 21:06:48 +0000 Subject: [PATCH 2/7] Disable MSBuild node reuse for the whole integ test phase The previous fix disabled MSBuild node reuse only for deployment scripts started through CommandLineWrapper. That removed the ~15 minute stall from TestDurableServerlessApp but moved it to Amazon.Lambda.DurableExecution.IntegrationTests, whose own process helper also waits for the build's output pipes to close and now started the lingering worker nodes itself. Set MSBUILDDISABLENODEREUSE and DOTNET_CLI_USE_MSBUILD_SERVER in run-integ-tests-parallel.ps1 so every process in the integ phase inherits them, and on the durable execution process helper so running that project directly does not stall either. --- .../DurableFunctionDeployment.cs | 6 ++++++ buildtools/run-integ-tests-parallel.ps1 | 8 ++++++++ 2 files changed, 14 insertions(+) diff --git a/Libraries/test/Amazon.Lambda.DurableExecution.IntegrationTests/DurableFunctionDeployment.cs b/Libraries/test/Amazon.Lambda.DurableExecution.IntegrationTests/DurableFunctionDeployment.cs index 839d9176e..580058196 100644 --- a/Libraries/test/Amazon.Lambda.DurableExecution.IntegrationTests/DurableFunctionDeployment.cs +++ b/Libraries/test/Amazon.Lambda.DurableExecution.IntegrationTests/DurableFunctionDeployment.cs @@ -783,6 +783,12 @@ private async Task RunProcess(string fileName, string arguments, string workingD UseShellExecute = false }; + // MSBuild worker nodes and build servers started by the child outlive it and inherit the + // redirected stdout/stderr pipes. Reading those streams to the end below would then block + // for the ~15 minute idle lifetime of the nodes, so make them exit with the build. + psi.Environment["MSBUILDDISABLENODEREUSE"] = "1"; + psi.Environment["DOTNET_CLI_USE_MSBUILD_SERVER"] = "0"; + var process = System.Diagnostics.Process.Start(psi)!; if (stdin != null) diff --git a/buildtools/run-integ-tests-parallel.ps1 b/buildtools/run-integ-tests-parallel.ps1 index cbb06f141..c724fa57f 100644 --- a/buildtools/run-integ-tests-parallel.ps1 +++ b/buildtools/run-integ-tests-parallel.ps1 @@ -18,6 +18,14 @@ param( $ErrorActionPreference = 'Stop' +# The tests start builds as child processes (deployment scripts, dotnet lambda, dotnet build) and wait +# for the child's redirected output to close. MSBuild worker nodes and build servers left running by +# those builds inherit the output pipes and keep them open for their ~15 minute idle lifetime, which +# stalled whichever test project happened to start them. Every process started from here inherits +# these settings, so no build in the integ test phase leaves such processes behind. +$env:MSBUILDDISABLENODEREUSE = '1' +$env:DOTNET_CLI_USE_MSBUILD_SERVER = '0' + $projects = Get-ChildItem -Path $TestRoot -Recurse -Filter "*.IntegrationTests.csproj" | Select-Object -ExpandProperty FullName | Sort-Object From 6633015f2ca77771e6514f1d54249baa0c58fc76 Mon Sep 17 00:00:00 2001 From: Daniel Pinheiro Date: Wed, 2 Dec 2026 22:20:13 +0000 Subject: [PATCH 3/7] Fix parallel branch replay bug and streaming endpoint readiness check Durable execution: when a parallel branch completed in an earlier invocation than its parent, replaying it returned the cached result without exposing the checkpointed payload. The parent then recorded the branch with a null result, and the next resume mistook that for a stripped overflow value and re-ran the branch under the already completed parent. The service rejected that checkpoint with "Invalid checkpoint token" on every retry until the execution failed. Expose the payload on replay as on a fresh success. RuntimeSupport streaming integ tests: the fixture treated any response other than HTTP 500 as "endpoint ready", so tests started while API Gateway was still propagating the deployment. Wait for HTTP 200. --- .../durable-parallel-branch-result.json | 11 +++++++++ .../Internal/ChildContextOperation.cs | 5 +++- .../IncrementalParallelOperationTests.cs | 24 +++++++++++++++++++ .../ApiGatewayStreamingTests.cs | 4 +++- 4 files changed, 42 insertions(+), 2 deletions(-) create mode 100644 .autover/changes/durable-parallel-branch-result.json diff --git a/.autover/changes/durable-parallel-branch-result.json b/.autover/changes/durable-parallel-branch-result.json new file mode 100644 index 000000000..77cf48616 --- /dev/null +++ b/.autover/changes/durable-parallel-branch-result.json @@ -0,0 +1,11 @@ +{ + "Projects": [ + { + "Name": "Amazon.Lambda.DurableExecution", + "Type": "Patch", + "ChangelogMessages": [ + "Fix a durable execution failing with \"Invalid checkpoint token\" on every retry when the branches of a parallel operation completed in different invocations." + ] + } + ] +} diff --git a/Libraries/src/Amazon.Lambda.DurableExecution/Internal/ChildContextOperation.cs b/Libraries/src/Amazon.Lambda.DurableExecution/Internal/ChildContextOperation.cs index 6c97a8b20..5e097660d 100644 --- a/Libraries/src/Amazon.Lambda.DurableExecution/Internal/ChildContextOperation.cs +++ b/Libraries/src/Amazon.Lambda.DurableExecution/Internal/ChildContextOperation.cs @@ -137,7 +137,10 @@ protected override Task ReplayAsync(Operation existing, CancellationToken can return ExecuteFuncNoCheckpoint(cancellationToken); } // Side-effecting code runs at most once: replay returns the - // cached result without invoking the user func. + // cached result without invoking the user func. The payload is + // exposed as on a fresh success, so a parent that completes in a + // later invocation than this child still inlines the child's result. + SerializedResultPayload = existing.ContextDetails?.Result; return Task.FromResult(DeserializeResult(existing.ContextDetails?.Result)); case OperationStatuses.Failed: diff --git a/Libraries/test/Amazon.Lambda.DurableExecution.Tests/IncrementalParallelOperationTests.cs b/Libraries/test/Amazon.Lambda.DurableExecution.Tests/IncrementalParallelOperationTests.cs index 78f9452e8..d7e7d6598 100644 --- a/Libraries/test/Amazon.Lambda.DurableExecution.Tests/IncrementalParallelOperationTests.cs +++ b/Libraries/test/Amazon.Lambda.DurableExecution.Tests/IncrementalParallelOperationTests.cs @@ -1060,6 +1060,30 @@ public async Task CreateParallel_ReplaySucceeded_CorruptSummary_RecoversFromChil Assert.Empty(recorder.Flushed); // terminal parent → no re-checkpoint } + [Fact] + public async Task ParentSummary_IncludesResultOfBranchCompletedInEarlierInvocation() + { + var parentOpId = IdAt(1); + var (context, recorder, _, _) = CreateContext(new InitialExecutionState + { + Operations = new List + { + new() { Id = parentOpId, Type = OperationTypes.Context, Status = OperationStatuses.Started }, + new() { Id = ChildIdAt(parentOpId, 1), Type = OperationTypes.Context, Status = OperationStatuses.Succeeded, + Name = "a", ContextDetails = new ContextDetails { Result = "1" } } + } + }); + + await using (var parallel = context.CreateParallel()) + { + Assert.Equal(1, await parallel.Branch("a", (_, _) => Task.FromResult(-1))); + } + await recorder.Batcher.DrainAsync(); + + var parentSucceed = Assert.Single(recorder.Flushed, o => o.Id == parentOpId && o.Action == "SUCCEED"); + Assert.Equal("1", BatchSummaryCodec.ParseSummary(parentSucceed.Payload)!.Units[0].Result); + } + /// /// A serializer whose context-aware (durable) Serialize always throws, used to prove a /// serialization failure fails the branch terminally instead of completing the handle. diff --git a/Libraries/test/Amazon.Lambda.RuntimeSupport.Tests/Amazon.Lambda.RuntimeSupport.IntegrationTests/ApiGatewayStreamingTests.cs b/Libraries/test/Amazon.Lambda.RuntimeSupport.Tests/Amazon.Lambda.RuntimeSupport.IntegrationTests/ApiGatewayStreamingTests.cs index d357ee50f..30695f5ab 100644 --- a/Libraries/test/Amazon.Lambda.RuntimeSupport.Tests/Amazon.Lambda.RuntimeSupport.IntegrationTests/ApiGatewayStreamingTests.cs +++ b/Libraries/test/Amazon.Lambda.RuntimeSupport.Tests/Amazon.Lambda.RuntimeSupport.IntegrationTests/ApiGatewayStreamingTests.cs @@ -385,8 +385,10 @@ private async Task WaitForEndpointAsync() { try { + // Only a successful response means the endpoint is serving. API Gateway returns + // other errors (not just 500) while a new deployment is still propagating. var response = await httpClient.GetAsync(_apiUrl); - if (response.StatusCode != HttpStatusCode.InternalServerError) + if (response.StatusCode == HttpStatusCode.OK) { return; } From b8815a2111ff83ac9966c7996e739293dcc79b08 Mon Sep 17 00:00:00 2001 From: Daniel Pinheiro Date: Wed, 2 Dec 2026 23:01:55 +0000 Subject: [PATCH 4/7] Build and pack all libraries in one MSBuild session in CI --- buildtools/build.proj | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/buildtools/build.proj b/buildtools/build.proj index 337628854..92098e113 100644 --- a/buildtools/build.proj +++ b/buildtools/build.proj @@ -193,8 +193,23 @@ + - + + + + + + + + + + + + @@ -230,6 +245,6 @@ - + \ No newline at end of file From 7dde868e218b0cff7f06ff182a2c61912c8cdca5 Mon Sep 17 00:00:00 2001 From: Daniel Pinheiro Date: Wed, 2 Dec 2026 23:26:22 +0000 Subject: [PATCH 5/7] Keep the release build target unchanged; use the parallel build for tests only --- buildtools/build.proj | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/buildtools/build.proj b/buildtools/build.proj index 92098e113..9b84b4724 100644 --- a/buildtools/build.proj +++ b/buildtools/build.proj @@ -193,23 +193,8 @@ - - - - - - - - - - - - - + @@ -244,7 +229,23 @@ projects are picked up automatically, and exits non-zero if any project fails. --> - - + + + + + + + + + + + + + + \ No newline at end of file From 2798776527973c3ed4ed825e89fe2afc71f9f0b7 Mon Sep 17 00:00:00 2001 From: Daniel Pinheiro Date: Thu, 3 Dec 2026 02:06:00 +0000 Subject: [PATCH 6/7] Address review: isolate logger-state tests and trust integ script exit code Disable parallelization on the RuntimeSupportStateCheck collection. LambdaContextTests, W3CContextTests and RuntimeApiClientTests also construct a LogLevelLoggerWriter but are outside the collection, so they could still replace the static LambdaLogger callbacks while HandlerTests ran. Set IgnoreStandardErrorWarningFormat on the integ test Exec. A deploy that failed and then succeeded on retry printed error-formatted text, and MSBuild failed the target even though every project passed and the script exited 0. --- .../StreamingE2EWithMoq.cs | 5 +++-- buildtools/build.proj | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Libraries/test/Amazon.Lambda.RuntimeSupport.Tests/Amazon.Lambda.RuntimeSupport.UnitTests/StreamingE2EWithMoq.cs b/Libraries/test/Amazon.Lambda.RuntimeSupport.Tests/Amazon.Lambda.RuntimeSupport.UnitTests/StreamingE2EWithMoq.cs index 534f14604..8f7b5582f 100644 --- a/Libraries/test/Amazon.Lambda.RuntimeSupport.Tests/Amazon.Lambda.RuntimeSupport.UnitTests/StreamingE2EWithMoq.cs +++ b/Libraries/test/Amazon.Lambda.RuntimeSupport.Tests/Amazon.Lambda.RuntimeSupport.UnitTests/StreamingE2EWithMoq.cs @@ -32,9 +32,10 @@ namespace Amazon.Lambda.RuntimeSupport.UnitTests /// LambdaLogger.ConfigureStructuredLogging replaces LambdaLogger's static logging callbacks, so the /// last one constructed wins. Tests that assert on captured log output fail intermittently if another /// class replaces the callbacks in parallel, so all such classes must be in this single collection. - /// See https://github.com/aws/aws-lambda-dotnet/issues/2350. + /// Parallelization is disabled so the collection also never runs alongside classes outside it, + /// some of which construct a LogLevelLoggerWriter as well. /// - [CollectionDefinition("RuntimeSupportStateCheck")] + [CollectionDefinition("RuntimeSupportStateCheck", DisableParallelization = true)] public class RuntimeSupportStateCheckCollection { } /// diff --git a/buildtools/build.proj b/buildtools/build.proj index 9b84b4724..c192caffa 100644 --- a/buildtools/build.proj +++ b/buildtools/build.proj @@ -227,7 +227,7 @@ projects share no state and are run concurrently to cut the integ-test wall-clock time. The helper script discovers projects by convention (*.IntegrationTests.csproj) so new projects are picked up automatically, and exits non-zero if any project fails. --> - + + Properties="Configuration=Release;RuntimeIdentifier=linux-x64;SelfContained=false;GenerateRuntimeConfigurationFiles=true;PublishDir=bin\publish\" /> """; diff --git a/Libraries/test/TestCustomAuthorizerApp.IntegrationTests/DeploymentScript.ps1 b/Libraries/test/TestCustomAuthorizerApp.IntegrationTests/DeploymentScript.ps1 index f64ccc6a9..8a010feb6 100644 --- a/Libraries/test/TestCustomAuthorizerApp.IntegrationTests/DeploymentScript.ps1 +++ b/Libraries/test/TestCustomAuthorizerApp.IntegrationTests/DeploymentScript.ps1 @@ -83,7 +83,6 @@ try { throw "Failed to create the following bucket: $identifier" } - dotnet restore # Deploy with retries. The stack contains many Lambda functions that each reference # an IAM role created in the same stack. CloudFormation occasionally calls Lambda diff --git a/Libraries/test/TestDurableServerlessApp.IntegrationTests/DeploymentScript.ps1 b/Libraries/test/TestDurableServerlessApp.IntegrationTests/DeploymentScript.ps1 index 791c40d25..d6e1f42ea 100644 --- a/Libraries/test/TestDurableServerlessApp.IntegrationTests/DeploymentScript.ps1 +++ b/Libraries/test/TestDurableServerlessApp.IntegrationTests/DeploymentScript.ps1 @@ -59,7 +59,6 @@ try throw "Failed to create the following bucket: $identifier" } - dotnet restore Write-Host "Creating CloudFormation Stack $identifier" dotnet lambda deploy-serverless if (!$?) diff --git a/Libraries/test/TestServerlessApp.ALB.IntegrationTests/DeploymentScript.ps1 b/Libraries/test/TestServerlessApp.ALB.IntegrationTests/DeploymentScript.ps1 index f5e9e463d..3f07324de 100644 --- a/Libraries/test/TestServerlessApp.ALB.IntegrationTests/DeploymentScript.ps1 +++ b/Libraries/test/TestServerlessApp.ALB.IntegrationTests/DeploymentScript.ps1 @@ -84,7 +84,6 @@ try throw "Failed to create the following bucket: $identifier" } - dotnet restore Write-Host "Creating CloudFormation Stack $identifier, Architecture $arch" dotnet lambda deploy-serverless if (!$?) diff --git a/Libraries/test/TestServerlessApp.IntegrationTests/DeploymentScript.ps1 b/Libraries/test/TestServerlessApp.IntegrationTests/DeploymentScript.ps1 index 5802e5cbd..8d5b9c0b6 100644 --- a/Libraries/test/TestServerlessApp.IntegrationTests/DeploymentScript.ps1 +++ b/Libraries/test/TestServerlessApp.IntegrationTests/DeploymentScript.ps1 @@ -141,7 +141,6 @@ try Write-Host "Added TestTable resource to serverless.template" } - dotnet restore Write-Host "Creating CloudFormation Stack $identifier, Architecture $arch, Runtime $runtime" dotnet lambda deploy-serverless --template-parameters "ArchitectureTypeParameter=$arch" if (!$?) diff --git a/Libraries/test/TestServerlessApp.IntegrationTests/SimpleCalculator.cs b/Libraries/test/TestServerlessApp.IntegrationTests/SimpleCalculator.cs index 80dc2c4a7..b6fa981af 100644 --- a/Libraries/test/TestServerlessApp.IntegrationTests/SimpleCalculator.cs +++ b/Libraries/test/TestServerlessApp.IntegrationTests/SimpleCalculator.cs @@ -3,6 +3,7 @@ using System.Linq; using System.Net.Http; using System.Threading.Tasks; +using IntegrationTests.Helpers; using Xunit; using Xunit.Extensions.AssemblyFixture; @@ -20,7 +21,8 @@ public SimpleCalculator(IntegrationTestContextFixture fixture) [Fact] public async Task Add_FromQuery_ReturnsIntAsString() { - var response = await _fixture.HttpClient.GetAsync($"{_fixture.RestApiUrlPrefix}/SimpleCalculator/Add?x=2&y=4"); + var response = await RetryHelper.SendWithRetryOnForbiddenAsync(_fixture.HttpClient, + () => new HttpRequestMessage(HttpMethod.Get, $"{_fixture.RestApiUrlPrefix}/SimpleCalculator/Add?x=2&y=4")); response.EnsureSuccessStatusCode(); Assert.Equal("6", await response.Content.ReadAsStringAsync()); } @@ -28,13 +30,13 @@ public async Task Add_FromQuery_ReturnsIntAsString() [Fact] public async Task Subtract_FromHeader_ReturnsIntAsString() { - var httpRequestMessage = new HttpRequestMessage - { - Method = HttpMethod.Get, - RequestUri = new Uri($"{_fixture.RestApiUrlPrefix}/SimpleCalculator/Subtract"), - Headers = {{ "x", "10" }, {"y", "2"}} - }; - var response = await _fixture.HttpClient.SendAsync(httpRequestMessage); + var response = await RetryHelper.SendWithRetryOnForbiddenAsync(_fixture.HttpClient, + () => new HttpRequestMessage + { + Method = HttpMethod.Get, + RequestUri = new Uri($"{_fixture.RestApiUrlPrefix}/SimpleCalculator/Subtract"), + Headers = {{ "x", "10" }, {"y", "2"}} + }); response.EnsureSuccessStatusCode(); Assert.Equal("8", await response.Content.ReadAsStringAsync()); } @@ -42,7 +44,8 @@ public async Task Subtract_FromHeader_ReturnsIntAsString() [Fact] public async Task Multiply_FromPath_ReturnsIntAsString() { - var response = await _fixture.HttpClient.GetAsync($"{_fixture.RestApiUrlPrefix}/SimpleCalculator/Multiply/2/10"); + var response = await RetryHelper.SendWithRetryOnForbiddenAsync(_fixture.HttpClient, + () => new HttpRequestMessage(HttpMethod.Get, $"{_fixture.RestApiUrlPrefix}/SimpleCalculator/Multiply/2/10")); response.EnsureSuccessStatusCode(); Assert.Equal("20", await response.Content.ReadAsStringAsync()); } @@ -50,7 +53,8 @@ public async Task Multiply_FromPath_ReturnsIntAsString() [Fact] public async Task DivideAsync_FromPath_ReturnsIntAsString() { - var response = await _fixture.HttpClient.GetAsync($"{_fixture.RestApiUrlPrefix}/SimpleCalculator/DivideAsync/50/5"); + var response = await RetryHelper.SendWithRetryOnForbiddenAsync(_fixture.HttpClient, + () => new HttpRequestMessage(HttpMethod.Get, $"{_fixture.RestApiUrlPrefix}/SimpleCalculator/DivideAsync/50/5")); response.EnsureSuccessStatusCode(); Assert.Equal("10", await response.Content.ReadAsStringAsync()); } diff --git a/buildtools/run-integ-tests-parallel.ps1 b/buildtools/run-integ-tests-parallel.ps1 index c724fa57f..4222d2976 100644 --- a/buildtools/run-integ-tests-parallel.ps1 +++ b/buildtools/run-integ-tests-parallel.ps1 @@ -55,6 +55,18 @@ foreach ($project in $projects) } } +# The deployments also build in parallel, and they share the libraries under Libraries/src. Publish +# the deployed apps once here, the way the deployments do, so the parallel builds leave the libraries alone. +foreach ($app in 'TestCustomAuthorizerApp', 'TestDurableServerlessApp', 'TestServerlessApp', 'TestServerlessApp.ALB') +{ + dotnet publish -c $Configuration --os linux -p:GenerateRuntimeConfigurationFiles=true (Join-Path $TestRoot $app) + if ($LASTEXITCODE -ne 0) + { + Write-Host "Publish failed for $app (exit $LASTEXITCODE)." + exit 1 + } +} + $results = $projects | ForEach-Object -ThrottleLimit $ThrottleLimit -Parallel { $project = $_ $name = [System.IO.Path]::GetFileNameWithoutExtension($project)