Thursday, November 10, 2011

Understanding Snapshot Attribute in LoadRunner

A snapshot is a graphical representation of the current step and it is an Attribute to functions like Web_URL, web_custom_request etc in LoadRunner

A Sample request is shown below

web_custom_request("Sample_Request",
"URL=http://… /Service",
"Method=POST",
"Resource=0",
"RecContentType=text/xml",
"Mode=HTML",
"Snapshot=t1.inf", //Snapshot attribute is commented
"EncType=text/xml; charset=utf-8",
"Body="
LAST);

When working in Tree view, VuGen displays the snapshot of the selected step in the right pane (as Shown Below). The snapshot shows the client window after the step was executed.(Refer Snapshot)

LoadRunner Snapshot

VuGen captures a base snapshot during recording and another one during replay. You compare the Record and Replay snapshots to determine the dynamic values that need to be correlated in order to run the script.

If Snapshot Attribute is not placed in the request, then Image file will not be generated during the replay(Refer Snapshot).

web_custom_request("Sample_Request",
"URL=http://… /Service",
"Method=POST",
"Resource=0",
"RecContentType=text/xml",
"Mode=HTML",
"EncType=text/xml; charset=utf-8",
"Body="
LAST);

LoadRunner Snapshot

Tutorial on Rational Performance Tester

A Very good tutorial on Rational Performance tester (RPT). This tutorial includes

  • Rational Performance Tester: Architecture
  • Rational Performance Tester: Features
  • RPT and the Performance Testing Framework (PTF)
  • Rational Performance Tester: Test Development
  • Rational Performance Tester: Workload Design
  • Rational Performance Tester: Reports
    and more

http://docs.google.com/present/edit?id=0ATOftuUbGkRvZGR3bTkyZGRfNTRncTU2ZGdkYg&hl=en

Little's Law

In continuation with my earlier post “Decoding concepts of Performance Engineering” I will try to derive Little's law in this post for better understanding

Consider a steady state system which has only one user and sends the requests at consistant intervals and response time of the requests were observed to be 1 sec.

No of Customers in the System = 1
Response Time = 1 sec (Service Demand)
So Maximum Throughput = (1/Service Demand) = 1 Request/Sec (Based on Utilization Law)

It implies average number of customers required being in the system to achieve 1 request/ sec with an average response time is 1 sec is 1 user

Similarly assume if the response time of the system is 0.1 Sec

Response time = 0.1
Max Throughput = 1/Service Demand = 10 requests/Sec

So One single user can simulate max of 10 requests/sec with a average response time of 0.1 sec

Little's Law






Average Number of Customers = Response time * Throughput

Little’s Law states that average number of customers in a system is equal to product of throughput and response time.

Decoding concepts of Performance Engineering

In most of the situations we have a tendency of using the formula’s without understanding the concepts behind it, because of which we may not be able to apply the laws correctly where it is required.

The following example will help in understanding the some of the performance rules

A system was subjected to 10 requests in a span of 2 min and got the responses for all requests during this period and Utilization of the system during the time frame was observed to be at 50%.


Request Arrival rate for that system is  10/2=5 requests/Min
Throughput = 10/2 = 5 Responses/Min


in the above example, system utilized 50% of its resources for serving 5 requests. For Each request, it consumed 50%/5 of system resources. This value is called service demand of that resource


From the above example the formula for service demand can be derived as below
Service Demand  =Utilization/Throughput.
similarly Utilization = Throughput * Service Demand - This is also called utilization Law


The utilization of a resource is equal to the product of the throughput of that resource and the average service demand at that resource.

Extracting LoadRunner Error messages based on Scripts

Sample C# code to fetch the LoadRunner Error messages based on Scripts using MS Access mdb file

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.OleDb;
using System.Data.SqlClient;


namespace LR_transaction
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new Form1());
        }
        private void button1_Click(object sender, EventArgs e)
        {
      
            //Create the database connection 
  
            OleDbConnection aConnection = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=d:\\abc.mdb");

            //create the command object and store the sql query 

            OleDbCommand aCommand = new OleDbCommand("select [ErrorMessage].[Error Message] from ErrorMessage where [ErrorMessage].[Error Id] in(select [Error_Meter].[Error Id] from Error_Meter where [Error_Meter].[Script Id] in (select [Script].[Script ID] from Script))", aConnection);          
            try
            {
                aConnection.Open();

                //create the datareader object to connect to table 
                OleDbDataReader aReader = aCommand.ExecuteReader();
                Console.WriteLine("This is the returned data from the table");

                //Iterate throuth the database 
                while (aReader.Read())
                {
                       MessageBox.Show(aReader.GetString(0));
                               
                }
              
                //close the reader 
                aReader.Close();
    
                //close the connection Its important. 
                aConnection.Close();
                Console.Read();

            }

            //Some usual exception handling
            catch (OleDbException ex)
            {
                Console.WriteLine("Error: {0}", ex.Errors[0].Message);
            }
        }


     }
}

Integrating Sitescope Monitor with Controller


To integrate a SiteScope server that needs authentication, modify the modify the LR installation folder\dat\monitors\xmlmonitorshared.ini file as follows:

1. Locate the [SiteScope] section in the file.

2. Append &account=administrator, or if you want to log in using other user (e.g., XXX), append &account=XXX, to the MetricListURL.

Note:
The user XXX must have the right permissions in SiteScope and may be different from the user name. The SiteScope server should be accessed as


3. Add "QueryLoginInfo=1" at the end of the section.

With this, you should be able to see a login window when adding measurements.

Monday, November 7, 2011

Simulating SOAP messages via JMS in LoadRunner using Web Services Protocol

Web services facilitate application to application communication for building integrated systems of web application components and HTTP is the most standard transport protocol used for the communication but it will be difficult to send messages from one subsystem to many using HTTP. Sending SOAP messages via JMS is a viable and a simple option for such requirements.


JMS is a J2EE standard for sending messages, either text or Java objects, between Java clients.


There are two scenarios for communication:


Point-to-Point. JMS implements point-to-point messaging by defining a message queue as the target for a message. Multiple senders send messages to a message queue, and the receiver gets the message from the queue.


Publish-Subscribe. Each message is sent from one publisher to many subscribers through a designated topic. The subscribers only receive messages sent after they have subscribed.


LoadRunner supports both the communication but I will focus sending SOAP over JMS point-to-point communication using LoadRunner in this post.


Vugen supports point to point by allowing you to send and receive JMS messages to and from a queue.


Please follow the steps to simulate JMS traffic to TIBCO in LoadRunner


       1.    Install JDK and set the class path accordingly

       2.    Download TIBCOjms.jar file from the application support team and set the class path of the jar in VUGEN- Runtime settings – Classpath

       3.    Request your application team to provide the following details and update in  Runtime settings

a.    JNDI Initial Context Factory - com.tibco.tibjms.naming.TibjmsInitialContextFactory (For Tibco)

b.    JNDI Provider URL

c.     JNDI Context Factory

d.    Credentials(userid/Password)


       4.    Create a Sample script to verify the connection


Action{

char text[100];

strcpy(text,"Sample Message to be Send to TIBCO");

lr_output_message("%s text is ", text);

//sending message

jms_send_message_queue("Sending message",text, "QueueName");

return 0;

}

JMS Runtime Settings for Point-to-Point
JMS Runtime Settings

How to start rstatd Demon process in Solaris 10

The following command will help you in starting rstatd Demon process

bash-3.2$ /usr/lib/netsvc/rstat/rpc.rstatd start

Verify the process is up or not using the following command
-bash-3.2$ rup tib(HostName)
tibq2 up 261 days, 14:14, load average: 5.73, 9.21, 10.74

Sending Emails using Blat utility in LoadRunner

If there is any requirement where you may have to send hundreds of emails to the server then one option is to use a web email client to simulate the load but it has following limitations

1. Your own corporate/personal Email id need to be used in LoadRunner Script but it may fill up the mail box

2. Password credentials need to be made visible in the script.

Other option is to use Blat utility which is a third party freeware utility. It sends the contents of a file in an e-mail message using the SMTP protocol.

Download the attached blat.dll utility and create a sample script as shown below.


Action()

{
command_line_Send = (char *)malloc(1024 * sizeof(char));

if(CheckLoadBlatDLL != 0) //if return code not zero then DLL not loaded!!Reload it
{
    lr_output_message("BLAT Emailing DLL Not Loaded Successfully !!! Reloading the DLL");
    CheckLoadBlatDLL = lr_load_dll("blat.dll");
}
f1=fopen(lr_eval_string("C:\\SR_{vuser_id}.txt"), "wb+" );
fprintf(f1,lr_eval_string("Email Performace Testing {TimeStamp}"));
fclose(f1);

//Initialize all the command line parameters for Blat tool

strcpy(DestEmailID,lr_eval_string("{EmailId} ")); // Destination Email ID
strcpy(Subject,lr_eval_string("\"Email PerfTesting{TimeStamp}\" ")); // EmailID Subject
strcpy(SMTPServer,lr_eval_string("{SMTPServer}")); //Your Corporate SMTP Server
strcpy(FromEmailID,lr_eval_string("{FromEmailID} "));// Source Email Id
strcpy(AttachFile,"C:\\attach.pdf "); // Any attachment
strcpy(BodyText,lr_eval_string("C:\\SampleBody{vuser_id}.txt "));// Email Body
lr_output_message("The Destination EmailId is :%s",lr_eval_string("{EmailId}"));

//Verify whether DLL Loaded successfully

if (CheckLoadBlatDLL == 0) //if return code not zero then not DLL not loaded
{
    lr_output_message("BLAT Emailing DLL Loaded Successfully ");
    // Build the Command line for sending Emails
    strcpy( command_line_Send, BodyText);
    // strcat( command_line_Send, "-attach ");
    //strcat( command_line_Send, AttachFile);
    strcat( command_line_Send, "-to ");
    strcat( command_line_Send, DestEmailID);
    strcat( command_line_Send, "-f ");
    strcat( command_line_Send, FromEmailID);
    strcat( command_line_Send, "-s ");
    strcat( command_line_Send, Subject);
    strcat( command_line_Send, "-server ");
    strcat( command_line_Send, SMTPServer);
    lr_output_message("Parameters for Send Command : %s", command_line_Send);
    temp_error_code = Send(command_line_Send);
    lr_output_message("Return code of Send command %d " , temp_error_code);
  //Check successful message sending.
   if (temp_error_code == 0) {
      lr_output_message("Email Sent Successfully ");
   }
  if(temp_error_code != 0){
  switch( temp_error_code ){
  case 1:
   //Command Line Bad Argument
   //Unable to open SMTP socket
   //Command unable to write to socket
   //Server does not like To: address
   // Mail server error accepting message data
   lr_error_message("ERROR : Check the command Line Argument Format");
   break;
  case 2:
   //The server actively denied our connection.
   //The mail server doesn't like the sender name.
   lr_error_message("ERROR : Email Server Denied connection or File does not exist");
   break;
   }//end SWITCH
 }//end IF
}else{
  lr_output_message("Unable to Load the Blat DLL - Check whether DLL exists at the specified location ");
}
free(command_line_Send);
return 0;
}

Performance Testing in Cloud

A factor which needs to consider while defining performance strategy in Cloud

Elasticity
:

Elasticity is the ability to scale up your system resources when needed, and scale down when not required. Here are two important measures of cloud elasticity: spin-up elasticity and spin-down elasticity.


Load testing always consider peak load scenarios while measuring the system performance where as in cloud we may also have to consider Peak, moderate and low level usage of transactions. Base lining the System performance under these various loads will help the administrator to take a decision while scaling up or scaling down the resources based on load.


Scalability


Scalability is the ability of an application to handle increased processing demand with increase of load.


Testing the scalability of an application is very important; if the application is not scalable then the elasticity of the cloud can actually cost thousands of dollars. When moving to the cloud, it becomes even important to test the applications and to tune them properly so they are optimized when it comes to hardware consumption


Bandwidth


Usually Cloud Providers are distributed across different geographical locations. Bandwidth testing using tools like Shunra Cloud will help to ensure bandwidth requirements between the endusers and the cloud provider


Some Cloud Platform providers provide the following usage information of your application this can also be used as a basis while defining performance strategy


• CPU


• Memory


• # of DML statements


• # web service calls


• # Calculations

How to determine the speed of network during a load test using LoadRunner


Sometimes problems in the Network can impact load test results. It is important to monitor the rate at which data is received from the server in a Network.

LoadRunner can help you in determining the bandwidth used during a load test. Web Page Diagnostics Graphs in LoadRunner provides drill down analysis across different layers.

Network bandwidth by a Component = Component Size/ Component Receive Time

Component Receive Time is the Time to transfer between the first byte to the last byte arrives from the server and Component Size is the size of component downloaded from the server.

In the below Example Network speed during the test is 263.249/1.132 = 232 KB/sec. This speed may slight vary from component to component and also based on Load Generators used for the test
Web page diagnostics