From b227f5c04b05ebbac3a16584cd3eaa36b3c6b34d Mon Sep 17 00:00:00 2001 From: Martin Prikryl Date: Tue, 8 Nov 2022 12:16:12 +0100 Subject: [PATCH 1/4] Add JMeter 5.5 with Java 18 --- jmeter/5.2/Dockerfile | 48 +++++++++++++++++++++++++ jmeter/5.2/entrypoint.sh | 76 ++++++++++++++++++++++++++++++++++++++++ jmeter/Dockerfile | 23 ++++++------ jmeter/entrypoint.sh | 10 +++--- 4 files changed, 140 insertions(+), 17 deletions(-) create mode 100644 jmeter/5.2/Dockerfile create mode 100755 jmeter/5.2/entrypoint.sh diff --git a/jmeter/5.2/Dockerfile b/jmeter/5.2/Dockerfile new file mode 100644 index 0000000..bd5a971 --- /dev/null +++ b/jmeter/5.2/Dockerfile @@ -0,0 +1,48 @@ +FROM openjdk:8-alpine + +LABEL maintainer="David Sperling " + +ENV JMETER_VERSION apache-jmeter-5.2 +ENV JMETER_HOME /opt/$JMETER_VERSION +ENV PATH $PATH:$JMETER_HOME/bin +ENV CMDRUNNER_VERSION 2.2 +ENV PLUGINMGR_VERSION 1.3 + +# overridable environment variables +ENV RESULTS_LOG results.jtl +ENV JMETER_FLAGS= +ENV CUSTOM_PLUGIN_URL= + +# Install the required tools for JMeter +RUN apk add --update --no-cache \ + curl \ + openssh-client + +WORKDIR /opt + +# install JMeter and the JMeter Plugins Manager +RUN curl -O https://archive.apache.org/dist/jmeter/binaries/$JMETER_VERSION.tgz \ + && tar -xvf $JMETER_VERSION.tgz \ + && rm $JMETER_VERSION.tgz \ + && rm -rf $JMETER_VERSION/docs $JMETER_VERSION/printable_docs \ + && cd $JMETER_HOME/lib \ + && curl -OL http://search.maven.org/remotecontent?filepath=kg/apc/cmdrunner/$CMDRUNNER_VERSION/cmdrunner-$CMDRUNNER_VERSION.jar \ + && cd $JMETER_HOME/lib/ext \ + && curl -OL4 http://search.maven.org/remotecontent?filepath=kg/apc/jmeter-plugins-manager/$PLUGINMGR_VERSION/jmeter-plugins-manager-$PLUGINMGR_VERSION.jar \ + && java -cp jmeter-plugins-manager-$PLUGINMGR_VERSION.jar org.jmeterplugins.repository.PluginManagerCMDInstaller + +# install all available plugins except for those that are deprecated +RUN PluginsManagerCMD.sh install-all-except jpgc-hadoop,jpgc-oauth \ + && sleep 2 \ + && PluginsManagerCMD.sh status + +# copy our entrypoint +COPY entrypoint.sh /opt/jmeter/ + +WORKDIR /logs + +EXPOSE 1099 50000 51000 4445/udp + +# default command in the entrypoint is 'minion' +ENTRYPOINT ["/opt/jmeter/entrypoint.sh"] +CMD ["minion"] diff --git a/jmeter/5.2/entrypoint.sh b/jmeter/5.2/entrypoint.sh new file mode 100755 index 0000000..af154f6 --- /dev/null +++ b/jmeter/5.2/entrypoint.sh @@ -0,0 +1,76 @@ +#!/bin/sh +# +# Main entrypoint for our Docker image - runs Gru, Minions or other commands + +# any .jmx file passed in the command line we act as 'Gru' +if [ ${1##*.} = 'jmx' ]; then + + if [ "$MINION_HOSTS" = '' ]; then + echo "MINION_HOSTS must be specified - a command separated list of hostnames or IP addresses" + exit 1 + fi + echo "Connecting to $MINION_HOSTS" + + # AWS Public HOSTNAME API + echo "Detecting an AWS Environment" + PUBLIC_HOSTNAME=$(curl -s --max-time 5 http://169.254.169.254/latest/meta-data/public-hostname) + + if [ "$PUBLIC_HOSTNAME" = '' ]; then + echo "Not running in AWS. Using Gru HOSTNAME $HOSTNAME" + else + HOSTNAME=$PUBLIC_HOSTNAME + echo "Using Gru AWS Public HOSTNAME $HOSTNAME" + fi + # empty the logs directory, or jmeter may fail + rm -rf /logs/report /logs/*.log /logs/*.jtl + + # remove setting JAVA heap and use the RUN_IN_DOCKER variable + sed -i 's/-Xms1g -Xmx1g -XX:MaxMetaspaceSize=256m//' $JMETER_HOME/bin/jmeter + sed -i 's/# RUN_IN_DOCKER/RUN_IN_DOCKER/' $JMETER_HOME/bin/jmeter + + # run jmeter in client (gru) mode + exec jmeter -n $JMETER_FLAGS \ + -R $MINION_HOSTS \ + -Dclient.rmi.localport=51000 \ + -Dserver.rmi.ssl.disable=true \ + -Djava.rmi.server.hostname=${PUBLIC_HOSTNAME} \ + -l $RESULTS_LOG \ + -t $1 \ + -e -o /logs/report + +fi + +# act as a 'Minion' +if [ "$1" = 'minion' ]; then + + # AWS Public HOSTNAME API + echo "Detecting an AWS Environment" + PUBLIC_HOSTNAME=$(curl -s --max-time 5 http://169.254.169.254/latest/meta-data/public-hostname) + + if [ "$PUBLIC_HOSTNAME" = '' ]; then + echo "Not running in AWS. Using Minion HOSTNAME $HOSTNAME" + else + HOSTNAME=$PUBLIC_HOSTNAME + echo "Using Minion AWS Public HOSTNAME $HOSTNAME" + fi + + # remove setting JAVA heap and use the RUN_IN_DOCKER variable + sed -i 's/-Xms1g -Xmx1g -XX:MaxMetaspaceSize=256m//' $JMETER_HOME/bin/jmeter + sed -i 's/# RUN_IN_DOCKER/RUN_IN_DOCKER/' $JMETER_HOME/bin/jmeter + + # install custom plugin if requested + if [ "$CUSTOM_PLUGIN_URL" != '' ]; then + echo "Installing custom plugin $CUSTOM_PLUGIN_URL" + CUSTOM_PLUGIN_FILE="${CUSTOM_PLUGIN_URL##*/}" + curl -o $JMETER_HOME/lib/ext/$CUSTOM_PLUGIN_FILE $CUSTOM_PLUGIN_URL + fi + + # run jmeter in server (minion) mode + exec jmeter-server -n $JMETER_FLAGS \ + -Dserver.rmi.localport=50000 \ + -Dserver.rmi.ssl.disable=true \ + -Djava.rmi.server.hostname=${HOSTNAME} + +fi + +exec "$@" diff --git a/jmeter/Dockerfile b/jmeter/Dockerfile index bd5a971..145a825 100644 --- a/jmeter/Dockerfile +++ b/jmeter/Dockerfile @@ -1,17 +1,17 @@ -FROM openjdk:8-alpine +FROM eclipse-temurin:18-alpine LABEL maintainer="David Sperling " -ENV JMETER_VERSION apache-jmeter-5.2 -ENV JMETER_HOME /opt/$JMETER_VERSION -ENV PATH $PATH:$JMETER_HOME/bin -ENV CMDRUNNER_VERSION 2.2 -ENV PLUGINMGR_VERSION 1.3 +ENV JMETER_VERSION=apache-jmeter-5.5 +ENV JMETER_HOME=/opt/$JMETER_VERSION +ENV PATH=$PATH:$JMETER_HOME/bin +ENV CMDRUNNER_VERSION=2.3 +ENV PLUGINMGR_VERSION=1.8 # overridable environment variables -ENV RESULTS_LOG results.jtl -ENV JMETER_FLAGS= -ENV CUSTOM_PLUGIN_URL= +ENV RESULTS_LOG=results.jtl +ENV JMETER_FLAGS="" +ENV CUSTOM_PLUGIN_URL="" # Install the required tools for JMeter RUN apk add --update --no-cache \ @@ -31,8 +31,9 @@ RUN curl -O https://archive.apache.org/dist/jmeter/binaries/$JMETER_VERSION.tgz && curl -OL4 http://search.maven.org/remotecontent?filepath=kg/apc/jmeter-plugins-manager/$PLUGINMGR_VERSION/jmeter-plugins-manager-$PLUGINMGR_VERSION.jar \ && java -cp jmeter-plugins-manager-$PLUGINMGR_VERSION.jar org.jmeterplugins.repository.PluginManagerCMDInstaller -# install all available plugins except for those that are deprecated -RUN PluginsManagerCMD.sh install-all-except jpgc-hadoop,jpgc-oauth \ +# install all available plugins except for those that are deprecated, not compatible or under licence +RUN PluginsManagerCMD.sh install-all-except \ + jpgc-oauth,schema-assertion,ulp-jmeter-autocorrelator-plugin,ulp-jmeter-gwt-plugin,ulp-jmeter-videostreaming-plugin,di-kafkameter,tilln-iso8583,jmeter.backendlistener.elasticsearch,jmeter-grpc-request,websocket-sampler \ && sleep 2 \ && PluginsManagerCMD.sh status diff --git a/jmeter/entrypoint.sh b/jmeter/entrypoint.sh index af154f6..906c3cd 100755 --- a/jmeter/entrypoint.sh +++ b/jmeter/entrypoint.sh @@ -24,10 +24,9 @@ if [ ${1##*.} = 'jmx' ]; then # empty the logs directory, or jmeter may fail rm -rf /logs/report /logs/*.log /logs/*.jtl - # remove setting JAVA heap and use the RUN_IN_DOCKER variable + # remove setting JAVA heap sed -i 's/-Xms1g -Xmx1g -XX:MaxMetaspaceSize=256m//' $JMETER_HOME/bin/jmeter - sed -i 's/# RUN_IN_DOCKER/RUN_IN_DOCKER/' $JMETER_HOME/bin/jmeter - + # run jmeter in client (gru) mode exec jmeter -n $JMETER_FLAGS \ -R $MINION_HOSTS \ @@ -54,10 +53,9 @@ if [ "$1" = 'minion' ]; then echo "Using Minion AWS Public HOSTNAME $HOSTNAME" fi - # remove setting JAVA heap and use the RUN_IN_DOCKER variable + # remove setting JAVA heap sed -i 's/-Xms1g -Xmx1g -XX:MaxMetaspaceSize=256m//' $JMETER_HOME/bin/jmeter - sed -i 's/# RUN_IN_DOCKER/RUN_IN_DOCKER/' $JMETER_HOME/bin/jmeter - + # install custom plugin if requested if [ "$CUSTOM_PLUGIN_URL" != '' ]; then echo "Installing custom plugin $CUSTOM_PLUGIN_URL" From 709f04acc87777ae8acfe22665910c7f2768d38d Mon Sep 17 00:00:00 2001 From: Martin Prikryl Date: Tue, 8 Nov 2022 12:47:45 +0100 Subject: [PATCH 2/4] Add support for multiple parallel .jmx plans --- README.md | 27 +++++++++++++++------ jmeter/Dockerfile | 1 - jmeter/docker-compose.yml | 17 ++++++++++--- jmeter/entrypoint.sh | 49 +++++++++++++++++++++++++++++++------- lucy/lucy.sh | 50 +++++++++++++++++++++++++++++++-------- 5 files changed, 115 insertions(+), 29 deletions(-) diff --git a/README.md b/README.md index d868c7f..3fbb0ff 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ Prerequisites to use this image: Docker run template: ``` -docker run -v :/plans -v :/keys -v :/logs \ +docker run -v :/plans -v :/keys -v :/logs \ --env AWS_ACCESS_KEY_ID= \ --env AWS_SECRET_ACCESS_KEY= \ --env AWS_DEFAULT_REGION= \ @@ -45,6 +45,19 @@ docker run -v $PWD/plans:/plans -v $PWD/keys:/keys -v $PWD/logs:/logs \ --env MINION_COUNT=5 \ smithmicro/lucy /plans/demo.jmx ``` +*Since 5.5:* +Run two .jmx test plans in parallel, 1st using 4 minions, 2nd and following using 2 minions: +``` +docker run -v $PWD/plans:/plans -v $PWD/keys:/keys -v $PWD/logs:/logs \ + --env AWS_ACCESS_KEY_ID=ABCDEFGHIJKLMNOPQRST \ + --env AWS_SECRET_ACCESS_KEY=abcdefghijklmnopqrstuvwxyz0123456789ABCDEF \ + --env AWS_DEFAULT_REGION=us-east-1 \ + --env SECURITY_GROUP=sg-12345678 \ + --env SUBNET_ID=subnet-12345678,subnet-87654321 \ + --env KEY_NAME=jmeter-key \ + --env MINION_COUNT=4,2 \ + smithmicro/lucy /plans/TestOne.jmx,/plans/TestTwo.jmx,/plans/TestThree.jmx +``` ## Architecture This Docker image replaces the JMeter master/slave nomenclature with *Gru*, *Minion* and *Lucy*. *Gru* manages the *Minions* from within ECS, but *Lucy* orchestrates the entire process. @@ -98,22 +111,22 @@ The following required and optional environment variables are supported: |AWS_DEFAULT_REGION|Yes|None|AWS Region (e.g. `us-east-1`)| |AWS_ACCESS_KEY_ID|Yes|None|AWS Access Key| |AWS_SECRET_ACCESS_KEY|Yes|None|AWS Secret Key| -|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`| +|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`.
*Since 5.5:* Comma separated list of .jmx files| |KEY_NAME|Yes|None|AWS Security Key Pair .pem file (do not specify the .pem extension)| |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)| |SUBNET_ID|Yes|None|One or more Subnets (comma separated) that are assigned to your VPC| -|VPC_ID||VPC assigned to SUBNET_ID|We dautomatically erive this from your SUBNET_ID| +|VPC_ID||VPC assigned to SUBNET_ID|We automatically derive this from your SUBNET_ID| |JMETER_VERSION||latest|smithmicro/jmeter Image tag. See Docker Hub for [available versions](https://hub.docker.com/r/smithmicro/jmeter/tags/).| |INSTANCE_TYPE||t2.micro|To double your memory, pass `t2.small`| |MEM_LIMIT||950m|If you are using t2.small, set MEM_LIMIT to `1995m`| -|MINION_COUNT||2|| +|MINION_COUNT||2|*Since 5.5:* Comma separated list of minion counts for each .jmx specified in INPUT_JMX in its order. If MINION_COUNT list is shorter than INPUT_JMX, last value of MINION_COUNT will be used for remaining .jmx test plans from INPUT_JMX.| |PEM_PATH||/keys|This must match your Volume map. See Volume section above.| |CLUSTER_NAME||JMeter|Name that appears in your AWS Cluster UI| -|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.| +|GRU_PRIVATE_IP||None|Set to non-empty string if you would like to run Lucy within AWS. See GitHub [Issue 8](https://github.com/smithmicro/jmeter-ecs/issues/8) for details.| |JMETER_FLAGS||None|Custom JMeter command line options. For example, passing `-X` will tell the Minion to exit at the end of the test| -|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.| +|RETAIN_CLUSTER||None|Set to non-empty string if you want to re-use your cluster for future tests. Warning, you will incur AWS charges if you leave your cluster running.| |CUSTOM_PLUGIN_URL||None|The URL of a custom plugin you want to install in the Minions. File will be copied to $JMETER_HOME/lib/ext.|| -|COPY_DIR||None|Set to `true` if you want to copy the directory in which the .jmx file is located to all Minions and Gru. The files will be located in all Docker containers in ` /plans`. Update your JMX file to reference external files at `/plans/...`| +|COPY_DIR||None|Set to non-empty string if you want to copy the directory in which the .jmx file is located to all Minions and Gru. The files will be located in all Docker containers in ` /plans`. Update your JMX file to reference external files at `/plans/...`.
*Since 5.5:* Directory from the first .jmx will be used.| ## Notes All current JMeter Plugins are installed via the Plugins Manager. diff --git a/jmeter/Dockerfile b/jmeter/Dockerfile index 145a825..5298a24 100644 --- a/jmeter/Dockerfile +++ b/jmeter/Dockerfile @@ -9,7 +9,6 @@ ENV CMDRUNNER_VERSION=2.3 ENV PLUGINMGR_VERSION=1.8 # overridable environment variables -ENV RESULTS_LOG=results.jtl ENV JMETER_FLAGS="" ENV CUSTOM_PLUGIN_URL="" diff --git a/jmeter/docker-compose.yml b/jmeter/docker-compose.yml index 5642557..942851a 100644 --- a/jmeter/docker-compose.yml +++ b/jmeter/docker-compose.yml @@ -11,11 +11,14 @@ services: volumes: - ../plans:/plans - ./logs:/logs - command: "/plans/TestCert.jmx" + command: "/plans/TestOne.jmx,/plans/TestTwo.jmx" links: - minion1 - environment: - - MINION_HOSTS=minion1 + - minion2 + - minion3 + environment: + - MINION_HOSTS=minion1,minion2,minion3 + - MINION_COUNT=1,2 - JMETER_FLAGS=-X ports: - "4445:4445/udp" @@ -23,3 +26,11 @@ services: image: smithmicro/jmeter:latest environment: - JMETER_FLAGS=-Djavax.net.ssl.keyStore=/plans/test.p12 + minion2: + image: smithmicro/jmeter:latest + environment: + - JMETER_FLAGS=-Djavax.net.ssl.keyStore=/plans/test.p12 + minion3: + image: smithmicro/jmeter:latest + environment: + - JMETER_FLAGS=-Djavax.net.ssl.keyStore=/plans/test.p12 diff --git a/jmeter/entrypoint.sh b/jmeter/entrypoint.sh index 906c3cd..2baf110 100755 --- a/jmeter/entrypoint.sh +++ b/jmeter/entrypoint.sh @@ -5,6 +5,10 @@ # any .jmx file passed in the command line we act as 'Gru' if [ ${1##*.} = 'jmx' ]; then + if [ "$MINION_COUNT" = '' ]; then + echo "MINION_COUNT must be specified - a command separated list of minion counts of the same length as list of .jmx files in 1st command line argument" + exit 1 + fi if [ "$MINION_HOSTS" = '' ]; then echo "MINION_HOSTS must be specified - a command separated list of hostnames or IP addresses" exit 1 @@ -28,14 +32,43 @@ if [ ${1##*.} = 'jmx' ]; then sed -i 's/-Xms1g -Xmx1g -XX:MaxMetaspaceSize=256m//' $JMETER_HOME/bin/jmeter # run jmeter in client (gru) mode - exec jmeter -n $JMETER_FLAGS \ - -R $MINION_HOSTS \ - -Dclient.rmi.localport=51000 \ - -Dserver.rmi.ssl.disable=true \ - -Djava.rmi.server.hostname=${PUBLIC_HOSTNAME} \ - -l $RESULTS_LOG \ - -t $1 \ - -e -o /logs/report + # run jmeter in client (gru) mode for all testplans + TEMP_INPUT_JMX=$1, + TEMP_MINION_COUNT=$MINION_COUNT, + TEMP_MINION_HOSTS=$MINION_HOSTS + + while [ "$TEMP_INPUT_JMX" ] + do + INPUT_JMX_FOR_TESTPLAN=${TEMP_INPUT_JMX%%,*} + MINION_COUNT_FOR_TESTPLAN=${TEMP_MINION_COUNT%%,*} + MINION_HOSTS_FOR_TESTPLAN=$(echo $TEMP_MINION_HOSTS | cut -f1-$MINION_COUNT_FOR_TESTPLAN -d,) + PORT_FOR_TESTPLAN=$((51000 + ${#TEMP_INPUT_JMX})) + NAME_FOR_TESTPLAN=$(basename $INPUT_JMX_FOR_TESTPLAN .jmx) + echo MINION_COUNT_FOR_TESTPLAN $MINION_COUNT_FOR_TESTPLAN + echo TEMP_MINION_HOSTS $TEMP_MINION_HOSTS + + jmeter -n $JMETER_FLAGS \ + -R $MINION_HOSTS_FOR_TESTPLAN \ + -Dclient.rmi.localport=$PORT_FOR_TESTPLAN \ + -Dserver.rmi.ssl.disable=true \ + -Djava.rmi.server.hostname=${PUBLIC_HOSTNAME} \ + -l $NAME_FOR_TESTPLAN.jtl \ + -j $NAME_FOR_TESTPLAN.log \ + -t $INPUT_JMX_FOR_TESTPLAN \ + -e -o /logs/$NAME_FOR_TESTPLAN & + + TEMP_INPUT_JMX=${TEMP_INPUT_JMX#*,} + TEMP_MINION_COUNT=${TEMP_MINION_COUNT#*,} + TEMP_MINION_HOSTS=$(echo $TEMP_MINION_HOSTS | cut -f$(($MINION_COUNT_FOR_TESTPLAN + 1))- -d,) + done + + # wait for jmeter processes to finish + while pgrep jmeter > /dev/null + do + sleep 20 + done + + exit fi diff --git a/lucy/lucy.sh b/lucy/lucy.sh index 1b05344..11a1588 100755 --- a/lucy/lucy.sh +++ b/lucy/lucy.sh @@ -69,10 +69,26 @@ if [ "$VPC_ID" == '' ]; then VPC_ID=$(aws ec2 describe-security-groups --group-ids $SECURITY_GROUP --query 'SecurityGroups[*].[VpcId]' --output text) fi -# Step 1 - Create our ECS Cluster with MINION_COUNT+1 instances +# Step 0 - Correct MINION_COUNT to have same number of comma separated values as INPUT_JMX +COMMAS_FROM_MINION_COUNT="${MINION_COUNT//[^,]}" +COMMAS_FROM_INPUT_JMX="${INPUT_JMX//[^,]}" +# shorten MINION_COUNT if it's too long +while [ ${#COMMAS_FROM_MINION_COUNT} -gt ${#COMMAS_FROM_INPUT_JMX} ] +do + MINION_COUNT=${MINION_COUNT%,*} + COMMAS_FROM_MINION_COUNT="${MINION_COUNT//[^,]}" +done +# prolong MINION_COUNT by duplicating last value if it's too short +while [ ${#COMMAS_FROM_MINION_COUNT} -lt ${#COMMAS_FROM_INPUT_JMX} ] +do + MINION_COUNT=$MINION_COUNT,${MINION_COUNT##*,} + COMMAS_FROM_MINION_COUNT="${MINION_COUNT//[^,]}" +done + +# Step 1 - Create our ECS Cluster with number of instances base on MINION_COUNT ecs-cli --version echo "Detecting existing cluster/$CLUSTER_NAME" -INSTANCE_COUNT=$((MINION_COUNT+1)) +INSTANCE_COUNT=$((${MINION_COUNT//,/+}+1)) CONTAINER_INSTANCE_COUNT=$(aws ecs describe-clusters --cluster $CLUSTER_NAME \ --query 'clusters[*].[registeredContainerInstancesCount]' --output text) if [ "$CONTAINER_INSTANCE_COUNT" == $INSTANCE_COUNT ]; then @@ -103,7 +119,7 @@ sed -i 's/JMETER_FLAGS=/JMETER_FLAGS='"$JMETER_FLAGS"'/' /opt/jmeter/lucy.yml sed -i 's/950m/'"$MEM_LIMIT"'/' /opt/jmeter/lucy.yml sed -i 's/CUSTOM_PLUGIN_URL=/CUSTOM_PLUGIN_URL='"$CUSTOM_PLUGIN_URL"'/' /opt/jmeter/lucy.yml ecs-cli compose --file /opt/jmeter/lucy.yml up --cluster $CLUSTER_NAME -ecs-cli compose --file /opt/jmeter/lucy.yml --cluster $CLUSTER_NAME scale $MINION_COUNT +ecs-cli compose --file /opt/jmeter/lucy.yml --cluster $CLUSTER_NAME scale $((${MINION_COUNT//,/+})) # Step 4 - Get Gru and Minion's instance ID's. Gru is the container with a runningTasksCount = 0 CONTAINER_INSTANCE_IDS=$(aws ecs list-container-instances --cluster $CLUSTER_NAME --output text | @@ -140,14 +156,19 @@ else #read -p "Press enter to start Gru setup: " # Step 6 - Copy all files to Minions/Gru, or just the JMX - if [ "$COPY_DIR" == '' ]; then - echo "Copying $INPUT_JMX to Gru" - scp -i $PEM_PATH/$KEY_NAME.pem -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no $INPUT_JMX ec2-user@${GRU_HOST}:/tmp - else + echo "Copying $INPUT_JMX to Gru" + TEMP_INPUT_JMX=$INPUT_JMX, + while [ "$TEMP_INPUT_JMX" ] + do + scp -i $PEM_PATH/$KEY_NAME.pem -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no ${TEMP_INPUT_JMX%%,*} ec2-user@${GRU_HOST}:/tmp + TEMP_INPUT_JMX=${TEMP_INPUT_JMX#*,} + done + if [ "$COPY_DIR" != '' ]; then # Get Gru and Minion public hosts (space delimited) so Lucy can reach them for scp. PUBLIC_HOSTS=$(aws ec2 describe-instances --instance-ids $GRU_INSTANCE_ID $MINION_INSTANCE_IDS \ --query 'Reservations[*].Instances[*].[PublicIpAddress]' --output text | tr '\n' ' ') - JMX_DIR=$(dirname $INPUT_JMX) + TEMP_INPUT_JMX=$INPUT_JMX, + JMX_DIR=$(dirname ${TEMP_INPUT_JMX%%,*}) for HOST in $PUBLIC_HOSTS; do echo "Copying $INPUT_JMX and test files to $HOST" @@ -157,9 +178,18 @@ else # Step 7 - Run Gru with the specified JMX echo "Running Docker to start JMeter in Gru mode" - JMX_IN_COMTAINER=/plans/$(basename $INPUT_JMX) + TEMP_INPUT_JMX=$INPUT_JMX, + JMX_IN_COMTAINER= + while [ "$TEMP_INPUT_JMX" ] + do + JMX_IN_COMTAINER=$JMX_IN_COMTAINER,/plans/$(basename ${TEMP_INPUT_JMX%%,*}) + TEMP_INPUT_JMX=${TEMP_INPUT_JMX#*,} + done + JMX_IN_COMTAINER=${JMX_IN_COMTAINER#,} + ssh -i $PEM_PATH/$KEY_NAME.pem -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no ec2-user@${GRU_HOST} \ - "docker run --network host -v /tmp:/plans -v /logs:/logs --env MINION_HOSTS=$MINION_HOSTS --env JMETER_FLAGS=$JMETER_FLAGS smithmicro/jmeter:$JMETER_VERSION $JMX_IN_COMTAINER" + "docker run --network host -v /tmp:/plans -v /logs:/logs --env MINION_HOSTS=$MINION_HOSTS --env MINION_COUNT=$MINION_COUNT \ + --env JMETER_FLAGS=$JMETER_FLAGS mprikryl/jmeter:$JMETER_VERSION $JMX_IN_COMTAINER" # Step 8 - Fetch the results from Gru echo "Copying results from Gru" From 3db4d3a969fc74a12d7ed908dae2325831aca84d Mon Sep 17 00:00:00 2001 From: Martin Prikryl Date: Tue, 8 Nov 2022 19:40:00 +0100 Subject: [PATCH 3/4] Remove additional comment --- jmeter/entrypoint.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/jmeter/entrypoint.sh b/jmeter/entrypoint.sh index 2baf110..003fd33 100755 --- a/jmeter/entrypoint.sh +++ b/jmeter/entrypoint.sh @@ -31,7 +31,6 @@ if [ ${1##*.} = 'jmx' ]; then # remove setting JAVA heap sed -i 's/-Xms1g -Xmx1g -XX:MaxMetaspaceSize=256m//' $JMETER_HOME/bin/jmeter - # run jmeter in client (gru) mode # run jmeter in client (gru) mode for all testplans TEMP_INPUT_JMX=$1, TEMP_MINION_COUNT=$MINION_COUNT, From 8750473cf7d46751ca937f9c4c2a2ddedaf75447 Mon Sep 17 00:00:00 2001 From: Martin Prikryl Date: Wed, 9 Nov 2022 15:32:39 +0100 Subject: [PATCH 4/4] Use smithmicro/jmeter image in lucy.sh --- lucy/lucy.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lucy/lucy.sh b/lucy/lucy.sh index 11a1588..6b0b67b 100755 --- a/lucy/lucy.sh +++ b/lucy/lucy.sh @@ -189,7 +189,7 @@ else ssh -i $PEM_PATH/$KEY_NAME.pem -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no ec2-user@${GRU_HOST} \ "docker run --network host -v /tmp:/plans -v /logs:/logs --env MINION_HOSTS=$MINION_HOSTS --env MINION_COUNT=$MINION_COUNT \ - --env JMETER_FLAGS=$JMETER_FLAGS mprikryl/jmeter:$JMETER_VERSION $JMX_IN_COMTAINER" + --env JMETER_FLAGS=$JMETER_FLAGS smithmicro/jmeter:$JMETER_VERSION $JMX_IN_COMTAINER" # Step 8 - Fetch the results from Gru echo "Copying results from Gru"