Today I am creating a jMeter test in Bamboo. Of course, you can also implement this test setup with Gitlab runners or Jenkins slaves.
Step 1: Create jMeter test
The first thing to do, of course, is to create a jMeter test. I downloaded jMeter from the following url https://jmeter.apache.org/ and started it with this command:
$ java -jar bin/ApacheJMeter.jar
I save with the JMX file for my Bamboo task.
Step 2: Prepare Bamboo Agent
Since Java is the prerequisite for Bamboo agents, I only post-install Python.
$ apt-get update
$ apt-get install python
And paste this shell script:
#!/bin/bash
java -jar /tools/apache-jmeter-5.4.1/bin/ApacheJMeter.jar -n -t test.jmx -l requests.log > result.log
echo "Ergebnis:"
cat result.log
if cat result.log | python /tools/check.py > /dev/null;
then
echo "Proceed... Alles Prima!"
exit 0
else
echo "Returned an error.... Oje!"
exit 1
fi
The tool directory is fixed on the machine and not part of the project repository. Additionally I use this Python script:
#!/usr/bin/python
import re
import sys
for line in sys.stdin:
print line,
match = re.search('summary =[\s].*Err:[ ]{0,10}([1-9]\d{0,10})[ ].*',line)
print 'Check in line if Err: > 0 -> if so Error occured -> Test fails: '
print match
if match :
print "exit 1"
sys.exit(1)
print "nothing found - exit 0"
sys.exit(0)
I also create an artifact pattern for the result logs.
Ready!
Now I can run my job. After I changed the timeouts, the test is also “green”.