Monday 15 September 2014

Load Runner Script Structure

A virtual user script can be made up of a number of different sections, each performing a different action, with each section handled differently by the compiler and controller during test execution.


•    vuser_init - The initialization phase of the script

•    action - The body of the business process, to be iterated

•    {more actions} - Further actions within the process

•    vuser_end - The close down, or housekeeping phase of the script.


When recording the business process and enhancing the virtual user script, the following standards must be applied to the structure of the script to ensure it is recorded in a consistent and supportable manner.

vuser_init

This section is executed once, when the virtual user is brought up and initialized, and contains any information necessary to enable the virtual user to log onto an application. It will also hold any directives to load function libraries, and to hold any functions unique to that particular script. Often, it will contain nothing but the script header block.


Generally it will contain:


•    #include file references

•    #define directives

•    Script headers

•    User defined functions

•    User login details


Each virtual user script contains exactly one ‘init’ section, and therefore there is no need for it to be renamed.

Action

The action section is the part of the script that performs the iterative work of the business process. The contents may be iterated hundreds if not thousands of times, and therefore should not hold any irrelevant content such as functions.


The default name is 'action'.  Even in a single action script, the main transaction should be named.  Thus, if the script is run with other scripts in a mixed traffic test, each type of action may be clearly distinguished in the resultant outputs.


In a more process intensive script, more than one action may be involved to enable tighter control on processing and flow control. In this case, each action should be given a meaningful name within the script, which need follow no standard convention save that it needs to be readable. Generally, if a script can be broken down into logical units, then the use of individual named actions should be seriously considered.

vuser_end

As with the ‘init’ section, this section is executed only once, either after the completion of the appropriate number of iterations, or by initiation of the controller during scenario ramp-down.


Should it be appropriate for the application and business process to log off in a controlled manner, it will occur in this section. It serves no other purpose, and occurs exactly once in each script. There is no requirement to rename this section.

No comments: