Function driven Framework for web (http/html) protocol in LoadRunner

Abstract:
The main objective of this paper is to reduce the effort involved in preparing loadrunner scripts using web (http/html) protocol and this is achieved by creating a Function driven framework. Say for example if we have hundreds of scripts with few transactions repeating in each of them, then these repeated transactions are divided into tiny modules or blocks and are converted into user defined functions. These functions will be saved as header files and maintained in a common repository from where they will be called to the loadrunner scripts when they are required. These header files will be modified when there are changes in the requests and we can start the test executions without even opening the other scripts that are using these header files. The major advantages of this framework is preparing and maintaining the scripts will be easier and also it reduces the script debugging and reworking efforts.

Creating a user defined function:
Say for example Login, Home Page & Logout transactions will be common for all the applications. Instead of recording these requests repeatedly for each script, we suggest to record it once and convert it into user defined function and save it in a header file.




What are Header Files?
Header files are used to define all the functions, variables and constants in any function library that we want to use in our C Program. These files instruct the compiler on how to call a function using function names. Declaration of these header files start with #include and end with .h extension.

Below is the script generated in loadrunner for logging into an application (Login Transaction):



Now this App_Launch & App_Login requests have to be converted into a user defined function in a notepad and then save it as “.h” file (i.e.) header file. Similarly, all the repeated actions are converted into header files with user defined functions.
In the below example we have created a function by name “Login()” and we have saved the file as “Login.h”. Maintain these header files in a structured folder path for ease of use.



These header files will be called in the desired loadrunner scripts with their function name. For that we need to define the path of the header file in the “global.h” section of the Vugen script. Reason for placing the header files in the global.h section is that it makes the header file globally accessible across the script. 
Since the header files are in a location other than the script folder, we have to mention the entire path in the declaration. Also Make sure that the header files exist on the remote Load Generator machine at the same location when running the test from Controller.



After adding the header file, next add the function name in vuser_init()/Action()/vuser_end() section of the script. In our case the function name is Login(); and we have called it from vuser_init().



When we run the script, requests from the header file Login.h (i.e.) the App_Launch & App_Login transactions will be executed in Vugen.
This user defined functions can contain parameters & correlation functions and they will also be executed without any issues. If there are user defined parameters make sure that the same parameter is also created in the script.


Advantages of this framework:
1. Since we are recording all the repeated transactions only once, Scripting time will be drastically reduced.
2. In future if the requests in the header files are modified, then we need to debug only a single header file, instead of reworking on all the scripts. So script debugging time will be drastically reduced.
3. Header files can be stored in a shared path and same can be reused by the team.




Work Load Modelling using concurrent Vusers and Transactions Per Hour (TPH)


One of the important aspects of performance testing is Work Load Modelling (WLM) and in this article we will see how we can design it based on the below inputs from the client.
  •        800 concurrent vusers
  •        TPH is 25% of TPD (Transactions Per Day). Script wise TPD has been shared by the client.
  •        Duration of the test will be 1 hour (3600 Seconds).

Now let’s see how we can design the WLM.
Below table shows the final WLM we have arrived at. In a step by step manner we will see how we calculated each parameter.



Step 1 – Calculate TPH
We know that TPH is 25 % of TPD. So our TPH will be.
TPH = 0.25 X TDP.

Step 2 – Calculate Load Distribution %
To find out the load distribution for each script, we need the Total TPH which will be the sum of all the scripts TPH. So our Load Distribution % will be.
Total TPH = TPH
Load Distribution % = (Script TPH / Total TPH) X 100
Load Distribution % value will be in decimal and we need to round it off.

Step 3 – Calculate Vusers
We know from the requirement, the Total Concurrent Vusers for the scenario will be 800. Now we need to distribute this across the scripts based on the scripts Load Distribution %. So our Vusers will be.
Vusers = (800 X Load Distribution %) / 100

Step 4 – Calculate Pacing
We know that the duration of the test will be 3600 seconds. So we will set the duration of the run in the controller and we will calculate only pacing so that the controller will decide upon the iterations required to achieve the TPH.  Since we know Vusers & TPH, our Pacing will be.
Pacing = (Vusers X Duration of the test in Seconds) / TPH