Using LoadRunner to send an email

I recently read a question on a LoadRunner user forum (http://osdir.com/ml/LR-LoadRunner/2010-08/msg00072.html) asking whether it was possible to get Loadrunner to send an email.

I started thinking how useful this could be, for example, my DBA always wants to know when a test finishes so he can restore the database on the test system. He often asks me to ring him when a test finishes. This is fine, but can be a nuisance when running a long test, for example over a weekend or evening.
Wouldn’t it be good if we could use LoadRunner to send an email when the scenario finishes?

I played around with an old DOS command line email program (BLAT).
BLAT can be downloaded here.
http://sourceforge.net/projects/blat/files/

Install BLAT into c:\blat and create a file containing your message body called Test.txt.

This command can then be used to send an email.

c:\blat\blat.exe c:\blatTest.txt -subject "Test Complete" -to name@mail.com -server mailserver.domain.com -f username@mailserver.domain.com -iu username -ipw password

The sample script in my GitHub repository will email the contents of a file with the subject line “Test Complete”. It is also possible to send email attachments using the -attach switch.

https://github.com/richardbishop/LoadRunnerSamples/tree/master/SendMail

 

LoadRunner syntax highlighting with GeSHi

Last week I can across this article by Stuart Moncrieff who looks after the myloadtest.com website.
http://www.myloadtest.com/loadrunner-syntax-highlighter/

In this article Stuart describes how he wrote a php file for GeSHi (Generic Syntax Highlighter) which highlights LoadRunner C code using the same colours as vuser generator. This has been something that I’ve wanted for ages. Whenever I do documentation describing a script, I often want to paste it into my Word document, PDF or website using the same colours as LoadRunner.

Once Stuart wrote the syntax file, I decided to give it a go. I installed it on my site and modified the sample GesHi page so that LoadRunner was the default language type. It took no time at all thanks to the good documentation provided by Stuart and the developers of GeSHi.

 

The finished results can be seen here – https://bish.co.uk/geshi/example.php
Simply paste your LoadRunner code into the empty text box and click “submit”, GeSHi does the rest for you.
If you wanted to, you could choose a different language from the drop-down list to format the code in colours relevant to a different programming language such as COBOL, delphi, java, html, php or the other languages supported by GeSHi.

Sample output:
GeSHi screenshot

Changing LoadRunner Agent to run as a process or service

During the installation of LoadRunner if you select “Allow virtual users to run on this machine without user login”, the LoadRunner agent will run as a Windows system service called “LoadRunner Agent Service”.

If you choose “Manually log in to the Load Generator “, the LoadRunner agent will be run as a process named magentproc.exe.  This means you need to start the LoadRunner agent manually each time you reboot the PC/server or you need to put the LoadRunner agent process into a windows startup group.

Some vUser types will only run if the agent is running as a service (GUI, SAP, Citrix etc.). This is because they need to run in a user context.

After installation, to switch from running the LoadRunner agent as a service to running as a process:
magentservice.exe -remove
Add this shortcut to the startup folder – “C:\Program Files (x86)\HP\LoadRunner\LAUNCH_SERVICE\bin\magentproc.exe”

After installation, to switch from running the LoadRunner agent as a process to running as a service:
Remove the LoadRunner Agent Process from the Startup folder
magentservice.exe -install

N.B. You need admin rights to do this. The magentservice.exe file is in the C:\Program Files (x86)\HP\LoadRunner\bin or C:\Program Files\HP\LoadRunner\bin folder.