Skip to content

Commit 068cfbb

Browse files
committed
FIx for feature-18
1 parent df484cb commit 068cfbb

File tree

6 files changed

+39
-56
lines changed

6 files changed

+39
-56
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
.vscode
2-
logs
2+
logs/
33
*.jmx
4+
test/
5+
*.xcworkspace/

README.md

Lines changed: 9 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ docker run -v <oath to jmx>:/plans -v <path to pem>:/keys -v <path to logs>:/log
2828
--env AWS_SECRET_ACCESS_KEY=<access key> \
2929
--env AWS_DEFAULT_REGION=<region> \
3030
--env SECURITY_GROUP=<security group within your VPC> \
31-
--env SUBNET_ID=<subnet ID within your VPC> \
31+
--env SUBNET_ID=<subnet IDs within your VPC> \
3232
--env KEY_NAME=<key pair name without extension> \
3333
--env MINION_COUNT=<number of minions> \
3434
smithmicro/lucy /plans/demo.jmx
@@ -40,7 +40,7 @@ docker run -v $PWD/plans:/plans -v $PWD/keys:/keys -v $PWD/logs:/logs \
4040
--env AWS_SECRET_ACCESS_KEY=abcdefghijklmnopqrstuvwxyz0123456789ABCDEF \
4141
--env AWS_DEFAULT_REGION=us-east-1 \
4242
--env SECURITY_GROUP=sg-12345678 \
43-
--env SUBNET_ID=subnet-12345678 \
43+
--env SUBNET_ID=subnet-12345678,subnet-87654321 \
4444
--env KEY_NAME=jmeter-key \
4545
--env MINION_COUNT=5 \
4646
smithmicro/lucy /plans/demo.jmx
@@ -89,45 +89,12 @@ The `lucy` container uses 3 volumes:
8989
* `/keys` - mapped into the orchestrator to provide the PEM file
9090
* `/logs` - mapped into the orchestrator to provide the output jmeter.log and results.jtl
9191

92-
## Local Testing with Docker Compose
93-
The `jmeter/docker-compose.yml` file allows for local testing of the Gru and Minion nodes without incurring costs from AWS.
94-
Edit the docker-compose.yml file and replicate the `links`, `environment` and `minionN` sections to increase the number of Minions to test.
95-
```
96-
version: '2'
97-
98-
services:
99-
gru:
100-
...
101-
links:
102-
- minion1
103-
- minion2
104-
- minion3
105-
- minion4
106-
environment:
107-
- MINION_HOSTS=minion1,minion2,minion3,minion4
108-
...
109-
minion1:
110-
image: smithmicro/jmeter:latest
111-
minion2:
112-
image: smithmicro/jmeter:latest
113-
minion3:
114-
image: smithmicro/jmeter:latest
115-
minion4:
116-
image: smithmicro/jmeter:latest
117-
118-
```
119-
Then run:
120-
```
121-
docker-compose up
122-
```
123-
Using the `docker-compose scale` command does not work as it creates hostnames like `minion_1`. This causes an error in JMeter as it uses the hostname in URL form and sees the underscore as an illegal URL character.
124-
12592
## Environment Variables
12693
The following required and optional environment variables are supported:
12794

12895
| Variable | Required | Default | Notes |
12996
|---|---|---|---|
130-
|AWS_DEFAULT_REGION|Yes|None|AWS Region (e.g. us-east-1)|
97+
|AWS_DEFAULT_REGION|Yes|None|AWS Region (e.g. `us-east-1`)|
13198
|AWS_ACCESS_KEY_ID|Yes|None|AWS Access Key|
13299
|AWS_SECRET_ACCESS_KEY|Yes|None|AWS Secret Key|
133100
|INPUT_JMX|Yes|None|File path of JMeter Test file to run (.jmx). You can optionally specify this as the first command line option of `docker run`|
@@ -136,24 +103,20 @@ The following required and optional environment variables are supported:
136103
|SUBNET_ID|Yes|None|One or more Subnets (comma separated) that are assigned to your VPC|
137104
|VPC_ID||VPC assigned to SUBNET_ID|We dautomatically erive this from your SUBNET_ID|
138105
|JMETER_VERSION||latest|smithmicro/lucy Image tag. See Docker Hub for [available versions](https://hub.docker.com/r/smithmicro/jmeter/tags/).|
139-
|INSTANCE_TYPE||t2.micro|To double your memory, pass t2.small|
140-
|MEM_LIMIT||950m|If you are using t2.small, set MEM_LIMIT to 1995m|
106+
|INSTANCE_TYPE||t2.micro|To double your memory, pass `t2.small`|
107+
|MEM_LIMIT||950m|If you are using t2.small, set MEM_LIMIT to `1995m`|
141108
|MINION_COUNT||2||
142109
|PEM_PATH||/keys|This must match your Volume map. See Volume section above.|
143110
|CLUSTER_NAME||JMeter|Name that appears in your AWS Cluster UI|
144-
|GRU_PRIVATE_IP||(blank)|Set to true if you would like to run Lucy within AWS. See GitHub [Issue 8](https://github.com/smithmicro/jmeter-ecs/issues/8) for details.|
111+
|GRU_PRIVATE_IP||None|Set to `true` if you would like to run Lucy within AWS. See GitHub [Issue 8](https://github.com/smithmicro/jmeter-ecs/issues/8) for details.|
112+
|JMETER_FLAGS||None|Custom JMeter command line options. For example, passing `-X` will tell the Minion to exit at the end of the test|
113+
|RETAIN_CLUSTER||None|Set to `true` if you want to re-use your cluster for future tests. Warning, you will incur AWS charges if you leave your cluster running.|
145114

146115
## Notes
147-
This Docker image uses the Instance Metadata API documented here:
148-
* http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-instance-metadata.html
149-
150-
To get the instance public hostname within the `entrypoint.sh` script, we call:
151-
* `curl -s --max-time 5 http://169.254.169.254/latest/meta-data/public-hostname`
152-
153116
For more information on JMeter Distributed Testing, see:
154117
* http://jmeter.apache.org/usermanual/remote-test.html
155118

156119
## Inspired by...
157120
https://en.wikipedia.org/wiki/Despicable_Me_2
158121

159-
![Minions](https://pbs.twimg.com/tweet_video_thumb/C8CtmUbVwAAaboL.jpg "Minions")
122+
![Minions](https://pbs.twimg.com/tweet_video_thumb/C8CtmUbVwAAaboL.jpg "Minions")

jmeter/docker-compose.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
version: '2'
22

3+
# This compose file allows for local testing of the Gru and Minion nodes without incurring
4+
# costs from AWS. Edit the docker-compose.yml file and replicate the links, environment
5+
# and minionN sections to increase the number of Minions to test.
6+
37
services:
48
gru:
59
build: .

lucy/Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM alpine:3.5
1+
FROM alpine:3.7
22

33
LABEL maintainer="David Sperling <[email protected]>"
44

@@ -9,6 +9,7 @@ ENV JMETER_FLAGS=
99
ENV AWS_ACCESS_KEY_ID=
1010
ENV AWS_SECRET_ACCESS_KEY=
1111
ENV AWS_DEFAULT_REGION=
12+
ENV RETAIN_CLUSTER=
1213

1314
# Install the AWS CLI
1415
RUN apk add --update --no-cache \

lucy/docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ services:
1212
# example values
1313
- KEY_NAME=123
1414
- SECURITY_GROUP=sg-12345678
15-
- SUBNET_ID=subnet-12345678
15+
- SUBNET_ID=subnet-12345678,subnet-87654321
1616
- AWS_DEFAULT_REGION=us-west-2
1717
- AWS_ACCESS_KEY_ID=123
1818
- AWS_SECRET_ACCESS_KEY=123

lucy/lucy.sh

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,20 @@ fi
7171

7272
# Step 1 - Create our ECS Cluster with MINION_COUNT+1 instances
7373
ecs-cli --version
74-
echo "Creating cluster/$CLUSTER_NAME"
74+
echo "Detecting existing cluster/$CLUSTER_NAME"
7575
INSTANCE_COUNT=$((MINION_COUNT+1))
76-
ecs-cli up --cluster $CLUSTER_NAME --size $INSTANCE_COUNT --capability-iam --instance-type $INSTANCE_TYPE --keypair $KEY_NAME \
77-
--security-group $SECURITY_GROUP --vpc $VPC_ID --subnets $SUBNET_ID --force --verbose
76+
CONTAINER_INSTANCE_COUNT=$(aws ecs describe-clusters --cluster $CLUSTER_NAME \
77+
--query 'clusters[*].[registeredContainerInstancesCount]' --output text)
78+
if [ "$CONTAINER_INSTANCE_COUNT" == $INSTANCE_COUNT ]; then
79+
echo "Using existing cluster/$CLUSTER_NAME"
80+
else
81+
if [ "$CONTAINER_INSTANCE_COUNT" != '0' ]; then
82+
echo "Instance count is $CONTAINER_INSTANCE_COUNT, but requested instance count is $INSTANCE_COUNT"
83+
fi
84+
echo "Creating cluster/$CLUSTER_NAME"
85+
ecs-cli up --cluster $CLUSTER_NAME --size $INSTANCE_COUNT --capability-iam --instance-type $INSTANCE_TYPE --keypair $KEY_NAME \
86+
--security-group $SECURITY_GROUP --vpc $VPC_ID --subnets $SUBNET_ID --force --verbose
87+
fi
7888

7989
# Step 2 - Wait for the cluster to have all container instances registered
8090
while true; do
@@ -107,7 +117,7 @@ MINION_INSTANCE_IDS=$(aws ecs describe-container-instances --cluster $CLUSTER_NA
107117
echo "Minion instances IDs: $MINION_INSTANCE_IDS"
108118

109119
# Step 5 - Get IP addresses from Gru (Public or Private) and Minions (always Private)
110-
if [ "$GRU_PRIVATE_IP" = '' ]; then
120+
if [ "$GRU_PRIVATE_IP" == '' ]; then
111121
GRU_HOST=$(aws ec2 describe-instances --instance-ids $GRU_INSTANCE_ID \
112122
--query 'Reservations[*].Instances[*].[PublicIpAddress]' --output text | tr -d '\n')
113123
else
@@ -137,7 +147,10 @@ echo "Copying results from Gru"
137147
scp -r -i $PEM_PATH/$KEY_NAME.pem -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no ec2-user@${GRU_HOST}:/logs/* /logs
138148

139149
# Step 7 - Delete the cluster
140-
echo "Deleting cluster/$CLUSTER_NAME"
141-
ecs-cli down --cluster $CLUSTER_NAME --force
142-
150+
if [ "$RETAIN_CLUSTER" == '' ]; then
151+
echo "Deleting cluster/$CLUSTER_NAME"
152+
ecs-cli down --cluster $CLUSTER_NAME --force
153+
else
154+
echo "cluster/$CLUSTER_NAME is retained upon request."
155+
fi
143156
echo "Complete"

0 commit comments

Comments
 (0)