feat(idempotency): add E2E tests for durable functions#4965
feat(idempotency): add E2E tests for durable functions#4965ConnorKirk wants to merge 1 commit intomainfrom
Conversation
Add E2E tests to verify idempotency behavior with AWS Lambda durable functions. Changes: - Add TestNodejsDurableFunction to testing-utils for creating Lambda functions with durableConfig - Add IdempotencyTestDurableFunctionAndDynamoTable construct - Add E2E tests verifying: - Durable execution with wait step executes successfully - Duplicate payload returns same result (idempotent) - Concurrent executions handled correctly - Add @aws/durable-execution-sdk-js as dev dependency Closes #4839
|
|
I kiro'd this. It needs a thorough review before marking it ready. I like the GH diff, so opening a draft PR. |
| minify: true, | ||
| mainFields: ['module', 'main'], | ||
| sourceMap: false, | ||
| format: OutputFormat.ESM, |
There was a problem hiding this comment.
I don't think this should be hardcoded, we should follow the way it's done in TestNodejsFunction above.
| mainFields: ['module', 'main'], | ||
| sourceMap: false, | ||
| format: OutputFormat.ESM, | ||
| banner: `import { createRequire } from 'module';const require = createRequire(import.meta.url);`, |
There was a problem hiding this comment.
Again this should be handled the same way as TestNodejsFunction. We should only add this polyfil in the test if necessary, which generally only applies if we are using a dependency that is CommonJS only.
| timeout: Duration.seconds(30), | ||
| }, | ||
| }, | ||
| { nameSuffix: 'fn' } |
There was a problem hiding this comment.
This is where we add whether to use ESM or not, as mentioned in my comment about the CDK construct. The parameter is outputFormat.
There was a problem hiding this comment.
This entire file doesn't need to exist.
The only difference - from a CDK construct perspective - between a Durable Function and an On Demand one is these 4 lines which you should be able to pass as props.
durableConfig: {
executionTimeout: Duration.minutes(5),
retentionPeriod: Duration.days(1),
},There was a problem hiding this comment.
This file also doesn't need to exist, there's nothing special to this construct that cannot be achieved by composing the existing L2.5 CDK constructs we already have.
| const invokeDurableFunction = async ( | ||
| lambda: LambdaClient, | ||
| functionName: string, | ||
| payload: object | ||
| ): Promise<{ result: string | undefined }> => { | ||
| const response = await lambda.send( | ||
| new InvokeCommand({ | ||
| FunctionName: functionName, | ||
| Payload: JSON.stringify(payload), | ||
| }) | ||
| ); | ||
|
|
||
| const result = response.Payload | ||
| ? JSON.parse(new TextDecoder().decode(response.Payload)) | ||
| : undefined; | ||
|
|
||
| return { result }; | ||
| }; |
There was a problem hiding this comment.
We already have utilities to invoke functions, these tests should reuse what's there.
|
Superseded by #4979 |




Summary
Changes
Add E2E tests to verify idempotency behavior with AWS Lambda durable functions.
Changes:
TestNodejsDurableFunctionto testing-utils for creating Lambda functions withdurableConfigIdempotencyTestDurableFunctionAndDynamoTableconstruct for idempotency E2E tests@aws/durable-execution-sdk-jsas dev dependencyIssue number: closes #4839
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.