Thursday, March 6, 2014

Vuser Init, Action, Vuser End Actions | Action files in Micro focus Load runner

LoadRunner has 3 types of action files.

1.Vuser_init()
2.Action()
3.Vuser_End()

vuser_init: It is the first action file in load runner script. In the course of a vuser's life, it is only ever executed. By "life cycle," we refer to the interval between a vuser's start and end.
 
Action: All major actions will be placed here and the actions which needs enhancements will be stay her. Every time that a vuser iterates, the steps that are embedded within this file are executed.

vuser_end: This is the last action file that is executed and it comes under the end section of the script. Like vuser_init, we can put steps that need to be executed once for the entire execution of a vuser.

if an user wants to login and perform some multiple actions then his login should be place in vuser_init() and logout shout be placed vuser_end().


  • Any script can be divided in to three sections Init, Run and End
  • Each of the above sections can be further divided in to one of more sub sections called blocks.
  • Each block can contain one or more action blocks or simply actions.
  • The blocks are particularly useful if we need to repeat a set of actions.
  • Action blocks can be created in the run time settings of the LR script. 
  • To create a block, just select the section that and then click insert block or right click on the section and then select Insert Actions Block.

Parameterization in Load runner | Sequential Random Unique Each iteration, Each occurrence in Load Runner

In the script View, select the string and right click on it. Then, select the replace with parameter. and then there are 4 types of parameterization techniques we have, They are
  • Sequential
  • Random
  • Unique
Each iteration : It instructs the Vuser to use a new value for each iteration
Each occurrence : It instructs the Vuser to use a new value for each occurrence of the parameter. 
Once :It tells the Vuser to change the parameter's value just once while the execution is running. In LoadRunner, the Data Wizard is a fantastic solution for parameterization.

Objectives of parameterization:
The main objective of parametrization is to simulate real user behavior while running the test and to Address any date restrictions that may appear during playback, Fix data caching issues that could come up during playback, Fix any special constraints that may appear during playback, Fix data dependency issues that could come up while playing back and Simulate actual user behavior.

How to create Parameters:
Right click on the value and select “Replace with parameter” where we need to execute with different set of values.


On the new window opened just give the Parameter name as user defined variable and Parameter type select any one from the drop down and Original Value will be default value and click on properties




After clicking on properties new window will be opened then click on Edit with notepad button and enter some list of values.{please note After entering values in notepad keep the cursor in new line and save the notepad and close it.}





After entering the different set of values we have to customize the parameter properties to execute the script as user’s perspective.

Parameter Customization:

1. Select Column By Number by Name

These values are used when we have multiple columns in the same table with the same parameter type. We can select for each parameter by number as column number or by name as column name.




2. File Format Column Delimiter
  • First Data Line
Column Delimiter drop down has values Comma, Tab, Space which are used to separate multiple columns. First Data Line is a number which it uses that number row data at the time of execution. For eg: if you increase the number to 2 by using up button then the execution starts from 2nd row data.



3. Select Next Row a Sequential
  • Random
  • Unique

Update Value on  Each Iteration 
  •  Each Occurrence
  • Once
If you select Select Next Row as Sequential and Update Value On as Each iteration then the users will execute the data sequentially for each iteration.

Click on close button and press CTRL+L buttons then parameter properties window will open with all parameters in left side and right side parameters data window.

If you click on Simulate Parameter button and then enter the iterations in check box and then click on simulate button then we will get the user behavior when the time of execution how the parameters will pass to the vusers.


If you select Update value on as Each Occurrence we can not simulate the parameter.

If you select Update value on as Once then the vuser will take only one set of data for all vusers. for example In the above snapshot we will get James and 123 for each and every vuser we execute. If you select Select Next Row as Random and Update value on as Each iteration then the user will pick random data for each and every iteration. At that we have to select for one parameter these values and select Same line as that parameter name for remaining parameters. For example If we select Random Each iteration for Username then we have to select Same line as username for password.

If you select Select Next Row as Unique and Update value on as Each Iteration or Each Occurrence then automatically When Out of Values and Allocate Vuser values in the controller will be enabled.

When Out Of Values Abort Vuser
  •  Continue in a cyclic manner
  • Continue with last value

Allocate Vuser values in the controller(Radio Buttons):



Automatically allocate block size
Allocate ______ values for each vuser



If you have values less than vusers at that time we have to select Unique Each Iteration abort Vuser then what ever the users extra are aborted from the execution.
We can select Unique Each Iteration Continue in a cyclic manner
We can select Unique Each Iteration Continue with last value

And we can select any of the two radio buttons for Allocate vuser values in the controller in the above three different cases

If you select Unique Each Occurrence only
Allocate ______ values for each vuser will be enabled for all the three cases

And you can click on Simulate Parameter button for each and every different options customized to view how the vuser behavior. If you select Unique Once all the vusers will execute with one set of data. Once parameterization is done click on close button. Test the data execution procedure in the form of iterations in Vugen.