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

test(cli): cdk import bundles and emits proper metadata #33372

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

iankhou
Copy link
Contributor

@iankhou iankhou commented Feb 11, 2025

Improves testing for #33322.

Reason for this change

The original test (removed below) does not adequately test the CDK import fix from the above-mentioned PR. It calls CDK synth, but does not use the CLI and does not test cdk import.

Description of changes

The test below covers many cases where code is supposed to be bundled, and appropriate metadata is supposed to be emitted. It ensures that CDK Import will bundle code when it synthesizes a new template.

Describe any new or updated permissions being added

No permissions changes.

Description of how you validated changes

This PR tests the feature. I ensured that the test failed on code prior to the change in PR #33322, and passes on code following the change.

Checklist


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

@iankhou iankhou self-assigned this Feb 11, 2025
@github-actions github-actions bot added the p2 label Feb 11, 2025
@aws-cdk-automation aws-cdk-automation requested a review from a team February 11, 2025 01:45
@mergify mergify bot added the contribution/core This is a PR that came from AWS. label Feb 11, 2025
@iankhou iankhou changed the title Iankhou import bundle test test(cli): cdk import is bundled and emits proper metadata Feb 11, 2025
@iankhou iankhou changed the title test(cli): cdk import is bundled and emits proper metadata test(cli): cdk import bundles and emits proper metadata Feb 11, 2025
@iankhou iankhou marked this pull request as ready for review February 11, 2025 01:50
@iankhou iankhou requested a review from a team as a code owner February 11, 2025 01:50
Copy link

codecov bot commented Feb 11, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 80.92%. Comparing base (36b7e5f) to head (5265e46).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #33372   +/-   ##
=======================================
  Coverage   80.92%   80.92%           
=======================================
  Files         236      236           
  Lines       14256    14256           
  Branches     2491     2491           
=======================================
  Hits        11537    11537           
  Misses       2434     2434           
  Partials      285      285           
Flag Coverage Δ
suite.unit 80.92% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
packages/aws-cdk 79.74% <ø> (ø)
packages/aws-cdk-lib/core 82.20% <ø> (ø)

@iankhou iankhou deployed to test-pipeline February 11, 2025 02:10 — with GitHub Actions Active
@aws-cdk-automation
Copy link
Collaborator

➡️ PR build request submitted to test-main-pipeline ⬅️

A maintainer must now check the pipeline and add the pr-linter/cli-integ-tested label once the pipeline succeeds.

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildv2Project1C6BFA3F-wQm2hXv2jqQv
  • Commit ID: 5265e46
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

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

@aws-cdk-automation aws-cdk-automation added the pr/needs-maintainer-review This PR needs a review from a Core Team Member label Feb 11, 2025
*
*/
integTest(
'CDK import adds the metadata properties expected by sam, validates that bundling is not skipped',
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider the issue we're trying to fix - does this test accurately simulate the scenario described in the issue?

It does address the root cause that we identified, but it doesn't give us enough guarantees that the original issue is actually fixed. It might be that something else will block the expected behavior. Think about the manual test you ran to validate the fix works, can you reproduce that manual test here?

  1. Deploy a stack with NodeJsFunction construct.
  2. Create a bucket out of band
  3. Run cdk import --resource-mappings

Should be feasible...

As for the scenarios you put here, they can serve as additional, quicker tests, that help us diagnose the issue in case of failures, but should not be the only ones. Prefer many small tests over fewer large complicated ones.

Also is the withSamIntegrationFixture really needed here? I understand it might be convenient because it has constructs you want as well, but seems like it also has a bunch of other things that we don't need. See if you can write your own stack in the normal app fixture, tailored to your use case.

@aws-cdk-automation aws-cdk-automation removed the pr/needs-maintainer-review This PR needs a review from a Core Team Member label Feb 11, 2025
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