File data source

Updated at:

A file data source is typically used with a data configuration node for scenarios that require custom performance test requests, such as simulating user logins with specific accounts. This topic describes how to use a file data source.

Limitations

You can add a data configuration node to a PTS performance test scenario or an MSE gateway performance test scenario. Other performance test scenarios do not support this feature. However, you can still reference file parameters by using the ${parameter name} format.

Background information

To use a file data source, you must upload a parameter file to the PTS console or to OSS. The parameter file must meet the following requirements:

  • The file can be in CSV or ZIP format. A ZIP archive must contain a single .csv file.

    Note

    We recommend exporting the file from software like Excel or Numbers, or generating it using a program like Apache Commons CSV.

  • Do not include a header row with column names in the parameter file. Start with parameter data from the first line. If your file includes a header row, select the first line as header option when you upload the file. This tells PTS to ignore the first line.

  • You can upload multiple files.

  • A single line in the file cannot exceed 20,000 characters.

  • If you need to combine data from multiple sources into a single parameter set, you do not need to merge them into one file. You can use the file parameter settings in the data configuration node to combine data from different files.

  • If you reference parameters from multiple files, you can specify a baseline column to establish the combination baseline. If you do not specify a baseline column or a parameter for which Data is polled once, the system randomly designates a file to provide the baseline column. For more information, see How PTS reads multi-file parameters in concurrent and RPS modes.

  • If parameters have a strict one-to-one relationship, make sure to place them in the same file and align them correctly. Each row must contain a complete set of data for all columns. Otherwise, empty fields can occur and skew your test data. For example, a parameter file could contain two columns for Username and Password parameters.

    john,123456  
    mike,234567  
    lilei,345678

Step 1: Create file parameters

  1. Log on to the PTS console. In the left-side navigation pane, choose Performance testing > Create scenario, and then click PTS performance test.

  2. On the Create PTS scenario page, click data source management at the bottom.

  3. You can upload a parameter file in one of the following ways:

    • Method 1: Upload a file.

      1. On the File data source tab of the data source management panel, click + Upload File. In the dialog box, select a local parameter file and click Open.

        Note

        You can also select a previously uploaded parameter file.

      2. Decide whether to select first line as header.

        Note

        If you select first line as header, PTS skips the first row when reading the parameter file. This option allows you to use the header to define parameter names automatically. If you do not select this option, you must manually define the parameter name for each column.

    • Method 2: Configure an OSS file. For more information, see Create an OSS data source.

  4. Click Save.

Step 2: Add a data configuration node

The data configuration node lets you specify a parameter from the global file parameters as the baseline column, which enables you to use all data in the parameter files. You can also redefine parameters, and these redefinitions apply only to the current test flow.

  1. On the Scenario configuration tab, click the arrow next to Add step and select Data configuration from the drop-down list.

  2. Click the expand icon next to Data configuration and configure the parameters on the Data source parameter settings tab.

    Note

    You can also click the Custom parameter tab to redefine parameters.

Step 3: Use the created parameters

  1. On the Create PTS scenario page, click Parameter list at the bottom.

  2. On the Test flow parameter tab, click the copy icon in the test flow area. This action automatically copies the parameter content.

  3. Click the expand icon next to the target API, and then click the Body definition tab. Paste the parameter content into the editor and edit the body as needed, for example, by combining strings, parameters, or functions.

Note

For GET requests, you can use parameters in the URL and header definitions.