Use system functions
In complex business scenarios, an API request body may contain parameters that change over time or with each request. You can use system functions to dynamically generate request body content. For APIs that use a cache, generating a different request body for each request prevents cache hits that could skew test results. In the PTS console, you can use the function generator to create functions, and then combine, replace, nest, or append strings as needed. This topic uses request body parameterization to demonstrate how to use system functions.
Procedure
- Log on to the PTS console. In the navigation pane on the left, choose performance testing > Create Scenario, and then click PTS stress test.
-
On the Create PTS scene page, on the Scene configuration tab, configure basic request information. For more information, see Basic request information.
NoteThis example demonstrates parameterization for a request body. The request method is set to POST or PUT. In your actual stress test, select the method that meets your specific requirements.
-
In the lower-left corner of the Create PTS scene page, click System functions to view the list of supported functions.
-
In the System functions panel, click the name of a function to copy it.
-
Optional: If the functions available in the System functions panel do not meet your requirements, use the function generator to create a custom function.
-
At the bottom of the System functions panel, click Function generator or the
icon in a function row. -
In the Function generator panel, select a function type and click Debug to verify the output.
-
Select Add as a global custom parameter and enter a variable name.
This adds the function to the list of global variables, allowing it to be referenced throughout the stress test scene.
-
Click Copy and Add to copy the function expression.
-
-
In the editor for the API's request body, paste the function and edit it as needed, such as by combining it with strings, parameters, or other functions. For more information about how to define a request body, see request body.
Note-
You can use arithmetic operations to combine functions. For more information, see Use arithmetic operations.
-
When you nest parameters within a system function, you must use double quotation marks (""). Single quotation marks ('') are not supported. For more information, see How do I combine and nest system functions and strings?.
-