Saturday, 27 August 2016

IP spoofing in loadrunner vugen and performance center

IP of client machine's is identity used by Servers and Network devices like routers to recognize them and then to cache the information and optimize themselves.
Sometimes we need to use different IPs to emulate the real world scenarios to make servers and devices see as if users are coming from different sources.

But this task is not simple.

Our job here is to fool the devices and it requires three simple steps:

1. Run IP Wizard (Start > Program Files > LoadRunner > Tools > IP Wizard) on LG to add the IPs you want to emulate in scenario.

2. Update the server’s routing table with new IPs, this is done so that servers are able trace back to the client. If client and server are in same network and subnet mask then not need of modification is required.
To update the table edit the batch file in IP wizard summary use route command as below to update:
“route ADD [IPs you want to add] MASK 255.255.255.255 [Your_IP] METRIC1”
“route ADD [IPs you want to add] MASK 255.255.255.255 [Your_IP] METRIC2”
Now run this .bat file on server to update.

3. Enable IP Spoofing ( Scenario > Enable IP Spoofer ) from Controller, before connecting to LG.

Thursday, 11 August 2016

Replace function used Vugen scripts

char *strSource;

void Replace( char *strSource, char *strFrom, char *strTo, char *strParam)
{

   char strTemp[1024];

char *s= (char *)strSource;
int i=0;
int iLenFrom = strlen (strFrom);

int iLenTo = strlen(strTo);

while(*s)
{

if(strncmp (s,strFrom, iLenFrom) ==0)
{

strncpy(&(strTemp[i]), strTo, iLenTo);
i+=iLenTo;
s+ =iLenFrom;
}

else
{
  strTemp[i++] =*s;
s++;
}


}


strTemp[i] =0;
lr_save_string(strTemp,strParam);

}


//how  to call replace function

strSource= lr_eval_string("{c_ESS}");

lr_save_string(strSource,"c_ESS_New");

Replace(strSource,"&#x21", "!","c_ESS_New");





Tuesday, 5 July 2016

Server has shut down the connection prematurely

Server has shut down the connection prematurely

First thing "Server xyz has shut down the connection prematurely " is not a webserver issue.
This is purely loadrunner issue and is one of the major pain area.

Solutions:
1. Make sure we are not ramping up all user simultaneously
2. Rendez point are not holding up too many users.
3. Make sure retry option is greater than 5
4. Check network connectivity or blockage.
5. Decrease the load from loadrunner machine
6. Clear the Temp folder in (Documents and Settings-->user-->Local Settings)-->Temp
    and restart the machine on which loadrunner is installed (This one is my favorite, it has always helped me in getting rid from this error, but the condition is that scripts ran successfully before and now you suddenly start seeing this error)
7. If above solution also doesn't work then, Recently I observed that if we suddenly start seeing this issue, then best option is to restart all machines and servers in your network or load test domain (after following point No. 6) .

Put this in script, not a solution but just the workaround, you will not see error, but issue will still exist
web_set_sockets_option ("NEW_BEHAVIOR_OF_OVERLAPPED_SEND", "1");
If none of the above option helps then put web_set_sockets_option("IGNORE_PREMATURE_SHUTDOWN", "1");  in vuser_init()

You can also try following
Run time settings --> Preferences --> Use WinInet Replay instead of Sockets (windows only)
but it worked in very specific cases. Not a general solution.

Friday, 17 June 2016

How to put strtok function in a vugen script


put the logic after the co-related string

strtok is used when you get a long value from load runner seperated by delimiters for example,( and you want to seperate each value from the delimiters

logic()
{

extern char *strtok(char * string,const char * delimiters); // explicit declaration

char seperators[]= "(,";

char *token;

char c[100];
char * a[100];
char * d[100];
int i=0;

strcpy(c,lr_eval_string("{c_ContentGUID}"));

token= (char *) strtok(c,seperators); //Get the first token

if(!token)
{

lr_output_message("No token found in the string");

return (-1);

}

for(i=0; token !=NULL;i++)
{
 a[i]=token;

lr_output_message("%s", a[i]);

token= (char *) strtok(c,seperators); // get the next token

}

lr_save_string( a[6],"c_ContentGUID");

lr_save_string( a[5],"c_fgfgh");

lr_save_string( a[2],"c_xyz");
lr_save_string( a[1],"c_sret");

lr_output_message("c_ContentGUID : %s", lr_eval_string("{c_ContentGUID}"));


return 0;

}


Tuesday, 14 June 2016

WEB services Soap UI

Web services is a way of communication between two softwares .

For example Software one calling to a function of another software

medium will be Internel/LAN and http protocol, and i/p and o/p will be saved in SOAP(Simple object Access protocol)

Client is service consumer and server is service provider, to access the server you should know the location of the webservices server and information about the server functions.


If service provider knows the client,it will directly give the xml(WSDL file)

second way is through UDDI,first all the service provide register on UDDI

Server->xml(WSDL)->UDDI->xml(UDDI)->Client

WEB services are two types

1.SOAP based
2. REST based

In REST client send a request to server using URI and server return the response in terms of resources for example-HTML,plain test etc


How to save vugen co-related value in a file


In case you face such scenario in which you need to save your co-related value in a file.

For example

web_reg_save_param("c_Incident","LB=abc", "RB=def", LAST);

// call this function wherever you want to save your co-related value
writeInfoToFile();

void writeInfoToFile();
{
           long File_Stream;
Char *Filename="D:\\Incident.txt";
//Open the file with read access

If((File_Stream= Fopen(Filename,"a+"))==NULL)
{
lr_error_message("Can't open %s ", Filename);
}

fprintf(File_Stream,"\r\n%s", lr_eval_string("{c_Incident}"));


//Close the file
If(fclose (File_stream))
{
 lr_error_message(error close file %s ",Filename);
}
}

Monday, 25 May 2015

ITSM BMC Scripting ARS 8.1 with HP Load Runner

 I recently worked in ITSM BMC project scripts for the BMC Remedy Action Request System 8.1. This blog contains some of the things that I learnt.
BMC people doesn't recommend using HP Loadrunner for scripting their application because they have their own tool and they say its impossible to script ARS with Vugen. Even HP doesn't support this but believe me its very easy.
So in our project we didn't have any ADM support and neither from HP guys.



First thing which is very important to keep in mind for this is your test data length should be equal. Ask from your data provider team to give such data which is equal in length.
For example Username=1186612 and Password=Justin
So for second username=1175512 and Password=Justin
 As you are running a Performance test and will be requiring a lot of User ID's So Username should be of same length like in this example its seven and password should be same for all the virtual Users as password comes in encrypted format .

Recording and Script Generation

Remedy ARS has both a Win32 client and a web-based client. The Win32 client communicates with the server using a proprietary protocol that is not supported by VuGen. Traffic can be recorded using the Windows Sockets vuser type, but the data is in an unintelligible binary format (just because you can record an application with Winsock doesn’t mean you should try to create a script using it).
Record by URL mode and go to advance options and set web_custom_requests only. Dont select concurrent group options as for some transaction it will record nothing.
Note that it might be possible to configure VuGen to record ARS by using the VuGen protocol development kit, and referring to the ARS API documentation, but time limitations prevented me from experimenting with this.
When recording, you must either use URL mode (so that each HTTP request is a separate function call), or change your recording settings to treat the MIME type “text/plain” as a non-resource (Recording Options > HTTP Properties > Advanced > Non-Resources). This will ensure that the calls to BackChannel are not recorded as EXTRARES.
VuGen 11.5 when generating code for the BackChannel requests. These appear as a web_custom_request with “Method=GET”, and have a body with values in it.

Backchannel Requests

You may have already guessed that BackChannel requests are kind of important for ARS. These requests are sent behind the scenes to fetch data to display in the GUI and to update data on the server. This means that you will be scripting “blind” as VuGen will not show you what any pages look like in either the Tree View or the Test Results window.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
// Lookup of Incident # INC00000126798
web_custom_request("BackChannel_15", 
    "URL=https://remedy-ars.example.com/arsys/BackChannel/?param=416%2FGetEntryList%2F22%2Fremedy-ars.example.com31%2FHPD%3AIncident%20Management%20Console22%2Fremedy-ars.example.com13%2FHPD%3AHelp%20Desk0%2F30%2F4%5C1%5C1%5C1000000161%5C99%5C302085700%5C13%2F1%2F9%2F30208570020%2F1%2F15%2FINC0000012679875%2F1%2F1%2F41%2F21%2F3212%2F17%2F9%2F24000100510%2F100000000110%2F10000057919%2F20000000510%2F100000000010%2F100000005610%2F100000016410%2F100000015110%2F100000008010%2F10000002179%2F20000000310%2F100000056010%2F10000057859%2F20000000492000000049%2F24000100310%2F10000000999%2F240001002", 
    "Method=GET", 
    "TargetFrame=", 
    "Resource=0", 
    "RecContentType=text/plain", 
    "Referer=https://remedy-ars.example.com/arsys/forms/remedy-ars.example.com/HPD%3AIncident+Management+Console/Default+User+View+%28Support%29/?cacheid=70246b58", 
    "Snapshot=t22.inf", 
    "Mode=HTML", 
    "EncType=text/plain; charset=UTF-8", 
    LAST);
/*
URL decoded request:
https://remedy-ars.example.com/arsys/BackChannel/?param=416/GetEntryList/22/remedy-ars.example.com31/HPD:Incident Management Console22/remedy-ars.example.com13/HPD:Help Desk0/30/4\1\1\1000000161\99\302085700\13/1/9/30208570020/1/15/INC0000012679875/1/1/41/21/3212/17/9/24000100510/100000000110/10000057919/20000000510/100000000010/100000005610/100000016410/100000015110/100000008010/10000002179/20000000310/100000056010/10000057859/20000000492000000049/24000100310/10000000999/240001002
 
JSON response:
this.result={n:1,f:[{t:0},{t:4,v:"JDS"},{t:4,v:"PPL000000132801"},{t:4,v:"Network Management 


In body there will be lot of PPL000000132801 and IDHAGG6782THEVB requests and Incident IDs starting from INC000000012347

Coreleate Incident ID and IDH ID its a must.

After script generation do one thing Ctrl+H  replace "web_custom_request("BackChannel"  with "web_reg_find("Text=this.result", LAST);web_custom_request("BackChannel" it will put

web_reg_find("Text=this.result", LAST); Function before each backchannel request and will help you to know if response is coming from the server or not.

Timestamp

There will be lot of timestamp in your script having 10 digits and 13 digits.
Coreelate it as following type:

// Example in C
// Timestamp in seconds
lr_save_int(time(NULL), "pTimestamp_1"); // 12499508091249950809 // Timestamp in milliseconds
web_save_timestamp_param("pTimestamp_2"); // 1249950434718
And one more thing while updating Incidents,Problems in application there will be backchannel's having Body containing combination of 13 digit and Incident ID of 15 digits.
Corelate this timestamp as
web_save_timestamp_param("pTimestamp_2"); // 1249950434718
Its very important, please do take care of this.
If you have any issue provide me your comments.