Archive

Archive for the ‘LoadRunner’ Category

Don’t waste your time

April 19th, 2009

Waste time in Load Runner is a time spend on tasks that normal browser user wouldn’t perform like storing test results, performance monitoring, calculations, etc. Wasted time is measured by LR automatically but sometimes it is necessary to use it explicitly through lr_wasted_time() function .

lr_wasted_times() removes time from all open transaction. If you want to make some calculation and don’t count them into overall transaction time then you should use this function.

Small example

  1. Action()
  2. {
  3.         merc_timer_handle_t timer;
  4.         long i;
  5.         double wastedTime;
  6.  
  7.         lr_start_transaction("My_Transaction");
  8.         timer = lr_start_timer();
  9.         for(i = 0; i < 1000; i++)
  10.                 lr_message("%d\n", i);
  11.         wastedTime = lr_end_timer(timer);
  12.         wastedTime*=1000;
  13.  
  14.         lr_wasted_time(wastedTime);
  15.  
  16.         lr_end_transaction("My_Transaction", LR_AUTO);
  17.         lr_message("Wasted %lf milliseconds", wastedTime);
  18.         return 0;
  19. }

On line 7 I’m starting one transaction. On line 8 I’m starting timer and stoping it at line 11. For loop between is used to generate my wasted time. After stopping the time, we need to subtract wasted time from open transaction by calling lr_wasted_time() on line 14. But before that on line 12 we need to change time units. lr_end_timer() returns time in seconds but lr_wasted_time() takes time in milliseconds. Thats why we need to multiply it by 1000. There is one more think. lr_wasted_time() is defined as

  1. void lr_wasted_time (long wasteTime);

If you use long type variable to measure wasted time you will always get rounded results (e.g. 1000, 2000, 3000). Instead it is better to use double type variable so at the end the results are more precise.

LoadRunner , ,

Running LoadRunner scenarios from QualityCenter automatically

February 25th, 2009

There is a very nice tool provided by HP Support that allows running few LoadRunner scenarios from QualityCenter using command line. You can use it to run load tests in regression every night for example.

Officially HP doesn’t support this small tool and they say it’s free and open source. There are two versions available. One for QC 9.0 and another for QC 8.2 SP1. If you want to find it on HP support page, just search for document ID KM191021.

cpt38343a – this is my local mirror for QC 9.0 version

LoadRunner ,

IBM WebSphere MQ testing using LoadRunner

February 23rd, 2009

My first script for WebSphere MQ testing was written in Java as Java Vuser script. It was pretty simple since I was using just MQ JMS API.  There is lots of examples howto connect to WebSphere in Java. Here is one http://hursleyonwmq.wordpress.com/2007/05/29/simplest-sample-applications-using-websphere-mq-jms/.

But howto test WebSphere MQ if you don’t have Java license in you LoadRunner?

There is a way to do that. LoadRunner API contains several JMS functions:

jms_receive_message_queue()
jms_send_message_queue()
jms_send_receive_message_queue()
jms_set_general_property()
jms_set_message_property()

First of all you need to have “Web Services” license to use them.

Here is what you need to do:

  • Get details of your environment like: MQ server IP, port (probably 1414), Queue Manager name, Queue name and channel name.
    Install IBM WebSphere MQ Client on machine where you have LoadRunner Controller (or LoadRunner Generator if you are using remote one). MQ Windows Client for WebSphere 6.0 can be downloaded here.
  • Setup details of our WebSphere MQ server on the client. We will use JNDI to store connection details (host, port, etc…)
  • Edit file C:\Program Files\IBM\WebSphere MQ\Java\bin\JMSAdmin.config and set

INITIAL_CONTEXT_FACTORY=com.sun.jndi.fscontext.RefFSContextFactory
PROVIDER_URL=file:/C:/JNDI

  • Create new .scp file and put there your MQ server details. Here an example

DELETE QCF(QueueConnectionFactory)
DEFINE QCF(QueueConnectionFactory) QMGR(QUEUE_MANAGER) tran(client) chan(SYSTEM.ADMIN.SVRCONN) host(192.168.12.13) port(1414)
DISPLAY QCF(QueueConnectionFactory)
DEFINE Q(MY_QUEUE) QUEUE(MY_QUEUE) QMGR(QUEUE_MANAGER)
DISPLAY Q(MY_QUEUE)
end

  • Last step for MQ Client is to generate .bindings file (placed automatically in C:/JNDI) with JMSAdmin tool from C:\Program Files\IBM\WebSphere MQ\Java\bin directory. Assuming that your .scp file is named My_qm.scp, use this command:

JMSAdmin < My_qm.scp

Now in LoadRunner:

  • Create new Web Services script
  • Open Run-Time settings (F4) and go to JMS/Advanced
  • Change JNDI initial context factory to “com.sun.jndi.fscontext.RefFSContextFactory”
  • Change JNDI provider URL to “file:/C:/JNDI”
  • Change JMS connection factory to “QueueConnectionFactory” and click OK

Use this sample code to send and receive a message from IBM WebSphere MQ:

//setting JMS message property JmsMessageID
jms_set_message_property("JMSMessageID","JMSMessageID", "12345");

//sending message
jms_send_message_queue("Sending message","My cool message", "MY_QUEUE");

//receiving message
jms_receive_message_queue("Receiving message", "MY_QUEUE");

//displaying message
lr_message(lr_eval_string("{JMS_message}"));

Received message is saved in “JMS_message” parameter automatically by LoadRunner.

Done. Smart and simple :)

LoadRunner , , ,

Cleaning browser cache

February 16th, 2009

Hello

As you know, browser can store some downloaded HTML/JPG/etc file from remote server on local hard drive so you can access it faster next time. This is called “cache”.

There is an option in LoadRunner VuGen to simulate browser cache behavior with your web performance testing. But how to use it and when? Here are my suggestions.

Don’t clean the cache
Your application is rather something internal used by (mostly) the same people in one company – In that case I suggest not to clean the cache because this will reflect users behavior in your tests. If you ask why? then ask yourself how often you clean your browser cache. Once a week? Once a month? Every login/logout? Are you getting the idea?

With such settings, your transaction performance graph would look like this:

without_cache_cleaning1

After first iteration with cache enabled, transaction performance is much smaller. It’s because user gets most of the files from the cache.

Clean the cache:
Your application is accessible from the Internet, and your customers are basically everyones on the net – in that case I suggest to clean the cache because its more probable to have new person without cached content already.

This is example performance graph after tests with cleaning browser cache.

with_cache_cleaning1

In each iteration, user has empty cache at the beginning so he need to get all the files from remote server.

Conclusion:

Only by cleaning/not cleaning the cache your transaction performance can vary significantly!!!

LoadRunner , , , ,

Web Services performance using LoadRunner HTTP Vuser script

January 24th, 2009

Small (basic) example howto test performance of Web Service using LoadRunner API.

Let say we have a web services that uses SOAP over HTTP. We want to check how fast we can send a request and receive a response.  Because our service uses HTTP as a transport protocol, we are able to test it using simple HTTP Vuser script.

Here is the C code:

  1. Action()
  2. {
  3.    web_reg_save_param("Response","LB=", "RB=", LAST);
  4.    web_add_header("SOAPAction", "SampleMethod");
  5.    lr_start_transaction("REQ");
  6.    web_custom_request("Sample_Request","Method=POST",
  7.          "Mode=HTML",
  8.          "RecContentType=text/xml",
  9.          "EncType=text/xml; charset=utf-8",
  10.          "URL=http://example.com:1234/sample/",
  11.          "Body=<Envelope xmlns=\"http://example.com/sample\">\n"
  12.                "   <Header/>\n"
  13.                "   <Body>\n"
  14.                "      <price><id>001</id></price>\n"
  15.                "   </Body>\n"
  16.                "</Envelope>",
  17.    "LAST");
  18.    lr_end_transaction("REQ", LR_AUTO);
  19.    lr_output_message("Response is : %s\n", lr_eval_string("{Response}"));
  20.    return 0;
  21. }

Have a fun…

LoadRunner

How to crash LoadRunner 9.0 in 5 steps

January 15th, 2009

I’ve found it during playing with latest LR version. Steps to reproduce:

  • Open controller
  • Create new goal oriented scenario
  • edit goal type and select “Virtual Users” goal
  • set 0 (zero) as amount of Vusers to reach
  • click OK

Done. LR crashes without any error message, without completely anything. And I thought  boundary value testing is something basic… :/

P.S. This bug is already reported to HP.

LoadRunner , ,