generated from amazon-archives/__template_Apache-2.0
-
Notifications
You must be signed in to change notification settings - Fork 6
refactor(sdk): optimize finishedAncestors with finished runInChildContext tracking #386
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
11 commits
Select commit
Hold shift + click to select a range
aad1e70
Add finishedAncestors set to CheckpointManager
ParidelPooya 1e3f479
Finalize finishedAncestors implementation
ParidelPooya e03bfa4
Update parallel-wait test expectations for finishedAncestors
ParidelPooya ffb4d72
refactor(sdk): optimize finishedAncestors with hierarchical stepId pa…
ParidelPooya e28aea3
Fix parallel and map min-successful tests by moving names to correct …
ParidelPooya 9fe61af
Add comprehensive unit tests for CheckpointManager ancestor functiona…
ParidelPooya 2fd7f66
Remove leftover testing console logs
ParidelPooya 6f8c74b
feat: implement ancestor cleanup during termination
ParidelPooya 72f3c5d
fix: remove duplicate test files causing integration test failure
ParidelPooya e4cfd60
fix: give unique name to min-successful-with-passing-threshold test
ParidelPooya 6add0bc
fix: use public method instead of private operationDataMap property
ParidelPooya 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
42 changes: 42 additions & 0 deletions
42
...allel/min-successful-with-passing-threshold/min-successful-with-passing-threshold.test.ts
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,42 @@ | ||
| import { handler } from "./min-successful-with-passing-threshold"; | ||
| import { createTests } from "../../../utils/test-helper"; | ||
| import { OperationStatus } from "@aws/durable-execution-sdk-js-testing"; | ||
|
|
||
| createTests({ | ||
| localRunnerConfig: { | ||
| skipTime: false, | ||
| checkpointDelay: 100, | ||
| }, | ||
| handler, | ||
| tests: (runner) => { | ||
| it("should complete early when minSuccessful is reached", async () => { | ||
| const execution = await runner.run(); | ||
| const result = execution.getResult() as any; | ||
|
|
||
| // Assert overall results | ||
| expect(result.successCount).toBe(2); | ||
| expect(result.completionReason).toBe("MIN_SUCCESSFUL_REACHED"); | ||
| expect(result.totalCount).toBe(5); | ||
|
|
||
| // Get the parallel operation to verify individual branch results | ||
| // Get individual branch operations | ||
| const branch1 = runner.getOperation("branch-1"); | ||
| const branch2 = runner.getOperation("branch-2"); | ||
| const branch3 = runner.getOperation("branch-3"); | ||
| const branch4 = runner.getOperation("branch-4"); | ||
| const branch5 = runner.getOperation("branch-5"); | ||
|
|
||
| // First two branches should succeed (branch-1 and branch-2 complete fastest) | ||
| expect(branch1?.getStatus()).toBe(OperationStatus.SUCCEEDED); | ||
| expect(branch2?.getStatus()).toBe(OperationStatus.SUCCEEDED); | ||
| expect(branch3?.getStatus()).toBe(OperationStatus.SUCCEEDED); | ||
| expect(branch4?.getStatus()).toBe(OperationStatus.SUCCEEDED); | ||
|
|
||
| // Remaining branches should be in STARTED state (not completed) | ||
| expect(branch5?.getStatus()).toBe(OperationStatus.STARTED); | ||
|
|
||
| // Verify the results array matches | ||
| expect(result.results).toEqual(["Branch 1 result", "Branch 2 result"]); | ||
| }); | ||
| }, | ||
| }); |
89 changes: 89 additions & 0 deletions
89
...s/parallel/min-successful-with-passing-threshold/min-successful-with-passing-threshold.ts
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,89 @@ | ||
| import { | ||
| DurableContext, | ||
| withDurableExecution, | ||
| } from "@aws/durable-execution-sdk-js"; | ||
| import { ExampleConfig } from "../../../types"; | ||
| import { log } from "../../../utils/logger"; | ||
|
|
||
| export const config: ExampleConfig = { | ||
| name: "Parallel minSuccessful with Passing Threshold", | ||
| description: | ||
| "Parallel execution with minSuccessful completion config and passing threshold", | ||
| }; | ||
|
|
||
| export const handler = withDurableExecution( | ||
| async (event: any, context: DurableContext) => { | ||
| log("Starting parallel execution with minSuccessful: 2"); | ||
|
|
||
| // First brach finishes first | ||
| // Branch 2 to 4 finish in the same time | ||
| // Branc 5 will finish later | ||
| const results = await context.parallel( | ||
| "min-successful-branches", | ||
| [ | ||
| { | ||
| name: "branch-1", | ||
| func: async (ctx) => { | ||
| return await ctx.step("branch-1", async () => { | ||
| await new Promise((resolve) => setTimeout(resolve, 10)); | ||
| return "Branch 1 result"; | ||
| }); | ||
| }, | ||
| }, | ||
| { | ||
| name: "branch-2", | ||
| func: async (ctx) => { | ||
| return await ctx.step("branch-2", async () => { | ||
| await new Promise((resolve) => setTimeout(resolve, 50)); | ||
| return "Branch 2 result"; | ||
| }); | ||
| }, | ||
| }, | ||
| { | ||
| name: "branch-3", | ||
| func: async (ctx) => { | ||
| return await ctx.step("branch-3", async () => { | ||
| await new Promise((resolve) => setTimeout(resolve, 50)); | ||
| return "Branch 3 result"; | ||
| }); | ||
| }, | ||
| }, | ||
| { | ||
| name: "branch-4", | ||
| func: async (ctx) => { | ||
| return await ctx.step("branch-4", async () => { | ||
| await new Promise((resolve) => setTimeout(resolve, 50)); | ||
| return "Branch 4 result"; | ||
| }); | ||
| }, | ||
| }, | ||
| { | ||
| name: "branch-5", | ||
| func: async (ctx) => { | ||
| return await ctx.step("branch-4", async () => { | ||
| await new Promise((resolve) => setTimeout(resolve, 2000)); | ||
| return "Branch 4 result"; | ||
| }); | ||
| }, | ||
| }, | ||
| ], | ||
| { | ||
| completionConfig: { | ||
| minSuccessful: 2, | ||
| }, | ||
| }, | ||
| ); | ||
|
|
||
| await context.wait({ seconds: 1 }); | ||
|
|
||
| log(`Completed with ${results.successCount} successes`); | ||
| log(`Completion reason: ${results.completionReason}`); | ||
|
|
||
| return { | ||
| successCount: results.successCount, | ||
| totalCount: results.totalCount, | ||
| completionReason: results.completionReason, | ||
| results: results.getResults(), | ||
| }; | ||
| }, | ||
| ); |
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
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
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
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
Oops, something went wrong.
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.