Fork me on GitHub

Herr Knedel/Cool things with Atlassian: using Bamboo and jMeter without plugins

Created Sun, 21 Mar 2021 00:00:00 +0000 Modified Mon, 28 Mar 2022 18:11:33 +0000 Difficulty level: Not too easy and not too hard

275 Words

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:

x
+
Terminal

$ java -jar bin/ApacheJMeter.jar

See:My demo test for this tutorial is intended to contain buggy and working samplers. I set the timeouts very low on purpose. 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.

x
+
Terminal

$ apt-get update
$ apt-get install python

I create a new job and a shell task. 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”.