Sunday, March 8, 2009

How to run a scenario from the command line

Solution:

Command line arguments for the LoadRunner Controller

Note:
1. Make sure that the Controller is shut down before starting the scheduled task.
2. When running the Controller via the Command Line, Controller will be shut down automatically after the scenario ends.

Command line parameters are parameters that the Controller receives when it is invoked. They are used to instruct the Controller on how to behave. When invoked, the Controller checks all the received parameters and sets its startup environment accordingly. If no parameters are passed, the Controller uses its default settings.

By passing parameters in the command line, you may set the Controller and the scenario's settings without the need to manually define them in the Controller UI. For example, you can instruct the Controller whether to connect to TestDirector on startup by using the ConnectToTD parameter, save the results to a directory other than that defined in the scenario by using the ResultName parameter, or invoke Analysis upon scenario termination with the InvokeAnalysis parameter.

The most common use of the Command Line is done by TestDirector. TestDirector includes a special program called "Test Run Scheduler," which was designed for scheduling the Controller to run scenarios at a specific date and time. It automatically invokes the Controller and runs scenarios. Results are saved in the TestDirector database. To do that, TestDirector must set the scenario's environment by supplying the Controller with specific parameters.

Predefined rules:

  • When one or more parameters are not passed, the Controller uses its default settings.
  • Results will always be overwritten.
  • The Controller will automatically terminate upon scenario termination and the results will be then collated.
  • The Controller's settings are loaded from wlrun5.ini located in the Windows directory.
  • The following parameters are supported on all Windows 9x and Windows NT platforms.
Switches for LoadRunner/TestDirector integration:
  • ConnectToTD - Should the Controller connect to TestDirector on startup (0/1 or ON/OFF).
  • TDServer - TestDirector server name. Must be a computer name with TestDirector installed.
  • TDDB - Database name. For example, "lrun."
  • UserName - User name.
  • Password - Password for the user name.
  • TestPath - Path to scenario in the TestDirector database. For example, "[TD]\Subject\LoadRunner\Scenario1." If the path includes white spaces, use quotation marks.
  • TestId - Test ID (for TestDirector only).
  • ResultCleanName - For use with ResultCycle only, for example, "Res1."
  • ResultCycle - TestDirector cycle, for example, "LR_60_SP1_247." To define the results path in TestDirector, the Controller must be provided with two parameters: ResultCycle and ResultCleanName.
Run-Time Switches:
  • Run - Runs scenario, dumps all output messages into res_dir\output.txt and closes the Controller.
  • InvokeAnalysis - InvokeAnalysis will set a flag in the Controller, which will invoke Analysis upon scenario termination (If not used, the scenario value will be taken).
Results Switches (for File System):
  • ResultName - Full results path, for example, "C:\Temp\Res_01."
  • ResultCleanName - Results name, for example, "Res_01."
  • ResultLocation - Results directory. For example, "C:\Temp".
  • Note:
    • If the scenario does not specify a results directory and one of the above parameters was not passed, the scenario will not run!
    • The results will always be automatically collated upon scenario termination.
    • The results will always be automatically overwritten.
Command Line Syntax examples:
  • Wlrun.exe -TestPath C:\Temp\Scenario1.lrs -ResultName C:\Temp\Res1 -Run -InvokeAnalysis
  • Wlrun.exe -TestPath C:\Temp\Scenario1.lrs -ResultLocation C:\Temp -ResultCleanName Res1 -Run
  • Wlrun.exe -ConnectToTD on -TDServer localhost -TDDB lrun -UserName yaniv18 -Passwordb#12GcSA -TestPath "[TD]\Subject\Trash for LR/TD Integration\Scenario1" -Run
  • Wlrun.exe -ConnectToTD 1 -TestPath "[TD]\Subject\Trash for LR/TD Integration\Scenario1" 
  • No comments:

    Post a Comment