All Products
Search
Document Center

Performance Testing:Import scripts to scenarios

Last Updated:Nov 01, 2024

Performance Testing Service (PTS) allows you to import Postman (JSON), HTTP Archive (.har), YAML (.yml), and Swagger (.json) scripts to scenarios and convert them to PTS-native formats for performance testing. PTS provides the requests per second (RPS) performance testing mode, allows real-time adjustment of the testing parameters, and can track performance metrics of individual APIs.

Scripts

To conduct performance testing on HTTP or HTTPS applications, PTS can extract and convert essential request information from scripts in various formats, including Postman (JSON), HTTP Archive (.har), YAML (.yml), and Swagger (.json) into API fields suitable for the performance testing scenarios.

Mappings between Postman script fields and PTS API fields

Postman script field

PTS API field

info.name

The name of the session.

item[]

The APIs.

item[0].name

The name of the API.

item[0].request.method

The request method.

item[0].request.url.raw

The requested URL.

item[0].request.header

key

The key of the header.

value

The value of the header.

item[0].request.body

For a POST request, the Content-Type header in the request specifies how the body data is interpreted or displayed on the receiving end.

Note
  • In a Postman (JSON) script, multiple info.name objects can exist at the same level but the item objects cannot be at the same level as the info.name objects.

  • To export Collections from a Postman (JSON) script, use version 2.1.

  • You can specify only the GET, POST, PUT, and DELETE HTTP methods in Postman (JSON) scripts.

  • You cannot specify the file mode in Postman (JSON) scripts.

  • You cannot specify file uploading or binary Content-Type header in Postman (JSON) scripts.

Mappings between YAML script fields and PTS API fields

Table 1. Basic items

YAML script field

PTS API field

Relations

The sessions.

Relation

The session.

Disabled

Specifies whether the session is disabled.

ID

The ID of the session.

Name

The name of the session.

Nodes

The nodes.

Name

The name of the node.

NodeId

The ID of the node.

NodeType

The type of the node.

Config

The node settings.

Table 2. Node types

YAML script field

PTS API field

chain

The API node

wait

The think time node.

condition

The conditional jump node.

dam

The rendezvous point.

dataInit

The data configuration node.

dataStore

The data export node.

dataDefine

The data command node.

delay

The delay node.

repeatBegin

The looping command start node.

repeatEnd

The looping command end node.

ifBegin

The condition-based command start node.

ifEnd

The condition-based command end node.

Table 3. Node settings

Category

YAML script field

PTS API field

chain

accessId

The ID of the protocol.

beginStep

Specifies the initial number of virtual users on the session in the virtual user mode and the initial requests per second (RPS) on the API in the RPS mode.

checkPoints

The checkpoints.

  • The checkpoint.

    • expectValue: the expected value.

    • operator: the operator.

      • gt: greater than

      • gte: greater than or equal to

      • lt: less than

      • lte: less than or equal to

      • eq: equal to

      • n_eq: not equal to

      • ctn: contains

      • n_ctn: does not contain

      • exist: exists

      • n_exist: does not exist

      • belong: belongs to

      • n_belong: does not belong to

      • regex_match: regular expression match

  • point: the item to be checked.

  • type: the checkpoint type. Valid values:

    • BODY_TEXT: the response body in plain text format.

    • BODY_JSON: the response body in JSON format.

    • HEADER: the HTTP headers.

    • COOKIE: the cookies.

    • STATUS_CODE: the HTTP response status code.

    • EXPORTED_PARAM: the parameters that are exported from the response.

endStep

Specifies the maximum number of virtual users on the session in the virtual user mode and the maximum RPS on the API in the RPS mode.

headers

The HTTP header settings.

  • name: the key of the header.

  • value: the value of the header.

method

The request method. Valid values: GET, POST, PUT, and DELETE.

postActions

Post-testing actions:

  • type: the type of the action. Only export is supported.

  • params: the output parameter settings.

    • name: the name of the parameter.

    • value: the output parameter expression.

    • type: the same as the checkpoint type.

body

The request body. This field is available only for the POST or PUT method.

  • contentType: the type.

  • value: the body content.

preActions

Pre-texting actions:

protocol

The protocol type. Default: http.

redirectCountLimit

Specifies whether to redirect the requests. A value of 0 indicates that the requests are not redirected. A value of 10 indicates that the requests are redirected.

timeoutInMilliSeconds

The timeout period. Unit: milliseconds.

condition

defaultAction

The default action. Valid values:

  • action: the action.

    • jump: jumps to a different path.

    • continue: continues along the current path.

    • return: ends the process.

  • target: the ID of the API.

  • conditions: the conditions.

    • param: the name of the parameter.

    • operator: the operator.

    • value: the comparison value.

actions

The added condition.

dam

type

The rendezvous point type.

  • BY_TIME.

  • BY_USER.

target

The load level.

datalnit

definitions

The key-value pair structure, corresponding to custom parameters.

references

The referenced file parameters.

  • column: the name of the column.

  • fileKey: the index of the file.

  • FileName: the name of the file.

  • useOnce: specifies whether to use the file parameters once.

  • asBase: specifies whether to use the column as the base column.

  • accessMethod: the access method.

    • inOrder.

    • inRandom.

  • index: the index of the column.

dataDefine

definitions

The key-value pair structure.

dataStore

dataSize

The data export level.

dataConfig

The data export setting.

  • type: The type.

    • COOKIE: the cookie type.

    • FILE: the file parameter type.

    • PARAM: the output parameter type.

    • INSTRUCTION: the data command type.

  • params: the parameters.

delay

duration

The delayed amount of time. Unit: milliseconds.

ifBegin

ifEndNodeId

The ID of the end node of the condition-based command.

operator

The operator.

param

The expression.

value

The comparison value.

ifEnd

ifBeginNodeId

The ID of the start node of the condition-based command.

repeatBegin

repeatEndNodeId

The ID of the end node of the looping command.

repeatEnd

repeatBeginNodeId

The ID of the start node of the looping command.

repeatCount

The repeated number of times.

wait

type

  • FIXED: a constant value for the delay.

  • NORMAL: a uniform distribution for the delay.

  • UNIFORM: a normal distribution for the delay.

base

Specifies the constant delay value if type is set to FIXED, the baseline delay if type is set to NORMAL, and the average or mean delay if type is set to UNIFORM.

scope

The field is irrelevant if type is set to FIXED, the variable range around the base if type is set to NORMAL, and the variance if type is set to UNIFORM.

Mappings between the Swagger script fields and PTS API fields

Swagger script field

PTS API field

paths.key

The requested URL.

paths.key.key

The request method.

paths.key.key.parameters

The request parameters or request body.

definitions

The schema used in the request body.

tags[0].name

The name of the session.

Procedure

On the Create Scenario page, select a script type, upload a script, and then click OK.

After the script is imported, you can see that the script content is converted into the corresponding API performance testing information on the Create PTS Scenario page.

Note
  • The valid script types are Postman (JSON), HTTP Archive (.har), YAML (.yml), and Swagger (.json). You can import only one script to a performance testing scenario. Before you save the scenario configuration, you can upload another script to override the imported script.

  • For information about the scripts that can be imported to PTS and the description of script fields, see Scripts. Do not import a script that contain types or protocols that are not supported by PTS. If you upload a non-compliant script, an error dialog box appears in the PTS console.