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/Amazon.Lambda.DurableExecution.csproj b/Libraries/src/Amazon.Lambda.DurableExecution/Amazon.Lambda.DurableExecution.csproj index 36d4d693f..7a1f2a7fc 100644 --- a/Libraries/src/Amazon.Lambda.DurableExecution/Amazon.Lambda.DurableExecution.csproj +++ b/Libraries/src/Amazon.Lambda.DurableExecution/Amazon.Lambda.DurableExecution.csproj @@ -58,7 +58,7 @@ <_DurableUserAgentVersionFile>$(IntermediateOutputPath)DurableUserAgentVersion.g.cs - + 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.IntegrationTests/DurableFunctionDeployment.cs b/Libraries/test/Amazon.Lambda.DurableExecution.IntegrationTests/DurableFunctionDeployment.cs index 839d9176e..91057f25f 100644 --- a/Libraries/test/Amazon.Lambda.DurableExecution.IntegrationTests/DurableFunctionDeployment.cs +++ b/Libraries/test/Amazon.Lambda.DurableExecution.IntegrationTests/DurableFunctionDeployment.cs @@ -736,13 +736,13 @@ private async Task EnsureAllFunctionsPublishedAsync() Projects="@(FunctionProject)" Targets="Restore" BuildInParallel="false" - Properties="Configuration=Release;RuntimeIdentifier=linux-x64;SelfContained=false" /> + Properties="Configuration=Release;RuntimeIdentifier=linux-x64;SelfContained=false;GenerateRuntimeConfigurationFiles=true" /> + Properties="Configuration=Release;RuntimeIdentifier=linux-x64;SelfContained=false;GenerateRuntimeConfigurationFiles=true;PublishDir=bin\publish\" /> """; @@ -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/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; } 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..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 @@ -26,7 +26,16 @@ namespace Amazon.Lambda.RuntimeSupport.UnitTests { - [CollectionDefinition("RuntimeSupportStateCheck")] + /// + /// 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. + /// Parallelization is disabled so the collection also never runs alongside classes outside it, + /// some of which construct a LogLevelLoggerWriter as well. + /// + [CollectionDefinition("RuntimeSupportStateCheck", DisableParallelization = true)] 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"); 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/build.proj b/buildtools/build.proj index 337628854..c192caffa 100644 --- a/buildtools/build.proj +++ b/buildtools/build.proj @@ -227,9 +227,25 @@ 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. --> - - - - + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/buildtools/run-integ-tests-parallel.ps1 b/buildtools/run-integ-tests-parallel.ps1 index cbb06f141..4222d2976 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 @@ -47,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)