Skip to content

Commit 05cd2dc

Browse files
committed
added env variable docs, added MEM_LIMIT variable, support creation of 2 submits in aws-setup.sh
1 parent b9410a1 commit 05cd2dc

File tree

3 files changed

+50
-23
lines changed

3 files changed

+50
-23
lines changed

README.md

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ The `smithmicro/lucy` Docker image can be run as-is with a number of required en
1212

1313
Prerequisites to use this image:
1414
* Create a VPC with at least one subnet as ECS requires the use of VPC **
15-
* Create a VPC security group that allows ports 22, 1099, 50000 and 51000 (tcp) to the VPC **
15+
* Create a VPC security group that allows ports 22, 1099, 50000 and 51000 (tcp) and 4445 (udp) to the VPC **
1616
* Create a security key pair and place in the `keys` subdirectory
1717
* Have your AWS CLI Access Key ID/Secret Access Key handy
1818
* Replace or edit the included `plans/demo.jmx` to run your specific tests
@@ -31,7 +31,6 @@ docker run -v <oath to jmx>:/plans -v <path to pem>:/keys -v <path to logs>:/log
3131
--env SUBNET_ID=<subnet ID within your VPC> \
3232
--env KEY_NAME=<key pair name without extension> \
3333
--env MINION_COUNT=<number of minions> \
34-
--env INSTANCE_TYPE=<valid ECS instance type> \
3534
smithmicro/lucy /plans/demo.jmx
3635
```
3736
For 5 test instances in N. Virginia, `docker run` would look like this, assuming your `jmeter-key.pem` file is located in the `keys` subdirectory:
@@ -44,7 +43,6 @@ docker run -v $PWD/plans:/plans -v $PWD/keys:/keys -v $PWD/logs:/logs \
4443
--env SUBNET_ID=subnet-12345678 \
4544
--env KEY_NAME=jmeter-key \
4645
--env MINION_COUNT=5 \
47-
--env INSTANCE_TYPE=t2.small \
4846
smithmicro/lucy /plans/demo.jmx
4947
```
5048

@@ -123,6 +121,28 @@ docker-compose up
123121
```
124122
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.
125123

124+
## Notes
125+
The following required and optional environment variables are supported:
126+
127+
| Variable | Required | Default | Notes |
128+
|---|---|---|---|
129+
|AWS_DEFAULT_REGION|Yes|None|AWS Region (e.g. us-east-1)|
130+
|AWS_ACCESS_KEY_ID|Yes|None|AWS Access Key|
131+
|AWS_SECRET_ACCESS_KEY|Yes|None|AWS Secret Key|
132+
|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`|
133+
|KEY_NAME|Yes|None|AWS Security Key Pair .pem file (do not specify the .pem extension)|
134+
|SECURITY_GROUP|Yes|None|AWS Secuirty group that allows ports 22,1099,50000,51000/tcp and 4445/udp from all ports (e.g. sg-12345678)|
135+
|SUBNET_ID|Yes|None|One or more Subnets that are assigned to your VPC|
136+
|VPC_ID||VPC assigned to SUBNET_ID|We dautomatically erive this from your SUBNET_ID|
137+
|JMETER_VERSION||latest|smithmicro/lucy Image tag. See Docker Hub for [available versions](https://hub.docker.com/r/smithmicro/jmeter/tags/).|
138+
|INSTANCE_TYPE||t2.micro|To double your memory, pass t2.small|
139+
|MEM_LIMIT||950m|If you are using t2.small, set MEM_LIMIT to 1995m|
140+
|MINION_COUNT||2||
141+
|PEM_PATH||/keys|This must match your Volume map. See Volume section above.|
142+
|MINION_CLUSTER_NAME||JMeterMinion|Name that appears in your AWS Cluster UI|
143+
|GRU_CLUSTER_NAME||JMeterGru|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.|
145+
126146
## Notes
127147
This Docker image uses the Instance Metadata API documented here:
128148
* http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-instance-metadata.html
@@ -133,11 +153,6 @@ To get the instance public hostname within the `entrypoint.sh` script, we call:
133153
For more information on JMeter Distributed Testing, see:
134154
* http://jmeter.apache.org/usermanual/remote-test.html
135155

136-
You can specify which JMeter version to run by adding the following to the Docker run line. By default, the `latest` tag is used.
137-
* --env JMETER_VERSION=3.3
138-
139-
If you would like to run Lucy in AWS, and it is running in the same VPC as Gru, you can configure Lucy to use the Private IP address of Gru:
140-
* --env GRU_PRIVATE_IP=true
141156

142157
## Inspired by...
143158
https://en.wikipedia.org/wiki/Despicable_Me_2

aws-setup.sh

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,13 @@ if [ "$CIDR_BLOCK" == '' ]; then
99
# create a CIDR block at 10.74, the 74 being ASCII 'J'
1010
CIDR_BLOCK=10.74.0.0/16
1111
fi
12-
if [ "$SUBNET_CIDR_BLOCK" == '' ]; then
12+
if [ "$SUBNET_CIDR_BLOCK1" == '' ]; then
1313
# this CIDR limits us to 251 JMeter Minions - protection from a typo trying to create 1000 instances
14-
SUBNET_CIDR_BLOCK=10.74.1.0/24
14+
SUBNET_CIDR_BLOCK1=10.74.1.0/24
15+
fi
16+
if [ "$SUBNET_CIDR_BLOCK2" == '' ]; then
17+
# this CIDR limits us to 251 JMeter Minions - protection from a typo trying to create 1000 instances
18+
SUBNET_CIDR_BLOCK2=10.74.2.0/24
1519
fi
1620
if [ "$OWNER" == '' ]; then
1721
OWNER=jmeter-ecs
@@ -39,10 +43,12 @@ echo "Created VPC $VPC_ID"
3943
# enable DNS hostnames
4044
aws ec2 modify-vpc-attribute --vpc-id $VPC_ID --enable-dns-hostnames --output text
4145

42-
# create a single subnet
43-
SUBNET_ID=$(aws ec2 create-subnet --vpc-id $VPC_ID --cidr-block $SUBNET_CIDR_BLOCK \
46+
# create a 2 subnets
47+
SUBNET_ID1=$(aws ec2 create-subnet --vpc-id $VPC_ID --cidr-block $SUBNET_CIDR_BLOCK1 \
48+
--query 'Subnet.[SubnetId]' --output text | tr -d '\n')
49+
SUBNET_ID2=$(aws ec2 create-subnet --vpc-id $VPC_ID --cidr-block $SUBNET_CIDR_BLOCK2 \
4450
--query 'Subnet.[SubnetId]' --output text | tr -d '\n')
45-
echo "Created Subnet $SUBNET_ID"
51+
echo "Created Subnets $SUBNET_ID1,$SUBNET_ID2"
4652

4753
# Step 2: Make Your Subnet Public
4854
IGW_ID=$(aws ec2 create-internet-gateway --query 'InternetGateway.[InternetGatewayId]' --output text | tr -d '\n')
@@ -59,12 +65,14 @@ if [ "$CREATE_ROUTE_RESULT" == 'True' ]; then
5965
echo "Created route for all traffic to the Internet Gateway"
6066
fi
6167

62-
# make this a public subnet
63-
RTBASSOC_ID=$(aws ec2 associate-route-table --subnet-id $SUBNET_ID --route-table-id $RTB_ID --output text | tr -d '\n')
64-
echo "Created Route Table Association $RTBASSOC_ID"
68+
# make these public subnet
69+
RTBASSOC_ID1=$(aws ec2 associate-route-table --subnet-id $SUBNET_ID1 --route-table-id $RTB_ID --output text | tr -d '\n')
70+
RTBASSOC_ID2=$(aws ec2 associate-route-table --subnet-id $SUBNET_ID2 --route-table-id $RTB_ID --output text | tr -d '\n')
71+
echo "Created Route Table Associations $RTBASSOC_ID1,$RTBASSOC_ID2"
6572

6673
# we need public IP addresses so instances can register with ECS clusters
67-
aws ec2 modify-subnet-attribute --subnet-id $SUBNET_ID --map-public-ip-on-launch
74+
aws ec2 modify-subnet-attribute --subnet-id $SUBNET_ID1 --map-public-ip-on-launch
75+
aws ec2 modify-subnet-attribute --subnet-id $SUBNET_ID2 --map-public-ip-on-launch
6876

6977
# create a security group for JMeter
7078
SG_ID=$(aws ec2 create-security-group --group-name "JMeter" --description "JMeter Security Group" --vpc-id $VPC_ID --output text | tr -d '\n')
@@ -74,10 +82,10 @@ JMETER_IP_PERMISSIONS='[{"IpProtocol": "tcp", "FromPort": 22, "ToPort": 22, "IpR
7482
aws ec2 authorize-security-group-ingress --group-id $SG_ID --ip-permissions "$JMETER_IP_PERMISSIONS"
7583

7684
# tag all created resources
77-
aws ec2 create-tags --resources $VPC_ID $SUBNET_ID $IGW_ID $RTB_ID $SG_ID --tags $VPC_TAGS --output text
85+
aws ec2 create-tags --resources $VPC_ID $SUBNET_ID1 $SUBNET_ID2 $IGW_ID $RTB_ID $SG_ID --tags $VPC_TAGS --output text
7886

7987
echo "******** Use these two enviroment variables in 'docker run'"
80-
echo " --env SUBNET_ID=$SUBNET_ID"
88+
echo " --env SUBNET_ID=$SUBNET_ID1,$SUBNET_ID2"
8189
echo " --env SECURITY_GROUP=$SG_ID"
8290
echo "********"
8391

lucy/lucy.sh

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ if [ "$KEY_NAME" == '' ]; then
2626
exit 2
2727
fi
2828
if [ "$SECURITY_GROUP" == '' ]; then
29-
echo "Please set a SECURITY_GROUP that allows ports 22, 1099, 50000, 51000 (tcp) from all ports (e.g. sg-12345678)"
29+
echo "Please set a SECURITY_GROUP that allows ports 22,1099,50000,51000/tcp and 4445/udp from all ports (e.g. sg-12345678)"
3030
exit 3
3131
fi
3232
if [ "$SUBNET_ID" == '' ]; then
@@ -53,6 +53,9 @@ fi
5353
if [ "$INSTANCE_TYPE" == '' ]; then
5454
INSTANCE_TYPE=t2.micro
5555
fi
56+
if [ "$MEM_LIMIT" == '' ]; then
57+
MEM_LIMIT=950m
58+
fi
5659
if [ "$MINION_COUNT" == '' ]; then
5760
MINION_COUNT=2
5861
fi
@@ -84,7 +87,7 @@ do
8487
MINION_CONTAINER_INSTANCE_IDS=$(aws ecs list-container-instances --cluster $MINION_CLUSTER_NAME --output text |
8588
awk '{print $2}' | tr '\n' ' ')
8689
if [ "$MINION_CONTAINER_INSTANCE_IDS" == '' ]; then
87-
echo "Waiting for Minion container instances IDs.."
90+
echo "Waiting for Minion container instance IDs.."
8891
sleep 5
8992
fi
9093
done
@@ -98,7 +101,7 @@ do
98101
GRU_CONTAINER_INSTANCE_ID=$(aws ecs list-container-instances --cluster $GRU_CLUSTER_NAME --output text |
99102
awk '{print $2}' | tr '\n' ' ')
100103
if [ "$GRU_CONTAINER_INSTANCE_ID" == '' ]; then
101-
echo "Waiting for Gru container instances ID.."
104+
echo "Waiting for Gru container instance ID..."
102105
sleep 5
103106
fi
104107
done
@@ -107,8 +110,9 @@ GRU_INSTANCE_ID=$(aws ecs describe-container-instances --cluster $GRU_CLUSTER_NA
107110
--container-instances $GRU_CONTAINER_INSTANCE_ID --query 'containerInstances[*].[ec2InstanceId]' --output text)
108111
echo "Gru instances ID: $GRU_INSTANCE_ID"
109112

110-
# Step 3 - Run the Minion task with the requested JMeter version and instance count
113+
# Step 3 - Run the Minion task with the requested JMeter version, instance count and memory
111114
sed -i 's/jmeter:latest/jmeter:'"$JMETER_VERSION"'/' /opt/jmeter/lucy.yml
115+
sed -i 's/950m/'"$MEM_LIMIT"'/' /opt/jmeter/lucy.yml
112116
ecs-cli compose --file /opt/jmeter/lucy.yml up --cluster $MINION_CLUSTER_NAME
113117
ecs-cli compose --file /opt/jmeter/lucy.yml --cluster $MINION_CLUSTER_NAME scale $MINION_COUNT
114118

0 commit comments

Comments
 (0)