Browse the Repo

file-type-icon.circleci
file-type-icon.github
file-type-icon.patcher
file-type-icon_docs
file-type-iconexamples
file-type-iconmodules
file-type-icontest
file-type-iconcommon
file-type-iconec2
file-type-iconfargate
file-type-iconscript_tests
file-type-iconupgrades
file-type-iconvalidation
file-type-iconREADME.md
file-type-icongo.mod
file-type-icongo.sum
file-type-icon.gitignore
file-type-icon.pre-commit-config.yaml
file-type-iconCODEOWNERS
file-type-iconLICENSE.txt
file-type-iconREADME.adoc
file-type-iconcore-concepts.md
file-type-iconsetup.cfg
file-type-iconterraform-cloud-enterprise-private-module-...

Browse the Repo

file-type-icon.circleci
file-type-icon.github
file-type-icon.patcher
file-type-icon_docs
file-type-iconexamples
file-type-iconmodules
file-type-icontest
file-type-iconcommon
file-type-iconec2
file-type-iconfargate
file-type-iconscript_tests
file-type-iconupgrades
file-type-iconvalidation
file-type-iconREADME.md
file-type-icongo.mod
file-type-icongo.sum
file-type-icon.gitignore
file-type-icon.pre-commit-config.yaml
file-type-iconCODEOWNERS
file-type-iconLICENSE.txt
file-type-iconREADME.adoc
file-type-iconcore-concepts.md
file-type-iconsetup.cfg
file-type-iconterraform-cloud-enterprise-private-module-...
EC2 Container Service (ECS) Cluster

EC2 Container Service (ECS) Cluster

Deploy a cluster of servers for use with EC2 Container Service (ECS), Amazon's container orchestration system

Code Preview

Preview the Code

mobile file icon

README.md

down

Testing ECS Modules

This folder contains the tests for the modules in this repo.

Special Considerations

Resource Consumption: Many of these tests create real resources in an AWS account. That means they cost money to run, especially if you don't clean up after yourself. Please be considerate of the resources you create and take extra care to clean everything up when you're done!

Prematurely Ending Tests: Never hit CTRL + C or cancel a build once tests are running or the cleanup tasks won't run!

Default Test Timeout: We set -timeout 45m on all tests not because they necessarily take 45 minutes, but because Go has a default test timeout of 10 minutes, after which it does a SIGQUIT, preventing the tests from properly cleaning up after themselves. Therefore, we set a timeout of 45 minutes to make sure all tests have enough time to finish and cleanup.

Prerequisites

  • Install the latest version of Go.
  • Install Terraform.
  • Add your AWS credentials as environment variables: AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY
  • For some tests, you also need to set the GITHUB_OAUTH_TOKEN environment variable to a valid GitHub auth token with "repo" access. You can generate one here
  • Install Python (minimum version 3.5) and pip.

Overview of the test folders

This repo groups tests into these four folders:

  • EC2 Tests: contains all the tests related to EC2-backed ECS clusters.
  • Fargate Tests: contains all the tests related to ECS Fargate.
  • Validation Tests: contains the tests for running terraform validate on all the modules.
  • Script Tests: contains the tests for Python scripts.

Run the tests in each folder

The tests can only be run per folder, not all together.

To run the tests in the ec2, fargate, and validation folders, change directory to that folder, and run the go test command.

For example, to run all the EC2 tests, run:

cd test/ec2
go test -v -timeout 45m -parallel 128

To run the tests in the script_tests folder, the command is different. Change directory to the script_tests folder, and install the required dependencies with pip3. Then run the executor.sh script.

cd test/script_tests
pip3 install requirements.txt
./executor.sh

Run a specific test

To run a specific test, look up the test name and pass it into the -run option. For example, to run the EC2 test called TestDockerServiceWithVPCAlbContainer, you need to prepend the test group name.

cd test/ec2
go test -v -timeout 45m -parallel 128 -run TestDockerEC2Service/group/TestDockerServiceWithVPCAlbContainer

The Fargate tests are not grouped in this way, so you only need the test name. For example, to run the test called TestDockerFargateServiceWithAlb, do:

cd test/fargate
go test -v -timeout 45m -parallel 128 -run TestDockerFargateServiceWithAlb

Questions? Ask away.

We're here to talk about our services, answer any questions, give advice, or just to chat.

Ready to hand off the Gruntwork?