Same as other script types, Taurus scripts can load test data from external CSV files and from BlazeMeter Data Entities.
Tip: The Test Data pane is visible only after you have uploaded or recorded a test script.
As with all test types, BlazeMeter supports the following data sources to provide test data to a Performance test:
- Load Test Data from Spreadsheets
- Generate Synthetic Test Data
- Find Test Data (TDM Find & Reserve Model Integration)
You can use one or combine multiple data sources in a Taurus test, as needed. For more information about BlazeMeter's test data integration in general, see What are Data Entities and Data Parameters? and How to Use Test Data.
Example Scenario
This article assumes a scenario where you already have a Taurus Performance test in YAML format. The Performance test sends requests to the online store endpoint at http://blazedemo.com/buy/123-phone. You want to use more varied test data in place of the product id "123" and the product name "phone". To do this, you have the option to load existing data from a CSV file or let BlazeMeter generate synthetic test data.
Prepare your test data
Create a Performance test.
Upload the Taurus script with hard-coded test data. For example:
TaurusPerformanceTest.yamlexecution: - concurrency: 100 ramp-up: 1m hold-for: 1m30s scenario: simple scenarios: simple: think-time: 0.75 requests: - http://blazedemo.com/buy/123-phone # hard-coded test data "123-phone"
Open the Test Data pane.
Create Test Data Entities using one or more of the following methods:
Upload a CSV file and attach it to the test.
Example: Upload "MyTestDataFile.csv" which contains the columns id and name.Create a Data Entity for the test.
Example: Create "MyDataEntity1" that contains synthetic test data which contains the Data Parameters randomid and randomname.Load a shared Data Entity from the BlazeMeter Workspace.
Example: Load "myshareddata.csv" from "MyTeamFolder" which contains the columns username and password.
Identify the Data Parameter names that you want to use in the test.
Examples:To use values from the CSV column id, reference ${id}.
To use values from the CSV column name, reference ${name}.
To use the synthetic randomid, reference ${randomid}.
To use the synthetic randomname, reference ${randomname}.
To use the shared username, reference ${username}.
To use the shared password, reference ${password}.
And so on.
Prepare the Taurus test
Adding the data-sources section to the Taurus script is optional when a Data Entity is associated with the test in BlazeMeter. When a test is executed, BlazeMeter dynamically adds any Data Entities associated with the test, using default Data Settings.
Edit the Taurus Test in the Test Configuration.
- Parameterize the request by replacing the hard-coded values.
For example, replace "123" and "phone" by ${id} and ${name}.
http://blazedemo.com/buy/${id}-${name} - (Optional) To override the default Data Settings, define your Data Entities in the data-sources section of the Taurus file.
Use the following options:
- path
Defines the path to an attached CSV file or Data Entity. To identify the implicit file name of the Data Entity, click the info button next to its name.
Example: Reference the Data Entity MyDataEntity1 as MyDataEntity1.csv. - delimiter
Defines the CSV delimiter.
Default: Auto detect
Values: '.' for dot, ',' for comma, 'tab' for a tab symbol. - quoted
Interprets the CSV columns as quoted data. Can be true of false.
Default: auto detect - encoding
Defines the encoding type.
Example: "utf-8" - loop
Defines the behavior when BlazeMeter reaches the end of the test data: If set to true, we loop over and continue again from the beginning of the test data. If set to false, we stop looping. - variable-names
Defines the comma-separated list of Data Parameter names for the CSV columns. If the first row of the CSV file already contains column headings, leave this option empty. If the first row contains data, define column name mappings here; to skip a column in the mapping, add an extra comma with no name.
Default: The first line of the CSV file is used as Data Parameter names.
Example: variable-names: id,name
- path
For more information about the options, see https://gettaurus.org/docs/DataSources/.
The Taurus script now looks like the following example:
TaurusPerformanceTest.yaml:
execution: - concurrency: 100 ramp-up: 1m hold-for: 1m30s scenario: simple scenarios: simple: think-time: 0.75 requests: - http://blazedemo.com/buy/${id}-${name} # use Data Parameters in test # list your Data Entities data-sources: - path: MyTestDataFile.csv # load Data Parameter values from a CSV file delimiter: ',' quoted: false encoding: "utf-8" loop: true variable-names: id,name # define Data Parameter names for columns
To override the default Data Settings of other data sources, such as shared files from the BlazeMeter Workspace or synthetic data from a Data Entity, add more paths and settings. For example:
- path: MyTeamFolder/myshareddata.csv # load shared Data Entity from the Workspace...
variable-names: username,,password # skip the second column, rename the first and third
- path: MyDataEntity1.csv # load Data Parameter values from a Data Entity...
loop: false # don't loop this data
Preview Test Data
Previewing your test data is helpful when you are combining data from multiple files, or generating synthetic test data, so you can review values in context.
- Open a Performance Test with test data attached.
- Verify that at least one data parameter is defined to be able to generate the data preview.
- Click Test Data, Data Settings.
The Test Data Settings window opens and shows the data preview.
0 Comments