[82] LoadRunner parameter settings

Source: Internet
Author: User

During load or stress testing, many people choose to use the LoadRunner testing tool. The basic process of this tool is to first record users' actual operations into scripts, and then generate thousands of virtual user running scripts (Virtual users can be distributed on different PCs in the LAN ), finally, generate relevant reports and analysis charts. However, many practical problems may occur during the script recording process. For example, different users have different data usage, which involves parameter settings. This article describes how to set parameters in LoadRunner.
When recording Program During the running process, vugen (script generator) automatically generates a script containing the actual numeric values used during the recording process. If you attempt to use different values in the recorded script to execute the script activity (such as query and submission), you must replace the recorded value with the parameter value. This process is called a parameterized script.
This article mainly includes the following content: understanding the limitations of parameters, setting up parameters, defining the properties of parameters, understanding the types of parameters, setting the properties of parameters for local data types, setting the properties of parameters for data files, from existing databases.
In addition to the GUI, the following content is suitable for various types of user scripts.
1. Parameter Definitions
When your recording program is running, the script generator automatically generates a user script composed of functions. The parameter value in the function is the actual value entered during the recording process.
For example, you have recorded a web application script. The script generator generates a declaration that searches the database of a book named "Unix. When you use multiple virtual users and iterative playback scripts, you may not want to reuse the same value "UNIX ". Then, you can replace this constant with parameters. The result is that you can replace the parameter value with the value of the specified data source. The data source can be a file or an internal variable.
Using parameters to indicate that a user's script has two advantages:
① The Script length can be shortened.
② You can use different values to test your script. For example, if you try to search for books with different names, you only need to write the submit function once. During playback, you can use different parameter values, instead of searching for values of a specific name.
Parameterization includes the following two tasks:
① Replace the constant value with parameters in the script.
② Set the parameter attributes and data source.
Parameterization can only be used for parameters in a function. You cannot use parameters to represent strings of non-function parameters. In addition, not all functions can be parameterized.

Ii. Parameter Creation
You can specify the name and type to create parameters. There is no limit on the number of parameters in the script. In User scripts of web programs, you can use the following process to create parameters in the text-based Script View. Alternatively, you can create parameters in the Tree View Based on icons.
Create a parameter in the text-based Script View:
1. Position the cursor on the character to be parameterized and right-click. Open the menu.
2. Select replace with a parameter in the pop-up menu ". The select or create parameters dialog box is displayed.
3. Enter the parameter name in "parameter name" or select a parameter that already exists in the parameter list.
4. Select the parameter type from the "parameter type" drop-down list.
5. Click "OK" to close the dialog box. The script generator replaces the parameterized characters in the script with the values in the parameters. The parameters are enclosed by a pair.
Note: The entire string must be parameterized, rather than the part of the string, When you parameterize the client-side user scripts of the common-Java language. Note: Except for web or WAP, the default parameter brackets are "{}" for any script. You can define the parameter brackets in the "parameterization" tab (tools> General options) in the "general options" dialog box.
6. Replace the remaining characters with the same parameters. Select the parameter and right-click the parameter to bring up the menu. Select replace more occurrences from the pop-up menu ". The search and replace dialog box is displayed. "Find what" shows the value you are trying to replace. The parameter name in brackets is displayed in "Replace. Select an appropriate check box to match the entire character or case. If you want to search for a rule expression (.,!,? Etc.), select the regular expression check box, and then click "replace" or "replace all ".
Note: Be careful when using "replace all", especially when replacing a numeric string. The script generator will replace all the characters that occur.
7. If you want to replace a constant string with a previously defined parameter, right-click the string and select "use existing parameter". The "use existing parameters" submenu is displayed. Select parameters from the sub-menu "use existing parameters", or use "select from parameter list" to open the Parameter List dialog box.
Note: If you use a previously defined parameter to replace a constant string, It is very convenient to use "parameter list. You can also view and modify the attributes of this parameter.
8. If you want to retrieve the original value of a place that has been replaced by a parameter, right-click the parameter and select "Restore original value ".
Create parameters in the Web user script Tree View:
1. Position the cursor in the place where parameters are attempted. Right-click the cursor and select "properties" from the pop-up menu ". The Related Properties dialog box is displayed.
2. Click the "ABC" icon next to the parameter to be parameterized. The select or create parameter dialog box is displayed.
3. Enter the parameter name in "parameter name" or select an existing parameter from the list.
4. Enter the parameter type in "parameter type.
5. Click "OK" to close the dialog box. The user script builder replaces the original String constant with parameters and replaces the "ABC" icon with a table-shaped icon.
6. To restore the values before parameterization, click the icon and select "undo parameter" from the pop-up menu. The previous values will be reproduced.

 

3. Define parameter attributes
After creating a parameter, you can define its attributes. The attribute definition of a parameter is the data source used by the parameter during script execution. In Web user scripts, you can define parameter attributes in the text-based Script View, or in the icon-based Tree View. The following process will teach you how to define parameter attributes in the script view based on this article.
To define the parameter attributes in the text-based Script View, follow these steps:
1. Right-click the parameter and a menu will pop up.
2. Select "parameter properties" in the pop-up menu ". The parameter properties dialog box is displayed, showing the properties related to the current parameter type.
3. Enter the property value of the parameter.
4. Click Close to close the parameter properties dialog box.
Define the attributes of parameters in the Tree View of Web user scripts:
1. Right-click the parameter and select Properties ". The Properties dialog box is displayed.
2. Click the table shape button next to the parameter of the property to be defined, right click, and select "parameter properties ". The parameter properties dialog box is displayed. properties related to the parameter type are displayed.
3. input parameter attributes.
4. Click Close to close the parameter properties dialog box.
List of parameters used:
You can use the parameter list to view all parameters, create new parameters, delete parameters, or modify attributes of existing parameters at any time.
1. Click the parameter list button or use "vuser> parameter list ". The Parameter List dialog box is displayed.
2. To create a new parameter, click "new. The new parameter is added to the parameter tree and has a temporary name. You can rename it and press Enter. Set the parameter type and properties, and click "OK" to close the Parameter List dialog box.
Note: Do not name a parameter "unique" because it is the name of the user script generator. The user script builder creates a new parameter, but does not automatically use this parameter to replace any selected string in the script.
3. to delete an existing parameter, select it from the parameter tree, click "delete", and then confirm your behavior.
4. to modify an existing parameter, select the parameter from the parameter tree and edit the parameter type and attribute.

4. Understand the parameter types
You must specify the data source of the parameter value when defining the parameter attribute. You can specify any of the following data source types:
Internal data-data generated inside a virtual user.
Data Files-data in the file. It may be an existing file or a new one created using the script generator.
User-defined functions-call the data generated by the external DLL Function
Internal data includes the following types:
1. date/time
Date/time replaces the parameter with the current date/time. To specify a date/time format, you can select the format from the menu list or specify your own format. This format should be consistent with the date/time format recorded in your script.
2. Group Name
The group name replaces the parameter with the virtual user group name. When creating scenario, you can specify the name of the virtual user group. When a script is run from the user script generator, the virtual user group name is always none.
3. load generator name
The load generator name replaces the parameter with the name of the script load generator. The server Load balancer is a computer where a virtual user is running.
4. iteration number
The iteration number replaces the parameter with the current number of iterations.
5. Random Number
Random Number replaces the parameter with a random number. Specify the maximum and minimum values to set the range of random numbers.
6. unique number
Unique number replaces the parameter with a unique number. You can specify a starting number and a block size.
7. vuser ID
The vuser ID replaces the parameter with the ID assigned to the virtual user. The ID is generated by the LoadRunner controller during scenario operation. If you run the script from the script generator, the virtual user ID is always-1.

V. Data Files
The data file contains the data accessed by virtual users during script execution. Data can be stored in local and global files. You can specify an existing ASCII file, use the script generator to create a new file, or introduce a database. The data file is useful when many values are known to the parameter. The data in the data file is stored as a table. A file can contain many parameter values. Each column contains the data of a parameter. Columns are separated by delimiters, for example, comma.
Set parameter attributes for data files
If a file is used as a parameter data source, you must specify the following content: file name and location, columns containing data, file format, including column delimiters and update methods.
If the parameter type is "file", open the parameter properties dialog box and set the file properties as follows:
1. Enter the file location in "file path", or click "Browse" to specify an existing file location. By default, all new data files are named "parameter_name.dat". Note that the suffix of existing data files must be. dat.
2. Click "edit ". In notepad, the first line is the parameter name, and the second line is the initial value of the parameter. Use separators such as commas to separate columns. Start a new row of data for each new table row.
Note: If you want to add a column without starting notepad, click "add col" in the parameter attribute dialog box. The "Add new column" dialog box appears. Enter the name of the new column and click "OK ". The script generator adds the column to the table and displays the initial values of the column.
3. In the "Select column" section, specify the columns that contain the current parameter data. You can specify the column name or column number. The column number is the index of the column that contains the data you need. The column name is displayed in the first row (row 0) of each column ).
4. Enter a column Separator in "column delimiter". You can specify commas (,) and space characters.
5. In "first data line", select the first row of data for use during script execution. The column title is 0th rows. If you start from the first line after the column title, enter 1 in "first data line. If no column title exists, enter 0.
6. Enter the update method in "select next row" to explain how the virtual user selects the data in the table during script execution. The method can be continuous, random, unique, or the same row as other parameter tables.
6.1. Sequential: This method sequentially assigns parameter values to virtual users. If a running Virtual user accesses a data table, it obtains the data available in the next row.
6.2 random (random): This method obtains random numbers from the data table during each iteration.
6.3 use random sequence with seed: If scenario is run from the LoadRunner controller, you can specify a seed value for random sequence. Each seed value represents the sequence of a random number during test execution. Whenever you use this seed value, the same data order in scenario will be allocated to virtual users. If you find a problem during the test execution and attempt to use the same random number sequence to repeat the test, you can start this function (optional ).
6.4 unique: the unique method assigns a unique and ordered value to each virtual user's parameter.
6.5. Get the same row as the previously defined parameter (same line as <parameter>): This method allocates data from the same row as the previously defined parameter. You must specify a column that contains the data. All defined parameters are displayed in the drop-down list. Note: at least one of the parameters must be sequential, random, or unique.
If the data table contains three columns, the three parameters are defined in the list: id1, name1, and title1, as follows :.
ID name title
132 Kim Manager
187 Cassie Engineer
189 Jane VP
For the id1 parameter, You can instruct the virtual user to use the random method. For the name1 and title1 parameters, you can specify the method "same line as id1 ". Therefore, once ID "132" is used, name "Kim" and title "manager" are used at the same time.

7. updta value on data update Method

7.1. Each iteration-get a new value for each repetition

7.2. each occurrence-set this parameter as long as it is found.

7.3. Once-the same value is used in all iterations

8. When out of values is out of range: (available only when data is set to unique)

8.1. Abort vuser-Abort

8.2. continue in a cyclic manner-continue cycle Value

8.3. Continue with last value-get the last value

9. Allocate vuser values in the Controller allocates values in the Controller: (only available when data is set to unique)

9.1. automatically allocate block size-automatic allocation

9.2. Allocate () values for each vuser-specify a value

6. import data from an existing database
LoadRunner allows you to use parameterization to import data from an existing database. You can use either of the following methods:
1. Use Microsoft query (MS query must be installed on the system first ).
2. Specify the database connection string and SQL statement.
The user script generator provides a wizard when importing data from the database. In the wizard, you specify how to import data-create a query statement through Ms query or directly write an SQL statement. After the data is imported, it is saved with the. dat suffix and as a regular parameter file. To start importing data to the database, click "Data wizard" in the parameter properties dialog box. The database query wizard is displayed.
To create a new Query
1. Select "create new query ". If you need Ms query help, select "show me how to use Microsoft query" and click "finish ".
If you have not installed Microsoft query, LoadRunner will prompt you that this function is unavailable. Install Ms query from Microsoft Office before proceeding.
2. Follow these steps in Microsoft query to import the expected tables and columns.
3. After the data is imported, select "exit and return to virtual user generator" and click "finish ". In the parameter properties dialog box, database records are displayed as data files.
To edit and view data in MS query, select View data or edit in Microsoft query ". To end, select "File> exit and return to virtual user generator" to return to the script generator.
4. In the "Select column" section, you can specify the column number or column name for a column that contains the current parameter data. Note: The column title is 0th rows (row 0) by default ).
5. Select an update method from the "select next row" list to show the virtual user how to select the data in the table during the process specified by the script. Optional options: sequential, random, unique, or same line. Meaning of each item Article I will not repeat it later.
6. If "advance row each iteration" is selected, the virtual user will use the data of a new row instead of repeating the same data during each iteration.
Specify database connection or SQL statement
1. Select "specify SQL statement" and click "Next ".
2. Click "CREATE" to specify a new connection string. The Select data source dialog box is displayed.
3. Select an existing data source or click "new" to create a new data source. The wizard prompts you through the process of creating an ODBC data source. After the connection is completed, the connection string is displayed in the connection string box.
4. In the SQL box, enter or paste the SQL statement.
5. Click "finish" to continue the SQL statement and import the data. Database records are displayed in the parameter properties box as data files.
6. In the "Select column" section, specify the columns that contain the current parameter data. You can specify the column number or column name.
7. Select an update method from the "select next row" list to show the virtual user how to select the data in the table during the specified procedure. Optional options: sequential, random, unique, or same line.
8. If you select "each iteration" from Update out of values, the virtual user will use the data of a new row instead of repeating the same data during each iteration.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.