Skip to content

Commit c5d0ed2

Browse files
Release/v1.35.0 (#1962)
* Release/v1.35.0 (#1950) * fix: Change yaml.load to yaml_parse as a best practice (#1951) (#1961) Co-authored-by: mingkun2020 <[email protected]>
1 parent 6da6a5b commit c5d0ed2

File tree

141 files changed

+5634
-110
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

141 files changed

+5634
-110
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
---
2+
name: Bug report
3+
about: Create an issue to report a bug for the SAM Translator
4+
title: ''
5+
labels: ''
6+
assignees: ''
7+
8+
---
9+
10+
<!-- Make sure we don't have an existing Issue that reports the bug you are seeing (both open and closed).
11+
If you do find an existing Issue, re-open or add a comment to that Issue instead of creating a new one. -->
12+
13+
### Description:
14+
<!-- Briefly describe the bug you are facing.-->
15+
16+
17+
18+
### Steps to reproduce:
19+
<!-- Provide detailed steps to replicate the bug, including steps from third party tools (CDK, etc.) -->
20+
21+
22+
23+
### Observed result:
24+
<!-- Please provide command output with `--debug` flag set.-->
25+
26+
27+
28+
### Expected result:
29+
<!-- Describe what you expected.-->
30+
31+
32+
33+
### Additional environment details (Ex: Windows, Mac, Amazon Linux etc)
34+
35+
1. OS:
36+
2. If using SAM CLI, `sam --version`:
37+
3. AWS region:
38+
39+
`Add --debug flag to any SAM CLI commands you are running`
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
---
2+
name: Feature request
3+
about: Suggest an idea/feature/enhancement for the SAM Translator
4+
title: ''
5+
labels: ''
6+
assignees: ''
7+
8+
---
9+
10+
<!-- Make sure we don't have an existing Issue for that feature request (open or closed). -->
11+
12+
### Describe your idea/feature/enhancement
13+
14+
Provide a clear description.
15+
16+
Ex: I wish the SAM Translator would [...]
17+
18+
### Proposal
19+
20+
Add details on how to add this to the product.
21+
22+
Things to consider:
23+
[ ] The [SAM documentation](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-specification.html) will need to be updated
24+
25+
### Additional Details

DEVELOPMENT_GUIDE.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,10 @@ will not work in Python3.6). If you want to test in many versions, you can creat
128128
each version and flip between them (sourcing the activate script). Typically, we run all tests in
129129
one python version locally and then have our ci (appveyor) run all supported versions.
130130

131+
### Integration tests
132+
133+
Integration tests are covered in detail in the [INTEGRATION_TESTS.md file](INTEGRATION_TESTS.md) of this repository.
134+
131135
Code Conventions
132136
----------------
133137

INTEGRATION_TESTS.md

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
# AWS SAM integration tests
2+
3+
These tests run SAM against AWS services by translating SAM templates, deploying them to Cloud Formation and verifying the resulting objects.
4+
5+
They must run successfully under Python 2 and 3.
6+
7+
## Run the tests
8+
9+
### Prerequisites
10+
11+
#### User and rights
12+
13+
An Internet connection and an active AWS account are required to run the tests as they will interact with AWS services (most notably Cloud Formation) to create and update objects (Stacks, APIs, ...).
14+
15+
AWS credentials must be configured either through a [credentials file](https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-files.html) or [environment variables](https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-envvars.html)
16+
17+
The user running the tests must have the following roles:
18+
19+
```
20+
AmazonSQSFullAccess
21+
AmazonSNSFullAccess
22+
AmazonAPIGatewayAdministrator
23+
AWSKeyManagementServiceFullAccess
24+
AWSStepFunctionsFullAccess
25+
```
26+
27+
If you plan on running the full tests suite, ensure that the user credentials you are running the tests with have a timeout of at least 30 minutes as the full suite can take more than 20 minutes to execute.
28+
29+
#### Initialize the development environment
30+
31+
If you haven't done so already, run the following command in a terminal at the root of the repository to initialize the development environment:
32+
33+
```
34+
make init
35+
```
36+
37+
### Running all the tests
38+
39+
From the root of the repository, run:
40+
41+
```
42+
make integ-test
43+
```
44+
45+
### Running a specific test file
46+
47+
From the command line, run:
48+
49+
```
50+
pytest --no-cov path/to/the/test_file.py
51+
```
52+
53+
For example, from the root of the project:
54+
55+
```sh
56+
pytest --no-cov integration/single/test_basic_api.py
57+
```
58+
59+
### Running a specific test
60+
61+
From the command line, run:
62+
63+
```
64+
pytest --no-cov path/to/the/test_file.py::test_class::test_method
65+
```
66+
67+
For example, from the root of the project:
68+
69+
```sh
70+
pytest --no-cov integration/single/test_basic_api.py::TestBasicApi::test_basic_api
71+
```
72+
73+
*We don't measure coverage for integration tests.*
74+
75+
## Write a test
76+
77+
1. Add your test templates to the `integration/resources/templates` single or combination folder.
78+
2. Write an expected json file for all the expected resources and add it to the `integration/resources/expected`.
79+
3. (Optional) Add the resource files (zip, json, etc.) to `integration/resources/code` and update the dictionaries in `integration/helpers/file_resources.py`.
80+
4. Write and add your python test code to the `integration` single or combination folder.
81+
5. Run it!
82+
83+
## Skip tests for a specific service in a region
84+
85+
1. Add the service you want to skip to the `integration/config/region_service_exclusion.yaml` under the region
86+
2. Add the @skipIf decorator to the test with the service name, take 'XRay' for example:
87+
```@skipIf(current_region_does_not_support('XRay'), 'XRay is not supported in this testing region')```
88+
89+
## Directory structure
90+
91+
### Helpers
92+
93+
Common classes and tools used by tests.
94+
95+
```
96+
+-- helpers/
97+
| +-- deployer Tools to deploy to Cloud Formation
98+
| +-- base_test.py Common class from which all test classes inherit
99+
| +-- file_resources.py Files to upload to S3
100+
| +-- resource.py Helper functions to manipulate resources
101+
| +-- template.py Helper functions to translate the template
102+
```
103+
104+
`base_test.py` contains `setUpClass` and `tearDownClass` methods to respectively upload and clean the `file_resources.py` resources (upload the files to a new S3 bucket, empty and delete this bucket).
105+
106+
### Resources
107+
108+
File resources used by tests.
109+
110+
```
111+
+-- resources
112+
| +-- code Files to upload to S3
113+
| +-- expected Files describing the expected created resources
114+
| +-- templates Source SAM templates to translate and deploy
115+
```
116+
117+
The matching *expected* and *template* files should have the same name.
118+
119+
For example, the `test_basic_api` test in the class `tests_integ/single/test_basic_api.py` takes `templates/single/basic_api.yaml` SAM template as input and verifies its result against `expected/single/basic_api.json`.
120+
121+
### Single
122+
123+
Basic tests which interact with only one service should be put here.
124+
125+
### Combination
126+
127+
Tests which interact with multiple services should be put there.
128+
129+
### Tmp
130+
131+
This directory is created on the first run and contains temporary and intermediary files used by the tests: sam templates with substituted variable values, translated temporary cloud formation templates, ...

Makefile

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,16 @@ init:
66
pip install -e '.[dev]'
77

88
test:
9-
pytest --cov samtranslator --cov-report term-missing --cov-fail-under 95 tests
9+
pytest --cov samtranslator --cov-report term-missing --cov-fail-under 95 tests/*
10+
11+
integ-test:
12+
pytest --no-cov integration/*
1013

1114
black:
12-
black setup.py samtranslator/* tests/* bin/*.py
15+
black setup.py samtranslator/* tests/* integration/* bin/*.py
1316

1417
black-check:
15-
black --check setup.py samtranslator/* tests/* bin/*.py
18+
black --check setup.py samtranslator/* tests/* integration/* bin/*.py
1619

1720
# Command to run everytime you make changes to verify everything works
1821
dev: test
@@ -30,6 +33,7 @@ Usage: $ make [TARGETS]
3033
TARGETS
3134
init Initialize and install the requirements and dev-requirements for this project.
3235
test Run the Unit tests.
36+
integ-test Run the Integration tests.
3337
dev Run all development tests after a change.
3438
pr Perform all checks before submitting a Pull Request.
3539

README.md

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,19 @@
33

44
# AWS Serverless Application Model (AWS SAM)
55

6-
![Apache-2.0](https://img.shields.io/github/license/awslabs/serverless-application-model.svg)
7-
![SAM_CLI release](https://img.shields.io/github/release/awslabs/aws-sam-cli.svg?label=CLI%20Version)
6+
![Apache-2.0](https://img.shields.io/github/license/aws/serverless-application-model.svg)
7+
![SAM_CLI release](https://img.shields.io/github/release/aws/aws-sam-cli.svg?label=CLI%20Version)
8+
[![codecov](https://codecov.io/gh/aws/serverless-application-model/branch/master/graphs/badge.svg?style=flat)](https://codecov.io/gh/aws/serverless-application-model)
89

9-
The AWS Serverless Application Model (SAM) is an open-source framework for building serverless applications.
10-
It provides shorthand syntax to express functions, APIs, databases, and event source mappings.
10+
The AWS Serverless Application Model (SAM) is an open-source framework for building serverless applications.
11+
It provides shorthand syntax to express functions, APIs, databases, and event source mappings.
1112
With just a few lines of configuration, you can define the application you want and model it.
1213

1314
[![Getting Started with AWS SAM](./docs/get-started-youtube.png)](https://www.youtube.com/watch?v=1dzihtC5LJ0)
1415

1516
## Get Started
1617

17-
To get started with building SAM-based applications, use the SAM CLI. SAM CLI provides a Lambda-like execution
18+
To get started with building SAM-based applications, use the SAM CLI. SAM CLI provides a Lambda-like execution
1819
environment that lets you locally build, test, debug, and deploy applications defined by SAM templates.
1920

2021
* [Install SAM CLI](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-install.html)
@@ -35,14 +36,14 @@ environment that lets you locally build, test, debug, and deploy applications de
3536
## Why SAM
3637

3738
+ **Single\-deployment configuration**\. SAM makes it easy to organize related components and resources, and operate on a single stack\. You can use SAM to share configuration \(such as memory and timeouts\) between resources, and deploy all related resources together as a single, versioned entity\.
38-
39+
3940
+ **Local debugging and testing**\. Use SAM CLI to locally build, test, and debug SAM applications on a Lambda-like execution environment. It tightens the development loop by helping you find & troubleshoot issues locally that you might otherwise identify only after deploying to the cloud.
4041

4142
+ **Deep integration with development tools**. You can use SAM with a suite of tools you love and use.
4243
+ IDEs: [PyCharm](https://aws.amazon.com/pycharm/), [IntelliJ](https://aws.amazon.com/intellij/), [Visual Studio Code](https://aws.amazon.com/visualstudiocode/), [Visual Studio](https://aws.amazon.com/visualstudio/), [AWS Cloud9](https://aws.amazon.com/cloud9/)
4344
+ Build: [CodeBuild](https://docs.aws.amazon.com/codebuild/latest/userguide/)
4445
+ Deploy: [CodeDeploy](https://docs.aws.amazon.com/codedeploy/latest/userguide/), [Jenkins](https://wiki.jenkins.io/display/JENKINS/AWS+SAM+Plugin)
45-
+ Continuous Delivery Pipelines: [CodePipeline](https://docs.aws.amazon.com/codepipeline/latest/userguide/)
46+
+ Continuous Delivery Pipelines: [CodePipeline](https://docs.aws.amazon.com/codepipeline/latest/userguide/)
4647
+ Discover Serverless Apps & Patterns: [AWS Serverless Application Repository](https://docs.aws.amazon.com/serverlessrepo/latest/devguide/)
4748

4849
+ **Built\-in best practices**\. You can use SAM to define and deploy your infrastructure as configuration. This makes it possible for you to use and enforce best practices through code reviews. Also, with a few lines of configuration, you can enable safe deployments through CodeDeploy, and can enable tracing using AWS X\-Ray\.
@@ -51,40 +52,40 @@ environment that lets you locally build, test, debug, and deploy applications de
5152

5253
## What is this Github repository? 💻
5354

54-
This GitHub repository contains the SAM Specification, the Python code that translates SAM templates into AWS CloudFormation stacks and lots of examples applications.
55+
This GitHub repository contains the SAM Specification, the Python code that translates SAM templates into AWS CloudFormation stacks and lots of examples applications.
5556
In the words of SAM developers:
5657

57-
> SAM Translator is the Python code that deploys SAM templates via AWS CloudFormation. Source code is high quality (95% unit test coverage),
58-
with tons of tests to ensure your changes don't break compatibility. Change the code, run the tests, and if they pass, you should be good to go!
58+
> SAM Translator is the Python code that deploys SAM templates via AWS CloudFormation. Source code is high quality (95% unit test coverage),
59+
with tons of tests to ensure your changes don't break compatibility. Change the code, run the tests, and if they pass, you should be good to go!
5960
Clone it and run `make pr`!
6061

6162
## Contribute to SAM
6263

63-
We love our contributors ❤️ We have over 100 contributors who have built various parts of the product.
64+
We love our contributors ❤️ We have over 100 contributors who have built various parts of the product.
6465
Read this [testimonial from @ndobryanskyy](https://www.lohika.com/aws-sam-my-exciting-first-open-source-experience/) to learn
65-
more about what it was like contributing to SAM.
66+
more about what it was like contributing to SAM.
6667

67-
Depending on your interest and skill, you can help build the different parts of the SAM project;
68+
Depending on your interest and skill, you can help build the different parts of the SAM project;
6869

6970
**Enhance the SAM Specification**
7071

7172
Make pull requests, report bugs, and share ideas to improve the full SAM template specification.
72-
Source code is located on Github at [awslabs/serverless-application-model](https://github.com/awslabs/serverless-application-model).
73+
Source code is located on Github at [awslabs/serverless-application-model](https://github.com/awslabs/serverless-application-model).
7374
Read the [SAM Specification Contributing Guide](https://github.com/awslabs/serverless-application-model/blob/master/CONTRIBUTING.md)
7475
to get started.
75-
76+
7677
**Strengthen SAM CLI**
7778

7879
Add new commands or enhance existing ones, report bugs, or request new features for the SAM CLI.
79-
Source code is located on Github at [awslabs/aws-sam-cli](https://github.com/awslabs/aws-sam-cli). Read the [SAM CLI Contributing Guide](https://github.com/awslabs/aws-sam-cli/blob/develop/CONTRIBUTING.md) to
80-
get started.
80+
Source code is located on Github at [awslabs/aws-sam-cli](https://github.com/awslabs/aws-sam-cli). Read the [SAM CLI Contributing Guide](https://github.com/awslabs/aws-sam-cli/blob/develop/CONTRIBUTING.md) to
81+
get started.
8182

8283
**Update SAM Developer Guide**
8384

8485
[SAM Developer Guide](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/index.html) provides comprehensive getting started guide and reference documentation.
8586
Source code is located on Github at [awsdocs/aws-sam-developer-guide](https://github.com/awsdocs/aws-sam-developer-guide).
8687
Read the [SAM Documentation Contribution Guide](https://github.com/awsdocs/aws-sam-developer-guide/blob/master/CONTRIBUTING.md) to get
87-
started.
88+
started.
8889

8990
### Join the SAM Community on Slack
9091
[Join the SAM developers channel (#samdev)](https://join.slack.com/t/awsdevelopers/shared_invite/zt-idww18e8-Z1kXhI7GNuDewkweCF3YjA) on Slack to collaborate with fellow community members and the AWS SAM team.

appveyor-integration-test.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
version: 1.0.{build}
2+
image: Ubuntu
3+
4+
environment:
5+
matrix:
6+
- TOXENV: py27
7+
PYTHON_VERSION: '2.7'
8+
- TOXENV: py36
9+
PYTHON_VERSION: '3.6'
10+
- TOXENV: py37
11+
PYTHON_VERSION: '3.7'
12+
- TOXENV: py38
13+
PYTHON_VERSION: '3.8'
14+
15+
build: off
16+
17+
install:
18+
- sh: "source ${HOME}/venv${PYTHON_VERSION}/bin/activate"
19+
- sh: "python --version"
20+
- make init
21+
22+
test_script:
23+
- make integ-test
24+

integration/__init__.py

Whitespace-only changes.

integration/config/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)