Introduction to VuGen Script Files and Runtime Settings:
With our tutorials so far in this series, we have mastered VuGen and are in a position to create and enhance VuGen scripts for almost any Web Application.
Let’s conclude our VuGen tutorial series with these two topics – ‘VuGen script files’ and ‘Runtime settings’.
What You Will Learn:
- VuGen Script Files
- Runtime Settings
- 1) General->Run Logic:
- 2) General->Pacing:
- 3) General->Log:
- 4) General->Think Time:
- 5) General->Additional Attributes:
- 6) General->Miscellaneous:
- 7) Browser->Browser Emulation:
- 8) Network->Speed Simulation:
- 9) ) Network->Streaming:
- 10) Internet Protocol->Content Check:
- 11) Internet Protocol->Proxy:
- 12) Internet Protocol->Preferences:
- 13) Internet Protocol->Download Filters:
- 14) Data Format Extension->Chain Configuration:
- VIDEO Tutorial: VUGen Runtime Settings
- Recommended Reading
VuGen Script Files
When a VuGen script is created and saved, a number of files are created – namely configuration files, data files, source code files etc. These files contain Vuser runtime and setup information. VuGen saves these files together along with the script in the script folder.
Files inside the folder:
Let us understand some of the important files:
1) ScriptName.usr: This is the actual VuGen script file. When we open this file (this file can be opened only with VuGen), Vuser script is opened.
2) ScriptName.bak: This file is the backup file for VuGen script. This is a copy of the ScriptName.usr file before the last save operation.
3) default.cfg: This file contains a list of all runtime settings as defined in the VuGen script (think time, iterations, log, web).
4) default.usp: This file contains the script’s run logic, including how the actions section run.
5) vuser_init.c: This file contains a copy of the Vuser_init function as seen in the VuGen script.
6) Action.c: This file contains a copy of the Action function as seen in the VuGen script.
7) vuser_end.c: This file contains a copy of the Vuser_end function as seen in the VuGen script.
8) output.txt: This file contains the replay log.
9) CodeGenerationLog.txt: This file contains the generation log.
10) data folder: This folder contains all the recorded data that are used primarily as a backup. Once the data is in this folder, it is not touched or used.
11) result1 folder: This folder contains all the replay/results data.
Runtime settings define the way in which a VuGen script runs and logs/reports. Runtime settings can be defined in a VuGen script or in the Controller while running the test (Runtime settings in the Controller overrides the one set in the script).
Runtime settings can be seen in the Solution Explorer pane (of the VuGen script) as shown below:
Let’s see and understand these settings (for Web-HTTP/HTML protocol) one by one.
1) General->Run Logic:
Here is where we define how the actions in the script should run.
In Run Logic, there are three main blocks – Init, Run, and End. The actions that are put under Init block are run only once in the beginning, the actions that are put under End block are run only once in the end and the actions that are put under Run block run for multiple iterations defined.
For an e-commerce site, we can have the following actions:
If we set like this (as shown below) with the number of iterations as 10 say, in the first iteration vuser_init and Login actions (in that order) will be executed first and SearchProduct, OrderProduct, and CancelProduct actions will be executed next (in that order).
From the second iteration onwards only the SearchProduct, OrderProduct and CancelProduct actions will be executed.
And in the last iteration, after the CancelProduct action is executed, the Logout and vuser_end actions (in that order) are executed and the script execution stops.
Also, we can define two ways of running the Run block (click on the Run block and these options will be enabled on the right)–Sequential and Random.
When we set ‘Sequential’, all the actions in the Run block run sequentially (in the order they appear).
When we set ‘Random’, we are prompted to enter the percentage weights for each of the actions in the Run block and accordingly only one of these actions will get executed in each iteration.
Also, we can define Block (click on Insert Block button) to group related actions.
For Example, we can put SearchProduct and OrderProduct actions under a block.
Pacing is the time for which the Vuser waits between iterations. It is used to control the number of iterations in a specified time thereby controlling the load on the application.
There are three pacing options as shown below.
The first option is not used in a load test, it is used for verifying data or for a low load test. Option 2 or 3 can be used to control the load in a load test.
The level of logging can be set here. As logging creates additional overhead on the Load Generators, one should be wise (log only what is required) in choosing these options.
While debugging the scripts, it is recommended to enable ‘Extended Logging’ always (to be able to see the complete log – request/response, parameters substitution etc.). But when running the tests, it is recommended to go with ‘Standard log’ or ‘Extended log’ with ‘Log when an error occurs’ option.
4) General->Think Time:
Think Time allows a Vuser to pause for a defined time between steps/actions on the VuGen script. This is to simulate the real user behavior of thinking for some time between actions/steps on an application.
There are four options as shown below:
The first option is generally used when verifying data, while any of the other three options can be used in a load test. It is recommended to put some randomness in think time by using the fourth option.
5) General->Additional Attributes:
We can define parameters here. Sometimes it is good to define parameters in the Runtime settings than in VuGen script. This helps us to easily edit the parameter values in the Runtime settings in the Controller (Runtime settings can be overridden in the Controller) than changing in the script every time.
For Example, if we have a URL that changes for every test, then it is better to add this as a parameter in the ‘Additional Attributes’ page.
In the Error Handling section, it is generally recommended to enable the second and third one. The first one (‘Continue on error’) can only be enabled if we have written a code to handle the errors separately, otherwise better leave it disabled.
In the Multithreading section, we have two options to choose from.
The Controller uses a driver program such as mdrv.exe to run the Vuser. If we select ‘Run Vuser as a process’ option, then the same driver program is loaded into the memory for every instance of the Vuser. This results in high usage of memory and other system resources.
If we select ‘Run Vuser as a thread’, then only one instance of the driver program is loaded for every 50 Vusers by default. This reduces the consumption of memory and other system resources.
It is recommended to go with the first option – ‘Run Vuser as a thread’. However, there are certain non-thread safe applications that cannot run with this option. We don’t have any option other than going with ‘Run Vuser as a process’ for such applications.
In the Automatic Transactions section, if we enable ‘Define each action as transaction’, each action will be treated as a transaction and will be listed in the test results, similarly if we enable ‘Define each step as transaction’, each step/request will be treated as a transaction and will be listed in the test results.
It is better not to enable any of these options and rely on the transactions that we insert in the script.
7) Browser->Browser Emulation:
When a VuGen script is run, the Vuser does not use an actual browser to access the site. Instead, the Vuser emulates a browser accessing the site. To do this emulation, the Vuser creates a user-agent string that includes various tokens.
The User-Agent Selection allows two ways of creating this User-Agent string:
Use browser – the user-agent string will be generated based on the browser information that we give.
Use custom – we can enter the user-agent string directly.
The Browser Cache options allow us to configure cache settings for the Vuser. It is recommended to enable ‘Simulate browser cache’ option to simulate a real user request.
8) Network->Speed Simulation:
This option allows us to set the network bandwidth limit for the test. It is recommended to go with the first option (‘Use the maximum bandwidth’) unless we have a specific scenario where we have to test the performance with a specific bandwidth.
9) ) Network->Streaming:
These options allow us to configure the streaming settings.
10) Internet Protocol->Content Check:
This is like a global verification point that will verify the text on every page.
We can add our application and define rules (or import/export rules).
11) Internet Protocol->Proxy:
These options allow us to make the proxy server connection settings. As the end user would be using our application without any proxy, it is recommended to use the first option (‘No proxy’) for our tests.
If our application is an intranet application and an end user would be using the application through a particular proxy server, then the corresponding settings should be configured here using the second option (that uses the proxy settings of the default browser on the machine where the script runs) or third option (that uses the settings that we specify).
12) Internet Protocol->Preferences:
This enables us to set various internet related runtime settings. It is recommended to leave them to the default settings but it would be good to understand these settings.
13) Internet Protocol->Download Filters:
This setting is a good way of preventing our scripts from the downloading content from specific URLs or Hosts. There may be a situation where our script contains certain URLs and we don’t want to hit them for certain reasons (it may be a third-party URL that cannot be hit any time etc.), in such a situation, we can add these filters.
An Example is shown below:
14) Data Format Extension->Chain Configuration:
This is an advanced setting that enables easier scripting (easier correlation and parameterization) of web applications by providing the ability to decode and encode formatted data that is exchanged between the client and the server.
NOTE: Below is the hands-on video on VuGen Runtime Settings recorded on HP LoadRunner version. This is still valid with just a few UI changes in the current Micro Focus LoadRunner version.
VIDEO Tutorial: VUGen Runtime Settings
Video Tutorial Summary:
#1. Vugen runtime setting – allows Vugen with different settings which works on script execution.
#2. These help testers in many ways:
- To emulate real user.
- Allow getting detailed information for the virtual user.
- Retrieve Performance stats for the graph.
- Automatic transaction
- Error handling
#3. Run Logic – using this the performance tester can play around with the sequence of running actions.
#4. Run Logic also has the option to have Block for looping and Properties which allow running the actions sequentially or randomly.
#5. Using pacing, the script can be allowed to wait between the iteration.
#6. Log stores record of user activities. The tester has good control when and what to store. The tester can instruct Vugen how much information to store and situation when logging starts.
#7. Think Time helps in adding wait time in the script for the user`s wait time between the action on an application. It helps the tester to get real actions from a virtual user.
#8. Using Additional Attributes, the tester can add a parameter to the script and has the flexibility to change the value for that through run time settings. These parameters are the same as declared parameter within the script.
#9. Using miscellaneous options, the tester can configure settings related to Error Handling, Multithreading and Automatic Transaction.
#10. Configuration related to bandwidth can be done through Speed Simulation. Bandwidth can be either maximum or with limitations.
#11. Browser selection can be done through Browser Emulation. There are few settings of the browser which can affect the Performance of an application.
#12. Vugen also provides flexibility to use a Proxy setting. Through the Proxy setting, a custom proxy server can be set.
#13. Preference deals with the checkpoint, Performance graph, and advanced setting.
#14. Using the Download filter, the unwanted request coming from any server or with a URL can be blocked.
#15. Content Check is helpful in finding know errors anywhere in the script while execution.
With this, we come to an end with the tutorial series for ‘LoadRunner VuGen’ (the first component of LoadRunner).
Hope you enjoyed this informative series of tutorials and we are sure that this will help you to kick-start your career in Performance testing using Load Runner.
The next tutorials will be on other important LoadRunner components i.e ‘Controller’ and ‘Test Result Analysis’.
Watch our Video tutorial to know more about Controller.