Sunday, August 16, 2009

Load Testing - Simulating Batch Jobs

Many of the production systems have the batch jobs running in the background either scheduled or unscheduled. This load is critical even though batch jobs run normally in off-peak hours. In the pre-production performance testing it is important to design a scenario simulating the batch job transaction load.

Most of the batch jobs deals with updating database tables or uploading files to the containers where the listening programs picks up to process the requests. The below explained scenario is something related to the same.

Say we have a scenario where there are 10 systems which collects user requests and stores them to get processed at the end of the day. Each system has varying number of requests to be processed at varying pace by the out bound systems/listeners.

To simulate the scenario, let's say each system has a request storage directory(x) with n files per request type and Listener pick-up directory(y).Now based on the production load, the simulator need to upload file1 from x to y, n times in the duration t resulting the production transaction per seconds.

The below code snippets do the same
  • Reads user inputs like duration (d mins), number of times to copy (n), source directory(x),destination directory(y), filename (a) from input file commands.txt
  • Copies file from source x to destination y for n times in duration of d mins
  • Checks for the file consumption at the destination y. If consumed by the listener, then does the copy and increments the success counter. If not, does not copy and also increments failure counter
  • The counters will be logged to successlog.txt and failurelog.txt and gives a final summary report showing the response of the listeners and load behaviour
Code:
  1. Folder Strucure
  2. Windows: LoadInitiator Uploader Commands
  3. Unix: Commands LoadInitiator, Uploader




Sunday, August 9, 2009

LoadTesting - VTS_MUTEX

Overview:

  • The Mutex (Mutually-exclusive-access flag) is used to achieve mutual exclusion between different virtual users in the LoadRunner script
  • Why the name VTS_MUTEX is because, this Mutex is one VTS cell data


History:

  • The reason behind the usage of Mutex is to achieve mutual exclusion between the virtual users
  • Suppose there are n virtual users for the same script (Because they use same parameter file), and needed to do a task on a single resource .This task is to be done as if one vuser is doing the task, no other vuser should perform that task irrespective of load generator on which this vuser is operating on


Description:

  • Now we have a script where this mutual exclusion to be implemented
  • This needed a Parameter file called MUTEX_PARAMETER_FILE
  • And one column of VTS should be dedicated for this mutual exclusion. Let us name it as MUTEX_VTS_COLUMN



  • Every vuser must take UNIQUE data from the table as ONCE
  • In the VTS column the 1*1 cell is the MUTEX variable
  • Now with the things are ready , we can now distribute the load
  • The logic of the implementation of Mutual exclusion will make the vusers having their data value from the parameter table will wait until the 1*1 cell data will have the same value
  • The vuser having the value from parameter table equals to the 1*1 value will enter into mutual exclusion area of the code and do the work and when he comes out of that mutually exclusive area, he will move the column values of the VTS one row up
  • Now other vuser who gets permit will enter



Below is the code template..
#include "as_web.h"
#include "vts2.h"

Action()
{
PVCI ppp;
unsigned short status;
int rc;
char *value = NULL;
char **colnames = NULL;
char **rowdata = NULL;
char *lgin=NULL;
char *tbl_parameter_value;
char *vts_col_array[7];
char *col1_2ndvalue=NULL;
int size,i,j;

lr_load_dll("vtclient.dll");
ppp = vtc_connect("127.0.0.1", 8888, VTOPT_KEEP_ALIVE);
lgin=lr_eval_string("{login}");
/*
----------------------------------------------------------------
reading data from the column 1*1 cell and waiting for the turn
----------------------------------------------------------------
*/
do
{
if ((rc = vtc_query_column(ppp, "login", 1, &value)) != 0)
{
lr_output_message("******************** VTS Error - Query Return Code = %d", rc);
}
lr_output_message("******************** %s",lgin);

}while(strcmp(value,lgin)!=0);

//---------------------------START--OF-THE--MUTEX-------------------------------------------

//-----------------BELOW--HERE-YOU-CAN-HAVE-YOUR-CODE-SECTION------------------------

tbl_parameter_value=lr_eval_string("{tblvalue}");

if ((rc = vtc_send_message(ppp, "Col2", tbl_parameter_value, &status)) != 0)
{
lr_output_message("******************** VTS Error - Send Return Code = %d", rc);
}





//------------------HERE-IS--END-OF-YOUR-CODE-SECTION------------------------

/*
-------------------------------------
this is for getting the column size
-------------------------------------
*/
vtc_column_size (ppp, "login", &size);
/*
--------------------------------------
this is to get 2nd element of the col1
--------------------------------------
*/

if ((rc = vtc_query_column(ppp, "login", 2, &col1_2ndvalue)) != 0)
{
lr_output_message("******************** VTS Error - Query Return Code = %d", rc);
}

/*
------------------------------------------------------
this is for copying from 3 to end of col1 to an array
------------------------------------------------------
*/
for( i=3;i<=size;i++) { if ((rc = vtc_query_column(ppp, "login", i, &vts_col_array[i-3])) != 0) { lr_output_message("******************** VTS Error - Query Return Code = %d", rc); } } /* -------------------------------------------------------- this is for updating from 2 to end of col1 by moving up -------------------------------------------------------- */ for( i=0;i