Trigger LoadRunner scenario from Jenkins

In this blog we will see how to trigger LoadRunner Scenario from Jenkins

First we need to create a LR scenario and set the SLA configuration (mandatory) and  result settings. 

Using Command Line:

We have a provision in LR to run the scenario using Windows Command prompt by using Wlrun.exe and CLIControllerApp.exe based on the version you have.

Syntax:
LoadRunner\bin\Wlrun.exe -Run -TestPath C:\scenario.lrs -ResultName C:\ControllerResultPath\Res

LoadRunner\bin\CLIControllerApp.exe -TestPath C:\scenario.lrs -CollateAndAnalyze -ResultName C:\ControllerResultPath\Res

We will continue with Wlrun.exe example for now:

Create Jenkins projects and Go to Configure.

In Build section click on 'Add build step' dropdown and choose 'Execute Windows batch command'

Since Jenkins takes one command only, we use below syntax. Please use double quote ("")  which your path contains space (white space).

cd "C:\Program Files (x86)\HPE\LoadRunner\bin\" & Wlrun.exe -Run -TestPath "C:\Users\OneDrive - USER\Scenario\Test_Scenarios.lrs" -ResultName "C:\Users\OneDrive - USER\Result\Res"

Apply and save and you will find results update once test is completed.

Open Issue:

  • Controller wasn't launching but manually on Command prompt using same command it is launcing.
  • Below command is working on Command prompt but not in jenkins:
Call "C:\Program Files (x86)\HPE\LoadRunner\bin\Wlrun.exe" -Run -TestPath "C:\Users\OneDrive - USER\Scenario\Test_Scenarios.lrs" -ResultName "C:\Users\OneDrive - USER\Result\Res"


Using Micro Focus Application Automation Tools plugin:

Firstly you need to install the plugin and then create the project.

Go to configure and then build section.
Click on 'Add build step' dropdown and choose 'Execute Micro Focus test from file System'

You need to update Test Field with path of your Load Runner scenario and Result Directory with Result path where you want to store it.

Click on LoadRunner Setting and you may change if need.

Click Save and Apply and Test the build.

You can configure Email for failed builds as well.

Email configuration in Jenkins

Please read the following blog to install Jenkins in Windows - Jenkins Installation for Windows

We need to install below plugin for Email from install page of Jenkins - 'Email Extension Plugin'

After installation restart Jenkins and we need to first configure default Email settings.

Default Email Setting:

From Home page, go to Manage Jenkins.

Then click on Configure System.
Fill the details for Extended E-mail Notification:
  • SMTP Server: Check with your team or admin or use gmail (smtp.gmail.com)
  • Click on Advance and then fill
  • SMTP port: Check with your team or admin or use gmail (465)
  • Default Receipients - Your receipents Email ID
  • Reply To List - Your Email ID
  • Default Subject - $PROJECT_NAME - Build # $BUILD_NUMBER - $BUILD_STATUS!
  • Default Content -  $PROJECT_NAME - Build # $BUILD_NUMBER - $BUILD_STATUS:
Check console output at $BUILD_URL to view the results.

After this you can Test Email by using E-mail Notification

Provide same details as above and check 'Test configuration by sending test e-mail'

Build Email notification:

Go to your project for which you want to send Email.

Go to Configure and then Post-build Actions.

Click on button - Add post-build action

select E-mail Notification.

Fill in the details.

Customized Email for every build run:

Go to your project for which you want to send Email.

Go to Configure and then Post-build Actions.

Click on button - Add post-build action

select 'Editable E-mail Notification'

Fill the below details

Java Heap Dumps

As name suggest, Heap dumps are only for java processes.

Commands to take heap dumps:

  • jmap -dump:live,format=b,file=heap.process_name.prof <PID>
  • jmap -dump:live,format=b,file=/home/Dumps/heap.process_name.prof <PID> 

Thread Analysis:

For analysis, we can use Java VisualVM and Eclipse Memory Analyzer

Heap Dump Parameter:

-Xms          set initial Java heap size in m,g or M,G (and not MB or GB)
-Xmx          set maximum Java heap size in m,g or M,G (and not MB or GB)

Garbage Collection:
In Java, there is object life cycle as below:

  • Object creation
  • Object in use
  • Object destruction

We need to clean object to release memory else we will have heap memory reaching 100%. Garbage collection is a way in Java which happens automatically and below are the available algorithm:


  • Mark and sweep:


  • Concurrent mark sweep (CMS) garbage collection:

To use CMS GC, use below JVM argument:
-XX:+UseConcMarkSweepGC


  • Serial garbage collection:

To use Serial GC, use below JVM argument:
-XX:+UseSerialGC


  • Parallel garbage collection:

To use parallel GC, use below JVM argument:
-XX:+UseParallelGC


  • G1 garbage collection:

If you want to use in Java 7 or Java 8 machines, use JVM argument as below:
-XX:+UseG1GC

Thread Dump

Thread dumps are only for java processes.

Commands to take thread dump:

  • jstack -l  <pid> > threaddump.txt
  • kill -3 <pid>
  • jcmd <pid> Thread.print > <file-path>

Thread Analysis:

Thread dumps should be taken multiple times to get exact issue and one dump is not sufficient and may mislead the investigation. We should atleast take 3-5 thread dumps at an interval of 10 secs.30 sec or 1 minutes as per the performance issue.

To analyse, take the thread dumps and upload the files in site - fastThread Java Thread Dump Analyzer

Thread Status:

  • NEW: The thread is created but has not been processed yet.
  • RUNNABLE: The thread is occupying the CPU and processing a task. (It may be in WAITING status due to the OS's resource distribution.)
  • BLOCKED: The thread is waiting for a different thread to release its lock in order to get the monitor lock.
  • WAITING: The thread is waiting by using a wait, join or park method.
  • TIMED_WAITING: The thread is waiting by using a sleep, wait, join or park method. (The difference from WAITING is that the maximum waiting time is specified by the method parameter, and WAITING can be relieved by time as well as external changes.)