-
Notifications
You must be signed in to change notification settings - Fork 4k
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
chore(cli): add SAM CDK integration test cases #18875
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I appreciate the submission, but I have a couple of concerns:
- The tests seem better off as unit tests than integration tests. It's not clear to me what exactly it is they are testing, which is something you can clearly encode into a unit test (vs an integration/shapshot test). Also, if they were unit tests, you wouldn't need all the additional changes to the integ test machinery.
- If they are going to be integration tests, they need to run the actual SAM CLI against some actual CDK apps.
cdk-sam-integ-assert
-> if you were going to do this (which I'd rather you don't), then it seems we're adding a new CLI and a new convention for what is essentially a boolean flag flip: "also check something about assets". That could have been encoded with a/// pragma
, which we already have some code for, which makes this more flexible in the future as well.- But the things you are encoding for assets are very v1-specific (or to be more precise:
LegacyStackSynthesizer
-specific). In v2 (or using theDefaultStackSynthesizer
), asset references look completely different and all the assertions you just wrote about{ Ref }
s and{ Fn::Join }
s are going out the window. It seems unlikely these are the things you actually want to be asserting, because they are things we are asserting. But because of the nature of snapshot tests, it's hard for me to tell what it is you are trying to assert, which brings me back to point 1.
For now:
- Can you reframe the things about templates and artifacts you are trying to assert as unit tests?
- Can you describe what a real integ test involving the CLI would look like? What are we synthing, what are we deploying, and what should the end result look like?
Thanks @rix0rrr for your comment.
I will see how can I move this logic to be done in unit testing. |
I understand, and I appreciate it! Nevertheless, we should ultimately have something like this. We should make a TODO for ourselves to add these. If you do decide to add a test like this, it should probably go into the set of CLI integ tests: https://github.com/aws/aws-cdk/blob/master/packages/aws-cdk/test/integ/cli/cli.integtest.ts, which are actual integ tests, that run in a Docker image we control, so we could preinstall SAM CLI there.
Thank you! |
we already add this testing in SAM repo here. We have a job that run daily against the latest CDK V1 and V2 releases to validate that the new release does not break this integration. The point here is we need to do that before the release. |
Do you have any docs that explain how to update these integ tests, how to local validate it, and how to update the docker image? |
Of course not 😛
Not really but copy/paste should get you far
To run a single integ test in the source tree:
https://github.com/aws/aws-cdk/blob/master/packages/aws-cdk/CONTRIBUTING.md
|
Pull request has been modified.
8213fba
to
c688f7c
Compare
@@ -65,7 +65,8 @@ | |||
"sinon": "^9.2.4", | |||
"ts-jest": "^27.1.3", | |||
"ts-mock-imports": "^1.3.8", | |||
"xml-js": "^1.6.11" | |||
"xml-js": "^1.6.11", | |||
"axios": "^0.25.0" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs to go somewhere into some test runner script where we also install jest
, not here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yarn build
fails if I removed axios
from package.json
as it is required to invoke the exposed api to validate the integration with sam.
Pull request has been modified.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Must be merged only AFTER the newest jsii is released, so that jsii/superchain
has the SAM CLI.
When I run the new integ tests through a test pipeline, they are all failing with the same error:
Do they succeed if you run them locally in a superchain container? (read here how) |
@rix0rrr .. Yes all test cases passed successfully locally.
|
Does that work from a fresh checkout as well? Is there a chance you have files in your working copy that aren't checked in? (Because of gitignore or other reasons?) |
I tested it in Cloud9 to make sure that it does not depend on any file in my machine. I found some issue, fixed it, and it is working fine now. Could you please retry the testing flow. |
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 CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
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). |
---- Add Integration test cases to cover the integration with SAM CLI tool. *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
---- Add Integration test cases to cover the integration with SAM CLI tool. *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Add Integration test cases to cover the integration with SAM CLI tool.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license