Skip to content
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

feat(integ-tests): make assertions on deployed infrastructure #20071

Merged
merged 4 commits into from
Apr 25, 2022
Merged

feat(integ-tests): make assertions on deployed infrastructure #20071

merged 4 commits into from
Apr 25, 2022

Conversation

corymhall
Copy link
Contributor

@corymhall corymhall commented Apr 25, 2022

This PR introduces a new group of constructs that allow you to make
assertions against deployed infrastructure. They are not exported yet
so we can work through the todo list in follow up PRs.

TODO:

  • Add more assertion types (i.e. objectContaining)
  • Update integ-runner to collect the assertion results
  • Assertion custom resources should not(?) be part of the snapshot
    diff
  • Assertions need to be run on every deploy (i.e. update workflow)
    but that should not be part of the snapshot diff

All Submissions:

Adding new Unconventional Dependencies:

  • This PR adds new unconventional dependencies following the process described here

New Features

  • Have you added the new feature to an integration test?
    • Did you use yarn integ to deploy the infrastructure and generate the snapshot (i.e. yarn integ without --dry-run)?

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

This PR introduces a new group of constructs that allow you to make
assertions against deployed infrastructure.

TODO:
- [ ] Add more assertion types (i.e. objectContaining)
- [ ] Update integ-runner to collect the assertion results
- [ ] Assertion custom resources should not(?) be part of the snapshot
  diff
- [ ] Assertions need to be run on every deploy (i.e. update workflow)
      but that should not be part of the snapshot diff
@mergify mergify bot added the contribution/core This is a PR that came from AWS. label Apr 25, 2022
@gitpod-io
Copy link

gitpod-io bot commented Apr 25, 2022

@github-actions github-actions bot added the p2 label Apr 25, 2022
@aws-cdk-automation aws-cdk-automation requested a review from a team April 25, 2022 14:24
@corymhall corymhall marked this pull request as ready for review April 25, 2022 16:56
@corymhall corymhall requested a review from otaviomacedo April 25, 2022 16:56
@corymhall
Copy link
Contributor Author

Current experience

const app = new App();                                                                                                                                                              
const stack = new Stack(app, 'aws-stepfunctions-tasks-eventbridge-put-events-integ');                                                                                               
                                                                                                                                                                                    
const eventBus = new events.EventBus(stack, 'EventBus', {                                                                                                                           
  eventBusName: 'MyEventBus1',                                                                                                                                                      
});                                                                                                                                                                                 
                                                                                                                                                                                    
const putEventsTask = new stepfunctions_tasks.EventBridgePutEvents(stack, 'Put Custom Events', {                                                                                    
  entries: [{                                                                                                                                                                       
    // Entry with no event bus specified                                                                                                                                            
    detail: sfn.TaskInput.fromObject({                                                                                                                                              
      Message: 'Hello from Step Functions!',                                                                                                                                        
    }),                                                                                                                                                                             
    detailType: 'MessageFromStepFunctions',                                                                                                                                         
    source: 'step.functions',                                                                                                                                                       
  }, {                                                                                                                                                                              
    // Entry with EventBus provided as object                                                                                                                                       
    detail: sfn.TaskInput.fromObject({                                                                                                                                              
      Message: 'Hello from Step Functions!',                                                                                                                                        
    }),                                                                                                                                                                             
    eventBus,                                                                                                                                                                       
    detailType: 'MessageFromStepFunctions',                                                                                                                                         
    source: 'step.functions',                                                                                                                                                       
  }],                                                                                                                                                                               
});                                                                                                                                                                                 
                                                                                                                                                                                    
const sm = new sfn.StateMachine(stack, 'StateMachine', {                                                                                                                            
  definition: putEventsTask,
  timeout: Duration.seconds(30),             
});    

new IntegTest(app, 'IntegTest', {
  testCases: [                               
    new IntegTestCase(app, 'TestCase', {
      stacks: [stack],                       
    }),                                        
  ],                                         
});       

const assert = new DeployAssert(
  stack,
);

// Start an execution
const start = assert.queryAws({
  api: 'startExecution',
  service: 'StepFunctions',
  parameters: {
    stateMachineArn: sm.stateMachineArn,
  },
});

// describe the results of the execution
const describe = assert.queryAws({
  api: 'describeExecution',
  service: 'StepFunctions',
  parameters: {
    executionArn: start.getAttString('executionArn'),
  },
});

// assert the results
assert.registerAssertion(describe.assertEqual({
  status: 'SUCCEEDED',
}, 'success'));

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject89A8053A-LhjRyN9kxr8o
  • Commit ID: 4dd82ed
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@corymhall corymhall added pr-linter/exempt-readme The PR linter will not require README changes pr-linter/exempt-integ-test The PR linter will not require integ test changes labels Apr 25, 2022
@mergify
Copy link
Contributor

mergify bot commented Apr 25, 2022

Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@mergify mergify bot merged commit 8362efe into aws:master Apr 25, 2022
@mergify
Copy link
Contributor

mergify bot commented Apr 25, 2022

Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contribution/core This is a PR that came from AWS. p2 pr-linter/exempt-integ-test The PR linter will not require integ test changes pr-linter/exempt-readme The PR linter will not require README changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants