|
1 |
| -Terraform vs LocalStack |
2 |
| -======================= |
3 |
| - |
4 |
| -This repository contains scripts and CI configurations to to run the Terraform Acceptance test suite of the AWS provider against LocalStack |
5 |
| - |
6 |
| -## Utilities |
7 |
| - |
8 |
| -Some utilities for local development: |
9 |
| - |
10 |
| -* `bin/list-tests [--all]`: list the available tests by parsing the go test files. |
11 |
| -* `bin/install-aws-test` creates the binary for running the test suite (and installs it into `$HOME/.cache/localstack/aws.test`. requires go 1.16 |
12 |
| -* `bin/run-tests [test]` run a specific test. this installs and runs localstack in a background process. add the flag `-t` to test against an already running localstack instance. |
13 |
| - |
14 |
| -## Finding and running tests |
15 |
| - |
16 |
| -After running `bin/install-aws-test`, use `bin/run-tests [OPTIONS...] [TESTS...]` to run individual tests or entire test suites. |
17 |
| - |
18 |
| -Here are some examples: |
19 |
| - |
20 |
| -* `bin/run-tests TestAccAWSAPIGatewayResource` |
21 |
| -* `bin/run-tests -t TestAccAWSAPIGatewayResource`: same as above, but does not start localstack |
22 |
| -* `bin/run-tests TestAccAWSAPIGateway`: runs all tests that match `TestAccAWSAPIGateway` (run `bin/list-tests TestAccAWSAPIGateway` to see which ones will be executed) |
23 |
| -* `bin/run-tests -e TestAccAWSAPIGatewayV2 TestAccAWSAPIGateway`: same as above, but excludes all tests that match `TestAccAWSAPIGatewayV2`. |
24 |
| -* `bin/run-tests -i localstack-tests.incl.txt`: runs all tests listed in the text file |
25 |
| - |
26 |
| -You can use `bin/list-tests` with the same parameters to see which tests will be executed, |
27 |
| -or to find specific tests based on patterns. |
28 |
| - |
29 |
| -For example: |
30 |
| - |
31 |
| -``` |
32 |
| - % bin/list-tests Queue |
33 |
| -TestAccAWSBatchJobQueue |
34 |
| -TestAccAWSGameliftGameSessionQueue |
35 |
| -TestAccAWSMediaConvertQueue |
36 |
| -TestAccAWSSQSQueue |
37 |
| -TestAccAWSSQSQueuePolicy |
38 |
| -TestAccDataSourceAwsBatchJobQueue |
39 |
| -TestAccDataSourceAwsSqsQueue |
40 |
| -``` |
41 |
| - |
42 |
| -or |
43 |
| - |
44 |
| -``` |
45 |
| - % bin/list-tests "Data.*Queue" |
46 |
| -TestAccDataSourceAwsBatchJobQueue |
47 |
| -TestAccDataSourceAwsSqsQueue |
48 |
| -``` |
49 |
| - |
50 |
| -## Generating the test reports |
51 |
| - |
52 |
| -Test logs are aggregated into `build/tests/*.log`, the command `bin/create-report` will create junit-like xml reports. |
53 |
| -These can then be rendered into html using `bin/create-report-html`, which also creates a summary page in `build/report.html`. |
54 |
| -For rendering html, you need `junit2html`. |
55 |
| - |
56 |
| -## Travis config |
57 |
| - |
58 |
| -### Build cache |
59 |
| - |
60 |
| -The Travis-CI worker caches the built `aws.test` binary across builds. |
61 |
| -The first build may therefore take a while. |
| 1 | +# Localstack Terraform Test Runner |
| 2 | + |
| 3 | +This is a test runner for localstack and terraform. It will run a test cases from the hashicrop [terraform provider aws](https://github.com/hashicorp/terraform-provider-aws.git) against Localstack Instance. |
| 4 | + |
| 5 | +Purpose of this project is to externalize the test cases from the localstack repo and run them against localstack to gather parity metrics. |
| 6 | + |
| 7 | +## Installation |
| 8 | +1. Clone the repository with submodules |
| 9 | + - `git clone [email protected]:localstack/localstack-terraform-test.git --recurse-submodules` |
| 10 | + - Make sure you have the latest version of the submodules after switching to a different branch using `git submodule update --init --recursive` |
| 11 | +2. Run `make venv` to create a virtual environment |
| 12 | +3. Run `make install` to install the dependencies |
| 13 | + |
| 14 | +## How to run? |
| 15 | +1. Run `python -m terraform_pytest.main patch` to apply the patch to the terraform provider aws |
| 16 | + - **Note: This operation is not idempotent. Please apply the patch only once.** |
| 17 | +2. Run `python -m terraform_pytest.main build -s s3` to build testing binary for the golang module |
| 18 | +3. Now you are ready to use `python -m pytest` commands to list and run test cases from golang |
| 19 | + |
| 20 | +## How to run test cases? |
| 21 | +- To list down all the test case from a specific service, run `python -m pytest terraform-provider-aws/internal/service/<service> --collect-only -q` |
| 22 | +- To run a specific test case, run `python -m pytest terraform-provider-aws/internal/service/<service>/<test-file> -k <test-case-name> --ls-start` or `python -m pytest terraform-provider-aws/internal/service/<service>/<test-file>::<test-case-name> --ls-start` |
| 23 | +- Additional environment variables can be added by appending it in the start of the command, i.e. `AWS_ALTERNATE_REGION='us-west-2' python -m pytest terraform-provider-aws/internal/service/<service>/<test-file>::<test-case-name> --ls-start` |
| 24 | + |
| 25 | +## Default environment variables for Terraform Tests |
| 26 | +- **TF_ACC**: `1` |
| 27 | +- **AWS_ACCESS_KEY_ID**: `test` |
| 28 | +- **AWS_SECRET_ACCESS_KEY**: `test` |
| 29 | +- **AWS_DEFAULT_REGION**: `us-west-1` |
| 30 | +- **AWS_ALTERNATE_ACCESS_KEY_ID**: `test` |
| 31 | +- **AWS_ALTERNATE_SECRET_ACCESS_KEY**: `test` |
| 32 | +- **AWS_ALTERNATE_SECRET_ACCESS_KEY**: `test` |
| 33 | +- **AWS_ALTERNATE_REGION**: `us-east-2` |
| 34 | +- **AWS_THIRD_REGION**: `eu-west-1` |
| 35 | + |
| 36 | +## Environment variables for Localstack |
| 37 | +- **DEBUG**: `1` |
| 38 | +- **PROVIDER_OVERRIDE_S3**: `asf` |
| 39 | +- **FAIL_FAST**: `1` |
| 40 | + |
| 41 | +## Options |
| 42 | +- `--ls-start`: Start localstack instance before running the test cases |
| 43 | +- `--ls-image`: Specify the localstack image to use, default is `localstack/localstack:latest` |
0 commit comments