LoadRunner Bash for Continuous Integration

I'm going to compile a few ideas here that I find useful for developing quick script solutions, particularly for my newer CI approaches.

This page may be a bit messy and you may need to search for various terms to find the code you are after. This is just a notepad for my use.

Concentrating here on various BASH scripts that I use in my Jenkins LR solutions that can be found on this site. In particular, I have methods to run several analysis sessions, so we can come in after a weekend of automated testing to different percentile reports (in particular) for a complex services test run.

Second, I look at adjusting analysis reports, to exclude various sections, live, for variable reports for different development teams and setups.

1. Running several analysis sessions after one CI test run

I want several reports available here, to highlight different transaction percentiles, in particular, 85th, 90th and 95th percentiles. This is for various development teams that are not so happy with one flat number to consider during their services development. E.g.:


Code snippet for this:

lrr_location=$(grep 'result folder to' ${xml_file} | tail -1 | awk 'BEGIN {FS="result folder to "} {print $2}')

sleep 60
echo lets get 90th percentiles:
/cygdrive/c/Program\ Files\ \(x86\)/HP/LoadRunner/bin/AnalysisUI.exe -RESULTPATH "${res}" -TEMPLATENAME MyTemplate9

(see below for more details)

I'm going to put my Jenkins script here in full, but do be aware you may have to change it for your needs. We get the location of the analysis file from the SLA XML file that the LoadRunner Jenkins plugin creates. We can then run further analysis sessions on this file, as per below. Also, note, we only archive one of these sessions. After some testing, it was found that each session is complete, so we only need one of them to do any further analysis work required, with the standard LoadRunner analysis tool.

I've attached my 3 analysis templates but do be aware they are basic: I am just after the percentiles in the standard report.

Percentile85_template Percentile90_template Percentile95_template

    echo $PATH
    echo $PATH
    cd "${WORKSPACE}"
    echo "workspace ="
    echo "run sla bash"
    stepname="27." ./
    echo save lrr location to disk for next step
    xml_file=$(ls -rt1 *.xml|tail -1)
    grep 'result folder to' ${xml_file} | tail -1 | awk 'BEGIN {FS="result folder to "} {print $2}' > lrr_location.txt
    cat lrr_location.txt

    if [ -s lrr_location.txt ]; then
       res_folder=$(grep 'result folder to' ${xml_file} | tail -1 | awk 'BEGIN {FS="result folder to "} {print $2}')
       echo $res_folder

       lrr_location=$(grep 'result folder to' ${xml_file} | tail -1 | awk 'BEGIN {FS="result folder to "} {print $2}')
       res=$(grep 'launcher with arguments : ' ${xml_file} | tail -1 | awk 'BEGIN {FS="launcher with arguments : \""} {print $2}'  | awk 'BEGIN {FS="\" "} {print $1}')
       echo ${res}

       echo lets get 85th percentiles:
       /cygdrive/c/Program\ Files\ \(x86\)/HP/LoadRunner/bin/AnalysisUI.exe -RESULTPATH "${res}" -TEMPLATENAME MyTemplate5
       sleep 60
       echo lets get 90th percentiles:
       /cygdrive/c/Program\ Files\ \(x86\)/HP/LoadRunner/bin/AnalysisUI.exe -RESULTPATH "${res}" -TEMPLATENAME MyTemplate9
       sleep 60
       echo lets get 95th percentiles:
       /cygdrive/c/Program\ Files\ \(x86\)/HP/LoadRunner/bin/AnalysisUI.exe -RESULTPATH "${res}" -TEMPLATENAME MyTemplate4

       sleep 10
       mv "${res_folder}/Report85" .
       mv "${res_folder}/Report85.html" .
       mv "${res_folder}/Report90" .
       mv "${res_folder}/Report90.html" .
       mv "${res_folder}/Report95" .
       mv "${res_folder}/Report95.html" .
       mv "${res_folder}/Session85" .
       #don't need all 3 of these archived: mv "${res_folder}/Session90" .
       #don't need all 3 of these archived: mv "${res_folder}/Session95" .
       echo cannot find lrr_location. exiting script.


2. Controlling general analysis settings, such as scenario times to include in the analysis session

The method presented here allows the user (or the Jenkins job) to control general analysis preferences, across any subsequent test runs.

This is achieved by editing the overall settings of the LoadRunner Analysis tool on the machine. These settings, stored in an ini file are set for any subsequent analysis runs carried out on the machine, so some care must be exercised in it's general use.

Below is my initial BASH script which was then placed in Jenkins with Jenkins variables added to set three thing:

FilterEdge=0 or FilterEdge=1



The first line above sets whether or not we adjust the scenario time scales at all: 0 = no, just use the whole scenario, 1 = yes, do not include the start time before the value set or the end time AFTER the value set (seconds into the scenario from the start)

The script below then adjusted these settings appropriately. A colleague of mine needs this to take out of his analysis the ramp up and ramp down sections of his scenarios. Thus, particular Jenkins jobs set the values depending on the scenario used and subsequent analysis sessions (including the automated ones given above) then exclude fixed periods from the start and end of the analysis. Thus the developers get exactly the numbers they are after, even after fully automated CI test runs:

    echo $PATH
    echo $PATH
    cd /cygdrive/c/Program\ Files\ \(x86\)/HP/LoadRunner/config/
    echo ===== BEFORE ================================================ BEFORE ===============
    cat LRAnalysis80.ini
    echo ====================================================================
    F1=$(grep FilterEdge LRAnalysis80.ini)
    echo $F1
    echo $F2
    sed -i s/"$F1"/"$F2"/ LRAnalysis80.ini

    #start time
    F3=$(grep FSartTime LRAnalysis80.ini)
    echo $F3
    echo $F4
    sed -i s/"$F3"/"$F4"/ LRAnalysis80.ini

    #end time
    F5=$(grep FEndTime LRAnalysis80.ini)
    echo $F5
    echo $F6
    sed -i s/"$F5"/"$F6"/ LRAnalysis80.ini

    echo ===== AFTER =============================================== AFTER ================
    cat LRAnalysis80.ini
    echo ====================================================================





[Home] [About (CV)] [Contact Us] [JMeter Cloud] [webPageTest] [_64 images] [asset moniitor] [Linux Monitor] [Splunk ETL] [Splunk API] [AWS bash] [LR Rules OK] [LR Slave] [LR CI Graphs] [LoadRunner CI] [LR CI Variables] [LR Bamboo] [LR Methods] [LR CI BASH] [Bash methods] [Jenkins V2] [Streaming vid] [How fast] [Finding Issues] [Reporting] [Hand over] [VB Scripts] [JMeter tips] [JMeter RAW] [Dynatrace] [Documents] [FAQ] [Legal]

In the Cartesian Elements Ltd group of companies