From 609c351441ff42def9f79615ba7bf3b261346114 Mon Sep 17 00:00:00 2001 From: brunohlopes Date: Tue, 23 Aug 2022 11:37:45 -0300 Subject: [PATCH] feat: add jmeter action --- Dockerfile | 31 +++++++++++++++++++++ README.md | 3 ++ action.yaml | 60 ++++++++++++++++++++++++++++++++++++++++ entrypoint.sh | 6 ++++ jmeter-plugin-install.sh | 19 +++++++++++++ 5 files changed, 119 insertions(+) create mode 100644 Dockerfile create mode 100644 README.md create mode 100644 action.yaml create mode 100644 entrypoint.sh create mode 100644 jmeter-plugin-install.sh diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..ea0c9b9 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,31 @@ +FROM public.ecr.aws/d5m6a7e4/sre-alpine:latest + +LABEL "maintainer" "Central QA" +LABEL "com.github.actions.name"="jmeter-runner-action" +LABEL "com.github.actions.description"="Github action for running a load test using Jmeter. Included with plugins:- concurrency thread, throughput shaping timer" + +ENV JMETER_VERSION "5.4.1" +ENV JMETER_HOME "/opt/apache/apache-jmeter-${JMETER_VERSION}" +ENV JMETER_BIN "${JMETER_HOME}/bin" +ENV PATH "$PATH:$JMETER_BIN" +ENV JMETER_CMD_RUNNER_VERSION "2.2" +ENV JMETER_PLUGIN_MANAGER_VERSION "1.6" + +COPY entrypoint.sh /entrypoint.sh +COPY jmeter-plugin-install.sh /jmeter-plugin-install.sh + +RUN apk --no-cache add curl ca-certificates openjdk9-jre && \ + curl -L https://archive.apache.org/dist/jmeter/binaries/apache-jmeter-${JMETER_VERSION}.tgz --output /tmp/apache-jmeter-${JMETER_VERSION}.tgz && \ + tar -zxvf /tmp/apache-jmeter-${JMETER_VERSION}.tgz && \ + mkdir -p /opt/apache && \ + mv apache-jmeter-${JMETER_VERSION} /opt/apache && \ + rm /tmp/apache-jmeter-${JMETER_VERSION}.tgz && \ + rm -rf ${JMETER_HOME}/docs && rm -rf ${JMETER_HOME}/printable_docs \ + rm -rf /var/cache/apk/* && \ + chmod a+x /entrypoint.sh && \ + chmod a+x /jmeter-plugin-install.sh + + +RUN /jmeter-plugin-install.sh + +ENTRYPOINT [ "/entrypoint.sh" ] diff --git a/README.md b/README.md new file mode 100644 index 0000000..a1e8357 --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# jmeter-runner-action +## Github action for running load test using Jmeter +## Includes plugin - Concurrency Threads and Throughput shaping timer diff --git a/action.yaml b/action.yaml new file mode 100644 index 0000000..ff52e1c --- /dev/null +++ b/action.yaml @@ -0,0 +1,60 @@ +--- +name: jmeter-runner-action +description: Github action for running a load test using Jmeter. Included with plugins:- concurrency thread, throughput shaping timer +author: QA-Performance-Engineering + +inputs: + testFilePath: + description: The path to the JMX test file + required: true + outputReportsFolder: + description: The folder where the JMeter reports will be published + required: false + default: reports/ + args: + required: false + description: | + Optional arguments that are passed to the JMeter tool + + Options: + -p, --propfile + -q, --addprop + -i, --jmeterlogconf + -j, --jmeterlogfile + -s, --server + -E, --proxyScheme + -H, --proxyHost + -P, --proxyPort + -N, --nonProxyHosts + -u, --username + -a, --password + -J, --jmeterproperty = + -G, --globalproperty = + -D, --systemproperty = + -S, --systemPropertyFile + -f, --forceDeleteResultFile + -L, --loglevel = + -r, --runremote + -R, --remotestart + -d, --homedir + -X, --remoteexit + -g, --reportonly + +runs: + using: 'docker' + image: 'Dockerfile' + args: + - "-n" + - "-t" + - "${{ inputs.testFilePath }}" + - "-l" + - "jmeter_log.log" + - "-e" + - "-f" + - "-o" + - "${{ inputs.outputReportsFolder }}" + - "${{ inputs.args }}" + +branding: + color: blue + icon: zap diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100644 index 0000000..c378c49 --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,6 @@ +#!/bin/sh + +# Export JAVA_HOME Variable within Entrypoint +export JAVA_HOME="/usr/lib/jvm/java-9-openjdk" + +jmeter $@ \ No newline at end of file diff --git a/jmeter-plugin-install.sh b/jmeter-plugin-install.sh new file mode 100644 index 0000000..26eec16 --- /dev/null +++ b/jmeter-plugin-install.sh @@ -0,0 +1,19 @@ +#!/bin/sh +echo ${JMETER_HOME} +echo ${JMETER_CMD_RUNNER_VERSION} +echo ${JMETER_PLUGIN_MANAGER_VERSION} + +echo "Downloading CMDRunner" +curl -L http://search.maven.org/remotecontent?filepath=kg/apc/cmdrunner/${JMETER_CMD_RUNNER_VERSION}/cmdrunner-${JMETER_CMD_RUNNER_VERSION}.jar --output ${JMETER_HOME}/lib/cmdrunner-${JMETER_CMD_RUNNER_VERSION}.jar + +echo "Downloading Plugin Manager" +curl -L https://jmeter-plugins.org/get/ --output ${JMETER_HOME}/lib/ext/jmeter-plugins-manager-${JMETER_PLUGIN_MANAGER_VERSION}.jar + +java -cp /opt/apache/apache-jmeter-${JMETER_VERSION}/lib/ext/jmeter-plugins-manager-${JMETER_PLUGIN_MANAGER_VERSION}.jar org.jmeterplugins.repository.PluginManagerCMDInstaller + +chmod a+x ${JMETER_HOME}/bin/*.sh + +${JMETER_HOME}/bin/PluginsManagerCMD.sh install jpgc-udp=0.4 +${JMETER_HOME}/bin/PluginsManagerCMD.sh install jpgc-casutg +${JMETER_HOME}/bin/PluginsManagerCMD.sh install jpgc-tst +chmod a+x ${JMETER_HOME}/lib/ext/*.jar