-
Notifications
You must be signed in to change notification settings - Fork 502
update to use managed runtime and also add class library example #2434
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
Libraries/test/Amazon.Lambda.DurableExecution.IntegrationTests/ClassLibraryTest.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| using System.Linq; | ||
| using System.Text; | ||
| using Amazon.Lambda.Model; | ||
| using Xunit; | ||
| using Xunit.Abstractions; | ||
|
|
||
| namespace Amazon.Lambda.DurableExecution.IntegrationTests; | ||
|
|
||
| /// <summary> | ||
| /// Proves a durable function works on the managed <c>dotnet10</c> runtime using the | ||
| /// <b>class-library programming model</b> — a plain <c>Handler</c> method with no | ||
| /// <c>Main</c>/<c>LambdaBootstrap</c> loop, deployed via an <c>Assembly::Type::Method</c> | ||
| /// handler string. Confirms the RuntimeSupport durable-execution changes are live in | ||
| /// the managed runtime, so the executable model is no longer required. | ||
| /// </summary> | ||
| public class ClassLibraryTest | ||
| { | ||
| private readonly ITestOutputHelper _output; | ||
| public ClassLibraryTest(ITestOutputHelper output) => _output = output; | ||
|
|
||
| [Fact] | ||
| public async Task ClassLibrary_TwoSteps_Checkpointed() | ||
| { | ||
| await using var deployment = await DurableFunctionDeployment.CreateAsync( | ||
| DurableFunctionDeployment.FindTestFunctionDir("ClassLibraryFunction"), | ||
| "classlib", _output, | ||
| handler: "ClassLibraryFunction::ClassLibraryFunction.Function::Handler"); | ||
|
|
||
| var (invokeResponse, executionName) = await deployment.InvokeAsync("""{"orderId": "chain"}"""); | ||
| Assert.Equal(200, invokeResponse.StatusCode); | ||
|
|
||
| var responsePayload = Encoding.UTF8.GetString(invokeResponse.Payload.ToArray()); | ||
| _output.WriteLine($"Response: {responsePayload}"); | ||
|
|
||
| var arn = await deployment.FindDurableExecutionArnByNameAsync(executionName, TimeSpan.FromSeconds(60)); | ||
| Assert.NotNull(arn); | ||
|
|
||
| var status = await deployment.PollForCompletionAsync(arn!, TimeSpan.FromSeconds(60)); | ||
| Assert.Equal("SUCCEEDED", status, ignoreCase: true); | ||
|
|
||
| // History is eventually consistent — wait until both steps are indexed. | ||
| var history = await deployment.WaitForHistoryAsync( | ||
| arn!, | ||
| h => (h.Events?.Count(e => e.EventType == EventType.StepStarted) ?? 0) >= 2 | ||
| && (h.Events?.Count(e => e.StepSucceededDetails != null) ?? 0) >= 2, | ||
| TimeSpan.FromSeconds(60)); | ||
| var events = history.Events ?? new List<Event>(); | ||
|
|
||
| // Both steps ran exactly once, in declaration order, each chaining from the | ||
| // previous one's output — same checkpointing behavior as the executable model. | ||
| Assert.Equal(2, events.Count(e => e.EventType == EventType.StepStarted)); | ||
|
|
||
| var stepResults = events | ||
| .Where(e => e.StepSucceededDetails != null) | ||
| .Select(e => $"{e.Name}={e.StepSucceededDetails.Result?.Payload?.Trim('"')}") | ||
| .ToList(); | ||
| Assert.Equal( | ||
| new[] | ||
| { | ||
| "step_1=a-chain", | ||
| "step_2=a-chain-b", | ||
| }, | ||
| stepResults); | ||
| } | ||
| } |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
runtime support changes for #2378 is deployed in all regions for people making new lambda functions
with using managed runtime - its deployed to some regions but not all.
i was thinking we can update docs to say its available and then in the github issue just mention its still rolling out to some regions. i dont want to wait to update the docs is why