Skip to content

improv: include example tests in make tests - #63

Merged
heitorlessa merged 6 commits into
developfrom
chore/run_example_tests
Jun 7, 2020
Merged

improv: include example tests in make tests#63
heitorlessa merged 6 commits into
developfrom
chore/run_example_tests

Conversation

@to-mc

@to-mcto-mc commented Jun 7, 2020

Copy link
Copy Markdown
Contributor

Issue #, if available:

Description of changes:

Update pytest config to run example tests. Update tests in example/tests to specify env vars as fixture without requiring user to pass them at runtime.

Breaking change checklist

Ignore if it's not a breaking change

RFC issue #:

  • Migration process documented
  • Implement warnings (if it can live side by side)

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

@codecov-commenter

codecov-commenter commented Jun 7, 2020

Copy link
Copy Markdown

Codecov Report

Merging #63 into develop will increase coverage by 0.60%.
The diff coverage is n/a.

Impacted file tree graph

@@ Coverage Diff @@## develop #63 +/- ##
============================================
+ Coverage 99.39% 100.00% +0.60% 
============================================
Files 15 15 Lines 496 496 Branches 45 45 ============================================
+ Hits 493 496 +3 + Misses 3 0 -3 
Impacted FilesCoverage Δ
aws_lambda_powertools/tracing/extensions.py100.00% <0.00%> (+75.00%)⬆️

Continue to review full report at Codecov.

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

@to-mc
to-mc marked this pull request as draft June 7, 2020 13:14
@to-mc
to-mc marked this pull request as ready for review June 7, 2020 13:23
@to-mc
to-mc requested a review from heitorlessaJune 7, 2020 13:53
@heitorlessa

Copy link
Copy Markdown
Contributor

Two quick questions as everything else look great.

  1. For those trying to test/deploy the example directly, do we need to update the README given these changes?

  2. Could you add the POWERTOOLS_METRICS_NAMESPACE env in SAM back?

I've run through all steps after checking out this PR and am hitting the namespace issue (template.yaml)


sam local invoke HelloWorldFunction --event events/event.json
2020-06-0714:19:16,866aws_lambda_powertools.metrics.base [DEBUG] Serializing...
2020-06-0714:19:16,866aws_lambda_powertools.metrics.base [DEBUG] ValidatingserializedmetricsagainstCloudWatchEMFschema
[ERROR] SchemaValidationError: Invalidformat. Error: data._aws.CloudWatchMetrics[0].Namespacemustbestring, Invaliditem: data._aws.CloudWatchMetrics[0].NamespaceTraceback (mostrecentcalllast):
File"/var/task/aws_lambda_powertools/metrics/metrics.py", line110, indecoratemetrics=self.serialize_metric_set()
File"/var/task/aws_lambda_powertools/metrics/base.py", line186, inserialize_metric_setraiseSchemaValidationError(message)

@heitorlessaheitorlessa left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Need to re-add POWERTOOLS_METRICS_NAMESPACE back to SAM template as it fails when it runs locally

@to-mc

to-mc commented Jun 7, 2020

Copy link
Copy Markdown
ContributorAuthor

Need to re-add POWERTOOLS_METRICS_NAMESPACE back to SAM template as it fails when it runs locally

I added this env var back in PR #62. I just merged develop into this branch so you should see it now.

@to-mc

to-mc commented Jun 7, 2020

Copy link
Copy Markdown
ContributorAuthor

Two quick questions as everything else look great.

  1. For those trying to test/deploy the example directly, do we need to update the README given these changes?
  2. Could you add the POWERTOOLS_METRICS_NAMESPACE env in SAM back?

I've run through all steps after checking out this PR and am hitting the namespace issue (template.yaml)

sam local invoke HelloWorldFunction --event events/event.json
2020-06-0714:19:16,866aws_lambda_powertools.metrics.base [DEBUG] Serializing...
2020-06-0714:19:16,866aws_lambda_powertools.metrics.base [DEBUG] ValidatingserializedmetricsagainstCloudWatchEMFschema
[ERROR] SchemaValidationError: Invalidformat. Error: data._aws.CloudWatchMetrics[0].Namespacemustbestring, Invaliditem: data._aws.CloudWatchMetrics[0].NamespaceTraceback (mostrecentcalllast):
File"/var/task/aws_lambda_powertools/metrics/metrics.py", line110, indecoratemetrics=self.serialize_metric_set()
File"/var/task/aws_lambda_powertools/metrics/base.py", line186, inserialize_metric_setraiseSchemaValidationError(message)

README is updated already - please let me know if the steps don't work for you.

@heitorlessa

Copy link
Copy Markdown
Contributor

Just pulled, and it's all working now ;) Merging!

@heitorlessaheitorlessa changed the title chore: include example tests in make testsimprov: include example tests in make testsJun 7, 2020
@heitorlessa
heitorlessa merged commit 993e8e5 into developJun 7, 2020
@heitorlessa
heitorlessa deleted the chore/run_example_tests branch June 7, 2020 15:06
heitorlessa added a commit that referenced this pull request Jun 7, 2020
* develop:
improv: include example tests in `make tests` (#63)
chore: rename Makefile target docs-dev to docs-local (#65)
improv: better namespace/dimension handling for Metrics (#62)
heitorlessa added a commit that referenced this pull request Jun 10, 2020
* develop: (31 commits)
docs: fix contrast on highlighted code text (#73)
feat: improve error handling for log_metrics decorator (#71)
chore(deps): bump graphql-playground-html from 1.6.19 to 1.6.25 in /docs
feat: add high level imports (#70)
fix: correct env var name for publish to pypi test (#69)
chore: version bump (#68)
feat: add capture_cold_start_metric for log_metrics (#67)
chore(deps): bump websocket-extensions from 0.1.3 to 0.1.4 in /docs (#66)
feat: automate publishing to pypi (#58)
feat: add pre-commit hooks (#64)
improv: include example tests in `make tests` (#63)
chore: rename Makefile target docs-dev to docs-local (#65)
improv: better namespace/dimension handling for Metrics (#62)
docs: build on master only
chore: correct docstring for log_metrics
chore: fix typo in metrics doc
chore: Correct test comment
chore: remove unused import
chore: formatting
feat: update Metrics interface to resemble tracer & logger: use "service" as its namespace.
...
heitorlessa referenced this pull request in heitorlessa/aws-lambda-powertools-python Jun 17, 2020
* chore: add example/tests to test paths
* chore: update example tests to remove requirement to manually specify env vars
* chore: try to fix build for python3.6 (install dataclasses backport)
* chore: fix build for python 3.6
* chore: dont run example test on python3.6 since it requires asyncio
Sign up for freeto 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.

3 participants

@to-mc@codecov-commenter@heitorlessa