Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(stepfunctions): add
waitForAssertions
to distributed-map asse…
…rtions to wait for the expected resource state (#30286) ### Reason for this change Two assertions made in `integ.distributed-map.ts` are waiting on a specific resource state. The following waits for a state machine to be `ACTIVE`: ```ts testCase.assertions .awsApiCall('StepFunctions', 'describeStateMachine', { stateMachineArn: stack.stateMachine.stateMachineArn, }) .expect(ExpectedResult.objectLike({ status: 'ACTIVE' })); ``` The following wait for the state machine execution to be `SUCCEEDED`: ```ts describe.expect(ExpectedResult.objectLike({ status: 'SUCCEEDED', })); ``` In the current format, the second assertion fails because the state machine execution is still running at the time the assertion is made. This causes the integ test to fail with the following error: ``` { "executionArn": "arn:aws:states:us-east-1:123456789012:execution:StateMachine2E01A3A5-OqZg4PaGWIUA:ecfc64d5-c20e-483b-a2ec-9ef8f82b2214", "input": "{}", "inputDetails": { ... }, "name": "ecfc64d5-c20e-483b-a2ec-9ef8f82b2214", "redriveCount": 0, "redriveStatus": "NOT_REDRIVABLE", "redriveStatusReason": "Execution is RUNNING and cannot be redriven", "startDate": {}, "stateMachineArn": "arn:aws:states:us-east-1:123456789012:stateMachine:StateMachine2E01A3A5-OqZg4PaGWIUA", !! Expected SUCCEEDED but received RUNNING "status": "RUNNING", "traceHeader": "Root=1-664c0401-4504db7463bcd92c490e52bc;Parent=5ea37aeb46708a96;Sampled=0" } ``` As a best practice, we should always ensure that assertions based on resource state have a `waitForAssertions` call to force the assertion to wait for the specific state to occur. ### Description of changes I added a `waitForAssertions` call to each assertion in this integ test that is waiting for a specific resource state. Each `waitForAssertions` call has the following waiter options: - A total timeout of 5 minutes, after which the assertion will fail. - A 10 second interval which will be used to check if the resource is in the expected state. ### Description of how you validated changes Re-ran the integ test and it succeeded. ### Checklist - [x] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md) ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
- Loading branch information