8000 Add helper Makefile for more easier integration tests by phobologic · Pull Request #597 · cloudtools/stacker · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
8000

Add helper Makefile for more easier integration tests #597

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

Merged
merged 7 commits into from
Jul 7, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ clean:
rm -rf .egg stacker.egg-info

test-functional:
cd tests && bats .
cd tests && bats test_suite

# General testing target for most development.
test: lint test-unit test-unit3
Expand Down
8 changes: 8 additions & 0 deletions tests/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
permissions:
./stacker.yaml.sh | stacker build -

test: permissions
Copy link
Contributor

Choose a reason for hiding this comment

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

We already have a test-functional target in the top level Makefile. Maybe move this there? https://github.com/remind101/stacker/blob/master/Makefile#L13

Copy link
Member Author

Choose a reason for hiding this comment

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

I saw that after I submitted this - do you think I should include the permissions step and use it as a dependency? @ejholmes

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah

Copy link
Member Author

Choose a reason for hiding this comment

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

Hey @ejholmes we talked about this in person, but I can't remember where we landed. The functional tests that we run in circle don't have permissions to make the permissions for themselves, and that was a security decision I'm pretty sure. Moving what I have here to the tests used in circle would cause it to break, unless you have another idea (or I'm not thinking about this correctly).

What are your thoughts?

$(eval AWS_ACCESS_KEY_ID := $(shell ./stacker.yaml.sh | stacker info - 2>&1 | awk '/AccessKeyId/ {print $$3}'))
$(eval AWS_SECRET_ACCESS_KEY := $(shell ./stacker.yaml.sh | stacker info - 2>&1 | awk '/SecretAccessKey/ {print $$3}'))
$(eval STACKER_ROLE := $(shell ./stacker.yaml.sh | stacker info - 2>&1 | awk '/FunctionalTestRole/ {print $$3}'))
@STACKER_ROLE=$(STACKER_ROLE) AWS_ACCESS_KEY_ID=$(AWS_ACCESS_KEY_ID) AWS_SECRET_ACCESS_KEY=$(AWS_SECRET_ACCESS_KEY) ./run_test_suite.sh ${TESTS}
25 changes: 12 additions & 13 deletions tests/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
This directory contains the functional testing suite for stacker. It exercises all of stacker against a real AWS account.
This directory contains the functional testing suite for stacker. It exercises all of stacker against a real AWS account. Make sure you have the AWS credentials loaded into your environment when you run these steps.

## Setup

Expand All @@ -7,27 +7,26 @@ This directory contains the functional testing suite for stacker. It exercises a
```console
$ source venv/bin/activate
```

2. Set a stacker namespace & the AWS region for the test suite to use:

```console
$ export STACKER_NAMESPACE=my-stacker-test-namespace
$ export AWS_DEFAULT_REGION=us-east-1
```
3. Generate an IAM user for the test suite to use:

```console
$ ./stacker.yaml.sh | stacker build -
```
4. Grab the generated key pair for the user and set it in your shell:
3. Ensure that bats is installed:

```console
$ ./stacker.yaml.sh | stacker info -
$ export AWS_ACCESS_KEY_ID=access-key
$ export AWS_SECRET_ACCESS_KEY=secret-access-key
$ export STACKER_ROLE=<FunctionalTestRole>
# On MacOS if brew is installed
$ brew install bats
```
5. Run the test suite:

4. Setup functional test environment & run tests:

```console
$ brew install bats
$ bats .
# To run all the tests
$ make -C tests test
# To run specific tests (ie: tests 1, 2 and 3)
$ TESTS="1 2 3" make -C tests test
```
17 changes: 17 additions & 0 deletions tests/run_test_suite.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/sh

TEST_ARGS=$*

if [ -z "$TEST_ARGS" ]
then
_TESTS="test_suite"
else
for T in ${TEST_ARGS}
do
_TESTS="${_TESTS} test_suite/$(printf %02d ${T})_*"
done
fi

echo "bats ${_TESTS}"

bats ${_TESTS}
Loading
0