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: extend end-to-end test workflows #427

Merged
merged 85 commits into from
Jan 16, 2024
Merged

Conversation

madeline-k
Copy link
Contributor

@madeline-k madeline-k commented Nov 29, 2023

This PR extends the current end-to-end tests to add some additional capabilities. See the workflow diagram for the full flow. The high-level steps for each end-to-end test are:

  1. Create a Cloudformation Stack from the input CFN template
  2. Run cdk-from-cfn to synthesize a cdk stack definition in any target language from the input CFN template
  3. Create a working CDK App with the cdk stack definition
  4. Run CDK synth on the CDK App
  5. Verify the output of CDK synth has not changed, and store the diff from the original template in a file for review.

Notes for reviewers:

  • I moved some logic out of the test_case macro and into functions to make it easier to work with, because auto-complete does not work inside macros. The macro is still necessary to avoid having to write a test module for each end-to-end test and a test fn for each language. Autocomplete breaks inside macro rust-lang/rust-analyzer#12524
  • Using environment variables instead of cli flags to configure the end to end test workflow, because passing cli args through to your test functions is not supported by Rust's libtest. (We could do this with a custom test binary implementation as a future improvement.)
  • I am keeping the generated CDK stack code in the "snapshots", because this has been very helpful for reviewing changes to the code-gen. With this update, manual review of the generated CDK code is no longer always necessary to verify that the generated code works, because the end-to-end tests now actually run cdk synth on them. The manual review is especially helpful for reviewing style, format, etc. of the generated code.
  • CDK Synth is being skipped for some tests for a few reasons
    • simple::golang

      produces code that has errors during cdk synth (expand to see errors)
      ./stack.go:100:2: isUs declared and not used
      ./stack.go:100:71: not enough arguments in call to cdk.Fn_Split
          have (*string, *string)
          want (*string, *string, *float64)
      ./stack.go:129:27: undefined: LoggingConfiguration
      ./stack.go:132:27: undefined: WebsiteConfiguration
      ./stack.go:133:29: undefined: RedirectAllRequestsTo
      ./stack.go:143:21: cannot use table[jsii.String("Values")][jsii.String("String")] (map index expression of type interface{}) as *string value in argument to cdk.Fn_Base64: need type assertion
      
    • config::golang

      produces code that has errors during cdk synth (expand to see errors)
      ```
      ./stack.go:86:18: undefined: Policy
      ./stack.go:87:6: undefined: Policy
      ./stack.go:131:18: undefined: Policy
      ./stack.go:132:6: undefined: Policy
      ./stack.go:201:39: undefined: ConfigSnapshotDeliveryProperties
      ./stack.go:213:11: undefined: Code
      ./stack.go:271:21: undefined: RecordingGroup
      ./stack.go:285:12: undefined: Scope
      ./stack.go:291:13: undefined: Source
      ./stack.go:293:24: undefined: SourceDetail
      ./stack.go:293:24: too many errors
      ```
      </details>
      
    • documentdb::golang

      produces code that has errors during cdk synth (expand to see errors)
      ./stack.go:5:2: "github.com/aws/aws-cdk-go/awscdk/v2/awsdocdb" imported as docdb and not used
      ./stack.go:40:15: undefined: doc_db
      ./stack.go:43:4: undefined: doc_db
      ./stack.go:51:2: undefined: doc_db
      ./stack.go:54:4: undefined: doc_db
      
    • resource_w_json_type_properties::golang

      produces code that has errors during cdk synth (expand to see errors)
      ./stack.go:44:18: undefined: Policy
      ./stack.go:45:6: undefined: Policy
      
    • config::java, resource_w_json_type_properties::java
      These tests do not fail CDK synth, but CDK synth produces templates with a non-deterministic order. This makes the tests validation of the produced template fail. We need to make the validation mechanism for these tests more sophisticated so that it can recognize equivalent templates, even when the json objects and properties are not necessarily in the same order.

    • sam_nodejs_lambda and sam_nodejs_lambda_arr_transform
      These are new tests since I've been finalizing this PR. They still need to be run with cdk synth to see if it works or not.

Future improvements to the end-to-end tests

#506
#507
#508
#509
#510
#511

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@madeline-k madeline-k marked this pull request as draft November 29, 2023 00:59
auto-merge was automatically disabled November 29, 2023 00:59

Pull request was converted to draft

Copy link
Contributor

@comcalvi comcalvi left a comment

Choose a reason for hiding this comment

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

Looks really good! I have mostly minor comments

Copy link

codecov bot commented Jan 16, 2024

Codecov Report

Merging #427 (8510bb5) into main (a5da541) will decrease coverage by 0.5%.
The diff coverage is n/a.

Additional details and impacted files
Components Coverage Δ
Parser 76.0% <ø> (-1.2%) ⬇️
Intermediate Representation 82.0% <ø> (-0.2%) ⬇️
Synthesizers 87.5% <ø> (-0.6%) ⬇️
Other 50.5% <ø> (ø)
@@           Coverage Diff           @@
##            main    #427     +/-   ##
=======================================
- Coverage   84.4%   83.9%   -0.5%     
=======================================
  Files         27      27             
  Lines       4852    4852             
  Branches    4852    4852             
=======================================
- Hits        4095    4069     -26     
- Misses       556     582     +26     
  Partials     201     201             
Files Coverage Δ
src/lib.rs 87.5% <ø> (ø)

... and 8 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a5da541...8510bb5. Read the comment docs.

@cdklabs-automation cdklabs-automation added this pull request to the merge queue Jan 16, 2024
Merged via the queue into main with commit 6ef3dd6 Jan 16, 2024
@cdklabs-automation cdklabs-automation deleted the madeline-k/dev branch January 16, 2024 23:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants