Skip to content

Commit

Permalink
chore(stepfunctions): add waitForAssertions to distributed-map asse…
Browse files Browse the repository at this point in the history
…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
colifran committed May 21, 2024
1 parent 168cdac commit 3a59d78
Show file tree
Hide file tree
Showing 10 changed files with 5,063 additions and 6,669 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 3a59d78

Please sign in to comment.