Skip to content

Commit

Permalink
added xslt feature for better functional test reports
Browse files Browse the repository at this point in the history
  • Loading branch information
Kai Lehmann committed May 4, 2023
1 parent e865bd2 commit e516f70
Show file tree
Hide file tree
Showing 4 changed files with 265 additions and 6 deletions.
7 changes: 5 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down Expand Up @@ -61,4 +61,7 @@ RUN cd /tmp/ \
&& jmeter --version \
&& PluginsManagerCMD.sh status \
&& chmod +x ${JMETER_HOME}/bin/*.sh \
&& rm -fr /tmp/*
&& rm -fr /tmp/*

# add xsl file for result transformation \
ADD ./jmeter-results2html.xsl ${JMETER_HOME}
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
15 changes: 12 additions & 3 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Loading

0 comments on commit e516f70

Please sign in to comment.