diff --git a/Dockerfile b/Dockerfile index 3ad6081..3887247 100644 --- a/Dockerfile +++ b/Dockerfile @@ -19,7 +19,7 @@ RUN apk update \ && apk upgrade \ && apk add ca-certificates \ && update-ca-certificates \ - && apk add --update openjdk8-jre tzdata curl unzip bash git openssh \ + && apk add --update openjdk8-jre tzdata curl unzip bash git openssh libxslt \ && apk add --no-cache nss \ && rm -rf /var/cache/apk/* \ && mkdir -p /tmp/dependencies \ @@ -61,4 +61,7 @@ RUN cd /tmp/ \ && jmeter --version \ && PluginsManagerCMD.sh status \ && chmod +x ${JMETER_HOME}/bin/*.sh \ - && rm -fr /tmp/* \ No newline at end of file + && rm -fr /tmp/* + +# add xsl file for result transformation \ +ADD ./jmeter-results2html.xsl ${JMETER_HOME} \ No newline at end of file diff --git a/README.md b/README.md index 20cda2a..1cd4e1f 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,16 @@ A JMeter image packaged with the JMeter plugins manager plus initialized plugins - JPGC Webdriver - Prometheus Listener -> Note: The entrypoint script evaluates the run results and returns 0 for successful runs and 1 if any errors occurred. +> Notes +> - The entrypoint script evaluates the run results and returns 0 for successful runs and 1 if any errors occurred. +> - JMeter provides an out-of-the-box feature to build html reports for performance tests by using the `-e -o ${R_DIR}` args. +> In order to produce html results for functional tests pass the variable XML_REPORT_PATH to trigger JMeter +> XML report to HTML conversion and make sure this xml report gets generated in your testplan, then pass e.g. `-JXML_REPORT_PATH=report/test-report.xml` +> + +Example call + +`docker run -i -v ${PWD}:${PWD} -w ${PWD} aservo/jmeter:5.5 -n -t ./tests/Demo.jmx -JXML_REPORT_PATH=reports/demo.xml` ## Links diff --git a/entrypoint.sh b/entrypoint.sh index 08f2b41..be921cf 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -22,11 +22,20 @@ echo "JMeter args=$@" jmeter $@ 2>&1 | tee jmeter-output echo "END Running Jmeter on `date`" +# Perform XSLT by extracting report path from arg (-JXML_REPORT_PATH) +if [[ $@ =~ (JXML_REPORT_PATH=)([^-]*) ]]; then + # get and trim regex match (see also https://stackoverflow.com/questions/3532718/extract-string-from-string-using-regex-in-the-terminal) + reportPath="${BASH_REMATCH[2]/ /}" + echo "Processing report xslt from ${reportPath} ..." + xsltproc --output "${reportPath/.xml/.html}" jmeter-results2html.xsl "${reportPath}" +else + echo "INFO: No xml report path provided. Consider setting -JXML_REPORT_PATH=[path to jmeter xml report file] in order to utilize the xslt transformation. See also readme.md" +fi + # Evaluate jmeter process output -if grep -q -E 'Err:.+[1-9]\W\(' jmeter-output -then +if grep -q -E 'Err:.+[1-9]\W\(' jmeter-output; then echo "RESULT: test failed :-( - return code 1" exit 1 else - echo "RESULT: test suceeded :-) - return code 0" + echo "RESULT: test succeeded :-) - return code 0" fi diff --git a/jmeter-results2html.xsl b/jmeter-results2html.xsl new file mode 100644 index 0000000..992ebe2 --- /dev/null +++ b/jmeter-results2html.xsl @@ -0,0 +1,238 @@ + + + + + + + + + + JMeter Test Results + + + + +
+
    + + + + + + + +
  1. + +
    + + + success + failure + + + +
    + + + +
  2. +
    + + + sub-success + sub-failure + + + +
    + +
  3. +
    + + + +
+
+
+ + +
+ +
+
Sampler
+
+ + + + + + + + + + +
Thread Name:
Timestamp:
Time: ms
Latency: ms
Bytes:
Sample Count:
Error Count:
Response Code:
Response Message:
+
+
+ +
Assertion
+
+ + + + + + failure + failure + + + + + + + + +
Failure:
Error:
Failure Message:
+
+
+
+
Request
+
+ + + + + +
Method/Url:
 
Query String:
Cookies:
Request Headers:
+
+
+
Response
+
+ + + + + +
Response Headers:
Response Data:
Response File:
+
+
+ +
Screenshot
+ + + + + +
+
+
+
\ No newline at end of file