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-runner): test update path when running tests #19915

Merged
merged 3 commits into from
Apr 14, 2022
Merged

feat(integ-runner): test update path when running tests #19915

merged 3 commits into from
Apr 14, 2022

Conversation

corymhall
Copy link
Contributor

@corymhall corymhall commented Apr 14, 2022

This PR adds an "update path" workflow to the integration test
workflow. When a change is being made to an existing integration test we
want to be able to ensure that the change not only works for new
stacks, but also with existing stacks. In order to accomplish this,
the runner will first deploy the existing snapshot (i.e. cdk deploy --app /path/to/snapshot) and then perform a stack update by deploying
the integration test.

The update path can be disabled by passing the --disable-update-path
command line option.

This PR adds a couple of pieces of functionality in order to enable
testing the "update path".

  1. The runner will attempt to checkout the snapshot from the origin
    before running the test. This is to try and make sure that you are
    actually testing an update of the existing snapshot and not an
    intermediate snapshot (e.g. if you have been iterating locally).
  2. When the runner performs the snapshot diff, it will check for any
    destructive changes and return that information as a warning to the
    user.
  3. If any destructive changes are found, the runner will record that
    information as trace metadata in the manifest.json file. This will
    enable us to create automation that checks for this as part of the PR
    workflow

Added logic to include the allowDestroy option in items 2 & 3 above.
If a resource type is included in the allowDestroy list, then
it will not be reported.


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 adds an "update path" workflow to the integration test
workflow. When a change is being made to an existing integration test we
want to be able to ensure that the change not only works for _new_
stacks, but also with _existing_ stacks. In order to accomplish this,
the runner will first deploy the existing snapshot (i.e. `cdk deploy
--app /path/to/snapshot`) and then perform a stack update by deploying
the integration test.

The update path can be disabled by passing the `--disable-update-path`
command line option.

This PR adds a couple of pieces of functionality in order to enable
testing the "update path".

1. The runner will attempt to checkout the snapshot from the origin
   before running the test. This is to try and make sure that you are
   actually testing an update of the existing snapshot and not an
   intermediate snapshot (e.g. if you have been iterating locally).
2. When the runner performs the snapshot diff, it will check for any
   destructive changes and return that information as a warning to the
   user.
3. If any destructive changes are found, the runner will record that
   information as trace metadata in the `manifest.json` file. This will
   enable us to create automation that checks for this as part of the PR
   workflow
@gitpod-io
Copy link

gitpod-io bot commented Apr 14, 2022

@github-actions github-actions bot added the p2 label Apr 14, 2022
@aws-cdk-automation aws-cdk-automation requested a review from a team April 14, 2022 13:11
@mergify mergify bot added the contribution/core This is a PR that came from AWS. label Apr 14, 2022
packages/@aws-cdk/integ-runner/lib/cli.ts Outdated Show resolved Hide resolved
* This assumes that there is an 'origin'. `git remote show origin` returns a list of
* all branches and we then search for one that starts with `HEAD branch: `
*/
private checkoutSnapshot(): void {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens when the snapshot hasn't been added to git yet?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm good question. Currently it will throw a warning saying it couldn't checkout the snapshot directory. I think it might be best to just add some info to the README about iterating on new tests, i.e. if you are working on a new test you should run with --disable-update-workflow.

If it's a new test (snapshot hasn't been added to git) you shouldn't be using the update workflow. And I don't think there is a good way for us to automatically figure this out since you could have commited the snapshot and then run the test.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added section to readme.

@mergify
Copy link
Contributor

mergify bot commented Apr 14, 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).

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

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

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

@mergify mergify bot merged commit d0ace8f into aws:master Apr 14, 2022
@mergify
Copy link
Contributor

mergify bot commented Apr 14, 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).

StevePotter pushed a commit to StevePotter/aws-cdk that referenced this pull request Apr 27, 2022
This PR adds an "update path" workflow to the integration test
workflow. When a change is being made to an existing integration test we
want to be able to ensure that the change not only works for _new_
stacks, but also with _existing_ stacks. In order to accomplish this,
the runner will first deploy the existing snapshot (i.e. `cdk deploy
--app /path/to/snapshot`) and then perform a stack update by deploying
the integration test.

The update path can be disabled by passing the `--disable-update-path`
command line option.

This PR adds a couple of pieces of functionality in order to enable
testing the "update path".

1. The runner will attempt to checkout the snapshot from the origin
   before running the test. This is to try and make sure that you are
   actually testing an update of the existing snapshot and not an
   intermediate snapshot (e.g. if you have been iterating locally).
2. When the runner performs the snapshot diff, it will check for any
   destructive changes and return that information as a warning to the
   user.
3. If any destructive changes are found, the runner will record that
   information as trace metadata in the `manifest.json` file. This will
   enable us to create automation that checks for this as part of the PR
   workflow

Added logic to include the `allowDestroy` option in items 2 & 3 above.
If a resource type is included in the `allowDestroy` list, then
it will not be reported.


----

### All Submissions:

* [x] Have you followed the guidelines in our [Contributing guide?](https:/aws/aws-cdk/blob/master/CONTRIBUTING.md)

### Adding new Unconventional Dependencies:

* [ ] This PR adds new unconventional dependencies following the process described [here](https:/aws/aws-cdk/blob/master/CONTRIBUTING.md/#adding-new-unconventional-dependencies)

### New Features

* [ ] Have you added the new feature to an [integration test](https:/aws/aws-cdk/blob/master/INTEGRATION_TESTS.md)?
	* [ ] 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*
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants