From 29f38c9919d4bf2a15e55e68d2e054688def5979 Mon Sep 17 00:00:00 2001 From: Marcos Tenrero Date: Sun, 10 Dec 2017 04:00:49 +0100 Subject: [PATCH] First release --- .gitignore | 1 + Dockerfile | 24 ++++++++++++++++++++++++ README.md | 33 ++++++++++++++++++++++++++++++++- docker-compose.yml | 22 ++++++++++++++++++++++ tools/jmeter_startpoint.sh | 36 ++++++++++++++++++++++++++++++++++++ 5 files changed, 115 insertions(+), 1 deletion(-) create mode 100644 .gitignore create mode 100644 Dockerfile create mode 100644 docker-compose.yml create mode 100644 tools/jmeter_startpoint.sh diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e43b0f9 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.DS_Store diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..5994a74 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,24 @@ +FROM alpine + +LABEL com.mtenrero.jmeter.version="3.3.0" +LABEL vendor="mtenrero.com" +LABEL maintainer="Marcos Tenrero" + +RUN apk --update add openjdk8-jre-base +RUN apk -- update add wget + +RUN wget http://ftp.cixug.es/apache//jmeter/binaries/apache-jmeter-3.3.tgz +RUN tar zxvf apache-jmeter*.tgz +RUN apk del wget + +COPY ./test /test +COPY jmeter_startpoint.sh /script/jmeter_startpoint.sh + +RUN rm -f apache-jmeter*.tgz +RUN rm -fr /apache-jmeter*/docs + +EXPOSE 7777 +EXPOSE 1099 +EXPOSE 4445 + +ENTRYPOINT [ "/bin/ash", "/script/jmeter_startpoint.sh" ] \ No newline at end of file diff --git a/README.md b/README.md index efc30cd..42123d2 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,33 @@ # jmeterDistributed -Docker Image with Jmeter specially designed for distributed load testing +Docker Image with Jmeter and OpenJDK JRE based on Linux Alpine specially designed for distributed load testing + +## Building the image +In order to build the image, you should run the following command: +`docker build -t mtenrero/jmeter -t mtenrero/jmeter:latest -t mtenrero/jmeter:3.3 .` +Please, bear in mind that the tags *:latest* and *:3.3* represents the version of Jmeter you're installing into the image + +## Running the image +The image can be started in two modes: + +- **Master** Represents the main instance of Jmeter, and should be started after the nodes. Also a environment variable **_REMOTES_** should be specified in the `docker run` command with the list of all available remotes to use by the master. `docker run -it -v $(pwd)/test:/test -e MODE="master" -e TEST_NAME="test.jmx" -e REMOTES="hosts" -p 6666:6666 mtenrero/jmeter` +- **Node** It's a worker in the distributed load testing process. `docker run -d -e MODE="node" -p 7777:7777 -p 1099:1099 -p 4445:4445 mtenrero/jmeter` + +## Docker Compose +Docker Compose is the easiest way to try the configuration locally. You only need to specify the test name without the JMX extension in the enviroment variable *TEST_NAME* and put the file under the test folder within the root docker-compose folder. + +If you need simulate multiple nodes, clone the slaves in the docker-compose file and make sure that they are declared in the REMOTES env. + +`TEST_NAME=abvetmadrid docker-compose up` + +## Ports +- **4445** Jmeter communication port +- **7777** RMI Port +- **1099** Master Port + +## Roadmap +- [x] Basic Image for running distributed tests +- [x] Docker-compose for local debugging +- [ ] Publish to Docker Hub +- [ ] CI/CD +- [ ] Docker-compose v3 improvements +- [ ] Fix non-ending slaves \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..5bd31a0 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,22 @@ +version: "3.3" +services: + master: + image: mtenrero/jmeter + tty: true + environment: + - MODE=master + - TEST_NAME=$TEST_NAME + - REMOTES=slave + expose: + - 6666 + depends_on: + - slave + slave: + image: mtenrero/jmeter + tty: true + environment: + - MODE=node + expose: + - 7777 + - 1099 + - 4445 \ No newline at end of file diff --git a/tools/jmeter_startpoint.sh b/tools/jmeter_startpoint.sh new file mode 100644 index 0000000..ef7135f --- /dev/null +++ b/tools/jmeter_startpoint.sh @@ -0,0 +1,36 @@ +# !/bin/bash +#### Description: Start up Jmeter in the mode specified +#### MODES: master / node +#### Master mode requires a REMOTES env with the list of the remote nodes +#### Written by: Marcos Tenrero on 11-2017 + +MODE=$MODE +RMI_PORT=$RMI_PORT +JMX=$JMX + +_node(){ + cd ../apache-jmeter* + cd bin + ./jmeter-server -Dserver.rmi.localport=7777 -Dserver_port=1099 +} + +_master(){ + cd ../apache-jmeter* + cd bin + ./jmeter -n -t ../../test/$TEST_NAME.jmx -R$REMOTES + ./shutdown.sh +} + +if [ "$MODE" == "master" ] +then + echo "MASTER/SINGLE mode" + _master +elif [ "$MODE" == "node" ] +then + echo "NODE/SLAVE mode" + _node +else + echo "No valid mode detected, master/node in env MODE, exiting..." + exit 1 +fi +