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

No comments:

Post a Comment