Tuesday, April 10, 2012

Important functions to be used with array parameters

You can find certain cases in your testing where you need to correlate parameter values in arrays. i.e. When server returns a list of values or a table
If we want only first value from this parameter array then there is no need to go for array and no need to use "ORD=ALL", we can get the value by providing boundaries and "ORD=1" but if we have certain cases where we not to take value from any specified location within array (i.e. Third value from the array). Also we might have top choose ant random value from the array.

These are some inbuilt function comes with LR which can be used with array variables and can fulfill our need.

int arrSize;

char * FlightVal;

web_reg_save_param("outFlightVal", "LB=outboundFlight value=", "RB=>",  "ORD=ALL",  "SaveLen=18",  LAST ); 


    web_submit_form("reservations.pl",

        "Snapshot=t4.inf",

        ITEMDATA,

        "Name=depart", "Value=London", ENDITEM,

        "Name=departDate", "Value=11/20/2003", ENDITEM,

        "Name=arrive", "Value=New York", ENDITEM,

        "Name=returnDate", "Value=11/21/2003", ENDITEM,

        "Name=numPassengers", "Value=1", ENDITEM,

        "Name=roundtrip", "Value=<OFF>", ENDITEM,

        "Name=seatPref", "Value=None", ENDITEM,

        "Name=seatType", "Value=Coach", ENDITEM,

        "Name=findFlights.x", "Value=83", ENDITEM,

        "Name=findFlights.y", "Value=16", ENDITEM,

        LAST );

// The result of the web_reg_save_param having been called before the web_submit_form is:

Notify: Saving Parameter "outFlightVal_1 = 230;378;11/20/2003"

Notify: Saving Parameter "outFlightVal_2 = 231;337;11/20/2003"

Notify: Saving Parameter "outFlightVal_3 = 232;357;11/20/2003"

Notify: Saving Parameter "outFlightVal_4 = 233;309;11/20/2003"

Notify: Saving Parameter "outFlightVal_count = 4" 
  
arrSize = lr_paramarr_len("outFlightVal");

FlightVal = lr_paramarr_idx("outFlightVal", arrSize); 
FlightVal = lr_paramarr_random("outFlightVal");

lr_paramarr_len is used to get the length of the parameter array.
lr_paramarr_idx is used to get the value from the specified location from array (in FlightVal = lr_paramarr_idx("outFlightVal", arrSize);  We are taking last value from the parameter array and storing it into FlightVal )
lr_ paramarr_random is used to retrieve value from any random index of the array (FlightVal = lr_paramarr_random("outFlightVal");  This will retrieve value from any randon index of the array and will store this value in FlightVal )

JAR, WAR and EAR Files

While working on Flex based application, JAR files plays a key role to the generate the understandable body which doesn't compasses binary values.
We ask from the development team or from the data teams for application specific JAR files, those files can be given to us in any form like JAR, WAR or EAR files.

JAR: These files are with the .jar extension. The .jar files contain the libraries, resources and accessories files like property files.
Files with a .jar extension are intended to hold generic libraries of Java classes, resources, auxiliary files, etc.
JAR files (Java ARchive) allows aggregating many files into one, it is usually used to hold Java classes in a library. i.e. Math.jar

WAR:  These files are with the .war extension. The war file contains the web application that can be deployed on the any servlet/jsp container. The .war file contains jsp, html, javascript and other files for necessary for the development of web applications.
War files (files with a .war extension) are intended to contain complete Web applications. In this context, a Web application is defined as a single group of files,classes, resources, .jar files that can be packaged and accessed as one servlet context.

EAR:   Ear files (files with a .ear extension) are intended to contain complete enterprise applications. In this context, an enterprise application is defined as a collection of .jar files, resources, classes, and multiple Web applications. Each type of file (.jar, .war, .ear) is processed uniquely by application servers, servlet
containers, EJB containers, etc.
EAR files (Enterprise ARchive) combines JAR and WAR files to make a combined archive for Enterprise Applications.

Setting the Run-Time-Settings programmatically

Is it possible to programmatically set the Run-Time Settings through VuGen scripts instead of using the Run-Time Settings dialog box.
We have variety of functions available with LR which can be used to fulfill this purpose.

1. lr_set_debug_message:    Run-Time Settings -> Log

2. lr_think_time:    Run-Time Settings -> Think time
 
3. lr_continue_on_error:    Run-Time Settings -> Miscellaneous -> Error handling -> Continue on error

·     4. When working with RTE Vusers, you can control error handling for specific functions. You insert an lr_continue_on_error(0); statement before the function whose behavior you want to change. The Vuser uses the new setting until the end of the script execution or until another lr_continue_on_error statement is issued. 

      For example, if you enable the Continue on Error feature and the Vuser encounters an error during replay of the following script segment, it continues executing the script.

TE_wait_sync();
TE_type(...);

To instruct the Vuser to continue on error for the entire script, except for the following segment, select the Continue on Error option and enclose the segment with lr_continue_on_error statements, using 0 to turn off Continue on Error and 1 to turn it back on:

lr_continue_on_error(0);
TE_wait_sync();
lr_continue_on_error(1);

5. web_set_sockets_option("PROXY_INITIAL_BASIC_AUTH", "0")
To instruct the Vusers to wait for the proxy response during replay, and not to assume that the proxy supports basic authentication

  
 6. web_set_timeout :   Run-Time Settings -> Preferences -> Option -> Connect/Receive/Step Download timeout

7. web_enable_keep_alive:    Run-Time Settings -> Preferences -> Option -> Keep-Alive HTTP connection
 
8. web_set_max_retries :   Run-Time Settings -> Miscellaneous -> Error handling -> Run-Time Settings -> Preferences -> Option -> Max number of <META refresh> to the same page

9. ctrx_set_waiting_time:    Run-Time Settings -> Timing -> Connect timeout

Some additional Run-Time-Settings

10. lr_abort:    Aborts Vuser script execution.
 
11. lr_disable_ip_spoofing:    Disables IP Spoofing.
 
12. lr_enable_ip_spoofing:    Enables IP Spoofing.

13. lr_exit:    Exits from the script, action, or iteration.

14. lr_rendezvous:    Sets a rendezvous point in a Vuser script.
 
15. lr_rendezvous_ex:    Sets a rendezvous point in a Vuser script.

Friday, April 6, 2012

Server xxxx has shut down the connection prematurely

Recently I was working on an application where I did load testing with around 350 Vuser and with 3 LGs. During the test I observed "Server xxxx has shut down the connection prematurely".
Note: XXXX refer the server name here

To fine tune the issue I found that this issue could be due to so may factors and we can take certain measures to resolve this issue out.

1. Over burdened LGs can cause the issue, so use more LGs.
2. Make sure all the users are not ramping up simultaneously and the rendezvous point not holding too many users.
3. Clear the temp directory from all the LGs and servers where loadrunner or It's components are Installed.
4. Make a note that there is no network blockage
5. Restart all the LGs, Controller machine and  the server, this may reduce the error.
6. You can use web_set_sockets_option("IGNORE_PREMATURE_SHUTDOWN", "1");
Use this function in your script and put in Vuser_Init section, This will not allow this error to come in the test.

Tuesday, April 3, 2012

IP Spoofing and Adding Multiple IP Addresses To Host

 
IP Spoofing:
When you run a scenario, the Vusers on each host machine use the host’s IP address. You can define multiple IP addresses on a host machine to emulate a real- life situation where users sit on different machines.

About Multiple IP Addresses:
Application servers and network devices use IP addresses to identify clients. The application server often caches information about clients coming from the same machine. Network routers try to cache source and destination information to optimize throughput. If many users have the same IP address, both the server and the routers try to optimize. Since Vusers on the same host machine have the same IP address, server and router optimizations do not reflect real- life situations. (real life Network Traffic)
LoadRunner’s multiple IP address feature enables Vusers running on a single machine to be identified by many IP addresses. The server and router recognize the Vusers as coming from different machines and as a result, the testing environment is more realistic.
Note:
  1. IP Spoofing runs on LG. Each LG will be allotted Bulk IPs. Ex 10 IPs.if we are running 10 users on that LG, each vuser will pick one unique IP. All the IP added should be valid and should be recognized by the network routers and firewalls.
  2. NIC card should be sufficient strong enough to support the data what flows across the number of Vusers and IP spoofed for the LG.
  3. DHCP should be disabled on LG Box and IP addresses should be static IP addresses.

Adding IP Addresses to a Host (Load Generator):
LoadRunner includes an IP Wizard program that you run on each host machine to create multiple IP addresses. You add new IP addresses to a machine once and use the addresses for all scenarios.  

The following procedure summarizes how to add new IP addresses to a host:
1 Run the IP Wizard on the host machine to add a specified number of IP addresses.
2 Re- Start the host machine.
3 Update the server’s routing table with the new addresses, if necessary.
4 Enable this feature from the Controller.

Using the IP Wizard:
The IP Wizard resides on each host machine where load generator software is installed. We need to run this process one time to add and register new IP addresses. The new addresses should be in the range of addresses defined by the Internet Assignment Numbers Authority. They are for internal use only for the project.
To add new IP addresses to a host machine:
1.  Invoke the IP Wizard from the LoadRunner program tools.

  
2. If you have an existing file with IP address settings, select Load settings from file and choose the file.
3. If you are defining new settings, select New Settings.
4. Click Next to proceed to the next step. If you have more than one network card, choose the card to use for IP addresses and click Next .The optional Web server IP address step enables the IP Wizard to check the server’s routing table to see if it requires updating after the new IP addresses are added to the host. (




Note: Using the Load Generator with Multiple NIC card is not recommended for Load Generator Purpose in case test involves measuring the network traffic or it is a large test.
5. To check the server’s routing table directly after adding the addresses, enter the server IP address. 
6. Click Next to see a list of the machine’s IP addresses. Click Add to define the range of addresses. 
IP addresses include two components, a netid and hostid. The sub mask determines where the netid portion of the address stops and where the hostid begins.  
7. Select a class that represents the correct sub mask for the machine’s IP addresses.
8. Specify the number of addresses to create. Select Verify that new IP addresses are not already in use to instruct the IP Wizard to check the new addresses. If some addresses are in use, the IP Wizard will only add the addresses not in use.
9. Click OK to proceed.
After the IP Wizard creates the new addresses, the summary dialog box lists all of the IP addresses. 
 
9. Click Finish to exit the IP Wizard. The IP Wizard Summary dialog box is displayed.

10. Select the checkbox Reboot now to update routing tables and click on OK.
11. To Verify the IPs added successfully to the Load Generator Box, Please login Manually to Load Generator Box and on command prompt type IPCONFIG/ALL.
12. We can also verify that each user is getting unique IP address by using lr_get_vuser_ip function in the script.