-
Notifications
You must be signed in to change notification settings - Fork 2.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: run cfn lint on test output #888
Conversation
@@ -9,7 +9,7 @@ class NestedStack(Resource): | |||
property_types = { | |||
'TemplateURL': PropertyType(True, is_str()), | |||
'Parameters': PropertyType(False, is_type(dict)), | |||
'NotificationArns': PropertyType(False, list_of(is_str())), | |||
'NotificationARNs': PropertyType(False, list_of(is_str())), |
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 was a bug- the CFN model had an incorrect property name.
# Only run linter on normal/gov partitions. It errors on china regions | ||
if testcase not in LINT_IGNORE_TESTS and partition != 'aws-cn': | ||
matches = runner.run() | ||
print('cfn-lint ({}): {}'.format(expected_filepath, matches)) |
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 section is really what was added, all the rest is updating output files to conform to lint rules.
Reviewers: look at the |
Codecov Report
@@ Coverage Diff @@
## develop #888 +/- ##
========================================
Coverage 94.62% 94.62%
========================================
Files 69 69
Lines 2997 2997
Branches 554 554
========================================
Hits 2836 2836
Misses 85 85
Partials 76 76
Continue to review full report at Codecov.
|
else: # deprecation warning catching in py2 | ||
import warnings | ||
with warnings.catch_warnings(): | ||
warnings.filterwarnings("ignore",category=DeprecationWarning) |
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.
CFN lint throws a DeprecationWarning in python2 here for every cfn node
object created (possibly dozens per template), and Travis truncates the test output due to the sheer volume of warnings generated. This is to make travis (and the tox
command) play nice with these tests and catch the warning.
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.
Travis errors on the output even though the tests pass.
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.
See https://travis-ci.org/awslabs/serverless-application-model/jobs/519380376
"The job exceeded the maximum log length, and has been terminated."
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.
How do we work around this?
if output_value.get("Ref") in deployment_logical_id_dict: | ||
output_value["Ref"] = deployment_logical_id_dict[output_value.get("Ref")] | ||
if output_value.get("Value").get("Ref") in deployment_logical_id_dict: | ||
output_value["Value"]["Ref"] = deployment_logical_id_dict[output_value.get("Value").get("Ref")] |
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.
The code was (incorrectly) trying to parse outputs in the following manner:
Outputs:
MyOutput: !Ref Deployment34567
I updated it (and the tests) to be correct:
Outputs:
MyOutput:
Value: !Ref Deployment34567
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.
Glad this catch a lot of incorrect templates we had!
# Only update the deployment Logical Id hash in Py3. | ||
if sys.version_info.major >= 3: | ||
self._update_logical_id_hash(expected) | ||
self._update_logical_id_hash(output_fragment) | ||
output_template = cfnlint.decode.cfn_json.load(expected_filepath) | ||
else: # deprecation warning catching in py2 | ||
import warnings |
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.
Is it good python style to use import in the middle of the code? Usually those things are at the top of the file I think
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.
Usually they are, but I feel it's fine in this case because we are only using it in py2.
@@ -32,6 +32,12 @@ Resources: | |||
Identity: | |||
Headers: | |||
- Authorization1 | |||
MyAuthFn: |
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.
Where did these new Resources come from?
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.
The new resources are the resources that are referenced in the template but weren't actually in the template. CFN lint does some resource reference resolution to find broken or missing resource references and dependencies. I added in what was necessary to make all of these templates valid.
Description of changes:
Runs CFN lint on the output files of the tests to make sure that they are valid CFN syntax.
Also fixes a parameter in
Serverless::Application
fromNotificationArns
->NotificationARNs
. This was previously broken and was a bug.Description of how you validated changes:
Tests run and pass.
Checklist:
make pr
passesBy submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.