Skip to content
This repository was archived by the owner on Sep 28, 2022. It is now read-only.

Commit dabd130

Browse files
committed
New README and fixes to pipeline.yaml
1 parent 1dc0035 commit dabd130

File tree

2 files changed

+47
-81
lines changed

2 files changed

+47
-81
lines changed

README.md

Lines changed: 44 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -21,50 +21,39 @@ This sample code is made available under a modified MIT license. See the LICENSE
2121

2222
## Requirements
2323

24-
- Python 2.7+
25-
- Docker
26-
- An AWS account
27-
- [AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-install.html)
28-
29-
## Examples
30-
31-
- [Load testing a basic HTTP endpoint](https://github.com/aws-samples/distributed-load-testing-using-aws-fargate/tree/master/examples/http)
32-
- [Load testing an Elasticsearch cluster behind a VPC](https://github.com/aws-samples/distributed-load-testing-using-aws-fargate/tree/master/examples/elasticsearch)
33-
24+
- An AWS Account
25+
- [Git Credentials for AWS CodeCommit](https://docs.aws.amazon.com/codecommit/latest/userguide/setting-up-gc.html)
3426

3527
## Getting Started
3628

3729
### 1. Launch Solution
3830

3931
In this step you will launch the `Master` CloudFormation stack that will create a Fargate Cluster, an ECR Docker registry, an IAM
40-
Execution Role, a Task Definition, a CloudWatch Log Group, a Security Group and a new VPC with Public Subnets.
32+
Execution Role, a Task Definition, a CloudWatch Log Group, a Security Group, a new VPC, a CodeCommit repository, a CodePipeline
33+
and 2 CodeBuild projects with their associated IAM Roles.
4134

4235
Region Name | Region Code | Launch
4336
------|-----|-----
44-
US East (N. Virginia) | us-east-1 | [![Launch in us-east-1](https://camo.githubusercontent.com/210bb3bfeebe0dd2b4db57ef83837273e1a51891/68747470733a2f2f73332e616d617a6f6e6177732e636f6d2f636c6f7564666f726d6174696f6e2d6578616d706c65732f636c6f7564666f726d6174696f6e2d6c61756e63682d737461636b2e706e67)](https://console.aws.amazon.com/cloudformation/home?region=us-east-1#/stacks/new?stackName=WildRydes-Cloud9&templateURL=https://s3-us-west-2.amazonaws.com/load-testing-using-aws-fargate/artifacts/templates/master.yaml)
45-
US East (Ohio) | us-east-2 | [![Launch in us-east-2](https://camo.githubusercontent.com/210bb3bfeebe0dd2b4db57ef83837273e1a51891/68747470733a2f2f73332e616d617a6f6e6177732e636f6d2f636c6f7564666f726d6174696f6e2d6578616d706c65732f636c6f7564666f726d6174696f6e2d6c61756e63682d737461636b2e706e67)](https://console.aws.amazon.com/cloudformation/home?region=us-east-2#/stacks/new?stackName=WildRydes-Cloud9&templateURL=https://s3-us-west-2.amazonaws.com/load-testing-using-aws-fargate/artifacts/templates/master.yaml)
46-
US West (Oregon) | us-west-2 | [![Launch in us-west-2](https://camo.githubusercontent.com/210bb3bfeebe0dd2b4db57ef83837273e1a51891/68747470733a2f2f73332e616d617a6f6e6177732e636f6d2f636c6f7564666f726d6174696f6e2d6578616d706c65732f636c6f7564666f726d6174696f6e2d6c61756e63682d737461636b2e706e67)](https://console.aws.amazon.com/cloudformation/home?region=us-west-2#/stacks/new?stackName=WildRydes-Cloud9&templateURL=https://s3-us-west-2.amazonaws.com/load-testing-using-aws-fargate/artifacts/templates/master.yaml)
47-
48-
You will notice that the CloudFormation stack will expand itself into 2 additional nested stacks: The master stack takes
49-
care of creating global resources like an ECR Registry and the IAM Execution Role. One nested stack takes care of
50-
creating the network (VPC) and the other creates the Fargate cluster.
51-
52-
Once the three stacks have completed deployment, you need to make a note of the Output values in the master stack
53-
(see the following Screenshot) as you will need these values later. Go to the Outputs section of the
54-
master stack and save the DockerRegistryName and DockerRegistryURL values somewhere in your notes.
37+
US East (N. Virginia) | us-east-1 | [![Launch in us-east-1](https://camo.githubusercontent.com/210bb3bfeebe0dd2b4db57ef83837273e1a51891/68747470733a2f2f73332e616d617a6f6e6177732e636f6d2f636c6f7564666f726d6174696f6e2d6578616d706c65732f636c6f7564666f726d6174696f6e2d6c61756e63682d737461636b2e706e67)](https://console.aws.amazon.com/cloudformation/home?region=us-east-1#/stacks/new?stackName=DistributedLoadTesting&templateURL=https://s3-us-west-2.amazonaws.com/load-testing-using-aws-fargate/artifacts/templates/master.yaml)
38+
US East (Ohio) | us-east-2 | [![Launch in us-east-2](https://camo.githubusercontent.com/210bb3bfeebe0dd2b4db57ef83837273e1a51891/68747470733a2f2f73332e616d617a6f6e6177732e636f6d2f636c6f7564666f726d6174696f6e2d6578616d706c65732f636c6f7564666f726d6174696f6e2d6c61756e63682d737461636b2e706e67)](https://console.aws.amazon.com/cloudformation/home?region=us-east-2#/stacks/new?stackName=DistributedLoadTesting&templateURL=https://s3-us-west-2.amazonaws.com/load-testing-using-aws-fargate/artifacts/templates/master.yaml)
39+
US West (Oregon) | us-west-2 | [![Launch in us-west-2](https://camo.githubusercontent.com/210bb3bfeebe0dd2b4db57ef83837273e1a51891/68747470733a2f2f73332e616d617a6f6e6177732e636f6d2f636c6f7564666f726d6174696f6e2d6578616d706c65732f636c6f7564666f726d6174696f6e2d6c61756e63682d737461636b2e706e67)](https://console.aws.amazon.com/cloudformation/home?region=us-west-2#/stacks/new?stackName=DistributedLoadTesting&templateURL=https://s3-us-west-2.amazonaws.com/load-testing-using-aws-fargate/artifacts/templates/master.yaml)
5540

56-
![CloudFormation Screenshot](docs/cfn-outputs.png)
41+
After launching it, notice that the CloudFormation stack expands itself into 3 additional nested stacks: The master stack,
42+
which takes care of creating resources that will be shared across regions like the ECR Registry and the CodePipeline;
43+
The VPC nested stack, which creates the network configuration and subnets; The Fargate nested stack which creates the cluster
44+
and task definition and the Pipeline nested stack that creates the CodeCommit repository and the CodeBuild projects to
45+
build and run the load tests in Fargate.
5746

5847
### 2. Clone this repository
5948

6049
```bash
6150
git clone https://github.com/aws-samples/distributed-load-testing-using-aws-fargate.git
6251
```
6352

64-
Switch to the latest release so you have an stable code base.
53+
Switch to the latest release so you have a stable code base.
6554

6655
```bash
67-
git checkout tags/v0.2-beta
56+
git checkout tags/v1.0-beta
6857
```
6958

7059
### 3. Modify the load test scenario
@@ -83,75 +72,32 @@ scenarios:
8372
aws-website-test:
8473
requests:
8574
- http://aws.amazon.com
86-
```
87-
88-
### 4. Build and push the docker image
89-
90-
Once you have completed your test scenario, you need to package it in a Docker image and push it to your ECR Docker registry.
91-
To do this, you first need to authenticate against ECR. The following command assumes you have the [AWS CLI installed and configured](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-install.html).
92-
93-
```bash
94-
$(aws ecr get-login --no-include-email --region us-west-2)
9575
```
9676
97-
Then, build the Docker image by running the following command from the root directory of this project. Replace
98-
_{DockerRegistryName}_ with the Output value you saved in Step 1.
77+
### 4. Push to CodeCommit
9978
100-
```bash
101-
docker build -t {DockerRegistryName} .
102-
```
79+
One of the resources that got created when deploying this solution is a CodeCommit repository to store this project along
80+
with your load test scenarios. It also created a CodePipeline connected to this repository, such that when you push a
81+
new commit the pipeline will be triggered automatically, build your load test scenarios into a Docker image, push the
82+
image to the ECR registry and then run the tests into the Fargate cluster; all of this automatically!
10383
104-
Tag the image as `:latest`, you can choose another tag name, but for simplicity I'm doing _latest_.
84+
First, remove the current Git origin of the project because you just cloned it from Github.
10585
10686
```bash
107-
docker tag {DockerRegistryName}:latest {DockerRegistryURL}:latest
87+
git remote rm origin
10888
```
10989

110-
Test your docker container locally to verify it runs correctly.
90+
Now, set the origin to be your new CodeCommit repository.
11191

11292
```bash
113-
docker run -it {DockerRegistryName} taurus.yml
93+
git remote add origin {code_commit_repository_url}
11494
```
11595

116-
If the docker container ran as expected, you can proceed to push the image to the registry. Unfortunately the Docker
117-
image for Taurus is quite heavy (~900 MB), so make sure you have good internet connectivity as this push can take a
118-
little while.
96+
Finally, push the project to the repository. Note that after you push this, the deployment pipeline will be triggered
97+
automatically and therefore the load tests will be run on the Fargate cluster.
11998

12099
```bash
121-
docker push {DockerRegistryURL}:latest
122-
```
123-
124-
### 4. Run the tests in Fargate
125-
126-
Finally, edit the `bin/runner.py` python file to add the list of regions with its CloudFormation stack names that
127-
you launched on the previous step. This python file will read the CloudFormation outputs and based on those parameters
128-
will schedule the execution of the Fargate tasks.
129-
130-
Before running the python script, install boto3 by creating a virtual environment. Creating a virtual
131-
environment is optional, but recommended. If you don't have virtualenv installed, you can install it with pip.
132-
133-
```bash
134-
pip install virtualenv
135-
```
136-
137-
Create the virtual environment inside the `bin/` directory and activate it.
138-
139-
```bash
140-
cd bin/
141-
virtualenv env
142-
source env/bin/activate
143-
```
144-
145-
Once inside the virtual environment, install boto3 by running:
146-
147-
```bash
148-
pip install -r requirements.txt
149-
```
150-
151-
And finally, when you are ready to run the Distributed Load Test, run the script.
152-
153-
```bash
154-
python runner.py
100+
git push -u origin master
155101
```
156102

157103
### 5. Monitor the test execution in CloudWatch
@@ -198,4 +144,21 @@ Additional Region | Region Code | Launch
198144
US East (N. Virginia) | us-east-1 | [![Launch in us-east-1](https://camo.githubusercontent.com/210bb3bfeebe0dd2b4db57ef83837273e1a51891/68747470733a2f2f73332e616d617a6f6e6177732e636f6d2f636c6f7564666f726d6174696f6e2d6578616d706c65732f636c6f7564666f726d6174696f6e2d6c61756e63682d737461636b2e706e67)](https://console.aws.amazon.com/cloudformation/home?region=us-east-1#/stacks/new?stackName=WildRydes-Cloud9&templateURL=https://s3-us-west-2.amazonaws.com/load-testing-using-aws-fargate/artifacts/templates/additional-region.yaml)
199145
US East (Ohio) | us-east-2 | [![Launch in us-east-2](https://camo.githubusercontent.com/210bb3bfeebe0dd2b4db57ef83837273e1a51891/68747470733a2f2f73332e616d617a6f6e6177732e636f6d2f636c6f7564666f726d6174696f6e2d6578616d706c65732f636c6f7564666f726d6174696f6e2d6c61756e63682d737461636b2e706e67)](https://console.aws.amazon.com/cloudformation/home?region=us-east-2#/stacks/new?stackName=WildRydes-Cloud9&templateURL=https://s3-us-west-2.amazonaws.com/load-testing-using-aws-fargate/artifacts/templates/additional-region.yaml)
200146
US West (Oregon) | us-west-2 | [![Launch in us-west-2](https://camo.githubusercontent.com/210bb3bfeebe0dd2b4db57ef83837273e1a51891/68747470733a2f2f73332e616d617a6f6e6177732e636f6d2f636c6f7564666f726d6174696f6e2d6578616d706c65732f636c6f7564666f726d6174696f6e2d6c61756e63682d737461636b2e706e67)](https://console.aws.amazon.com/cloudformation/home?region=us-west-2#/stacks/new?stackName=WildRydes-Cloud9&templateURL=https://s3-us-west-2.amazonaws.com/load-testing-using-aws-fargate/artifacts/templates/additional-region.yaml)
201-
147+
148+
149+
## Run Locally
150+
151+
Build the image by issuing the following command in the root directory of this project.
152+
153+
```bash
154+
docker build -t load-tests-using-fargate .
155+
```
156+
157+
Then run the docker container locally.
158+
159+
```bash
160+
docker run -it load-tests-using-fargate taurus.yml
161+
```
162+
163+
If the docker ran as expected, you can push the changes to your AWS CodeCommit repository and let the pipeline
164+
do the rest.

cloudformation/pipeline.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ Resources:
4747
# into the ECR Registry.
4848
CodeBuild:
4949
Type: AWS::CodeBuild::Project
50+
DependsOn: BuildAndPipelinePolicy
5051
Properties:
5152
Description: Builds distributed load testing suite
5253
TimeoutInMinutes: 20
@@ -86,6 +87,7 @@ Resources:
8687
# execution of Fargate tasks into the different regions.
8788
LoadTestRunner:
8889
Type: AWS::CodeBuild::Project
90+
DependsOn: BuildAndPipelinePolicy
8991
Properties:
9092
Description: Runs the load tests in Fargate
9193
ServiceRole: !GetAtt CodeBuildRole.Arn
@@ -117,6 +119,7 @@ Resources:
117119
118120
CodePipeline:
119121
Type: AWS::CodePipeline::Pipeline
122+
DependsOn: BuildAndPipelinePolicy
120123
Properties:
121124
RoleArn: !GetAtt CodePipelineRole.Arn
122125
ArtifactStore:

0 commit comments

Comments
 (0)