Run a quick LR script in standalone mode and graph the results by checking the output log
Step 1. Windows batch (code given as text below):
"C:\loadrunner\program\HP\loadrunner\bin\mmdrv.exe" -usr "Z:\github\PerformanceTesting\scripts\mint\mint_test_script1\mint_test_script1.usr"
cp "Z:\github\PerformanceTesting\scripts\mint\mint_test_script1\output.txt" .
Step 2. Shell script (code given as text below):
grep -o "PASS: user login:" output.txt
grep -o "PASS: user login:" output.txt | wc -l
result=$(grep -o "PASS: user login:" output.txt | wc -l)
echo "result = ${result}"
if [ "$result" != "5" ]
then
echo TERMS test FAILED
else
echo TERMS test PASSED
fi
rm -f *.jtl
#EXAMPLE JTL FILE:
#<?xml version="1.0" encoding="UTF-8"?>
#<testResults version="1.2">
#<httpSample t="7789" ts="1495203777317" s="true" lb="eventTime" rc="200"/>
#</testResults>
now=$(date +%s)
now=$(($now * 1000))
echo '<?xml version="1.0" encoding="UTF-8"?>' > count.jtl
echo '<testResults version="1.2">' >> count.jtl
echo -n '<httpSample t="' >> count.jtl
echo -n "${result}" >> count.jtl
echo -n '" ts="' >> count.jtl
echo -n ${now} >> count.jtl
Note: on the next line you might want to adjust the pass/fail in the jtl file, depending on the results
echo '" s="true" lb="eventTime" rc="200"/>' >> count.jtl
echo '</testResults>' >> count.jtl
Step 3. Groovy Post Build (code given as text below -
Don't need the first line!):
if(manager.logContains(".*TERMS test PASSED.*"))
{
manager.listener.logger.println("Groovy setting build to PASSED")
manager.build.@result = hudson.model.Result.SUCCESS
}
else
{
manager.listener.logger.println("Groovy setting build to FAILED")
manager.build.@result = hudson.model.Result.FAILURE
}
Step 4. Trend Graphs (code given as text below):
**/*.jtl
5
10
Results: (Quick example):
Last run failed (because the last count was 4 rather than the expected 5):