Thursday, November 10, 2011

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