This topic describes the parameter file and dynamic parameters used in microservices performance testing.
Parameter file
Make sure that you provide an Internet-accessible URL link to the parameter file. This way, users can easily download the parameter file. The platform distributes the parameter file to each load generator. Each time a microservices performance testing task retrieves a parameter, the task reads the next corresponding line from the parameter file in sequence. The parameter file also supports dynamic parameters.
The following guidelines can be used when you edit the parameter file:
Method parameter types: a JSON array of strings. Each element in the array defines the type of the corresponding parameter. For basic Java types, you can directly use the type names. For other types, you must provide the full class path.
Method parameters: a JSON array of strings. Each element in the array corresponds to a specific parameter of the method.
Examples
Method signature | Parameter type format | Parameter format |
Method signature | Parameter type format | Parameter format |
String sayHello(String name) | ["java.lang.String"] |
|
String helloBean(HelloBean helloBean) | ["com.alibaba.pts.dubbo.api.DemoService"] |
|
String helloList(List helloList1, List helloList2) | ["java.util.List","java.util.List"] |
|
String sayHello(String name) | ["java.lang.String"] |
|
Dynamic parameters
The Performance Testing Service (PTS) platform has built-in functions that allow for random parameter generation for microservice performance testing.
Each time an API is called, a dynamic parameter template is used to first generate parameters. Dynamic parameters are marked with a prefix ${__
and end with a suffix }
. When the platform executes an API call, it replaces the identifiers and the strings between the identifiers with dynamically generated strings and leaves other strings unchanged.
Generate a random number
Syntax
Result
Description
Syntax
Result
Description
${__Random(1,1000)}
First call: 3454
Second call: 67
Third call: 53
Generates a random number between 1 and 1000 for each API call.
["Tom",463${__Random(5,10)}]
First call: ["Tom",4635]
Second call: ["Tom",4637]
Third call: ["Tom",4638]
Generate a random number between 5 and 10. The ["Tom", and 463] strings outside the dynamic parameters remain unchanged.
Generate current time in different formats
Syntax
Result
Description
Syntax
Result
Description
${__time(,)}
1450056496991
The current time in milliseconds from January 1, 1970.
${__time(yyyyMMdd,)}
20151214
The current date in the YYYYMMDD format.
${__time(HHmmss,)}
092816
The current time in the HHMMSS format.
${__time(yyyyMMdd-HHmmss,)}
20151214-092816
The current date and time in the YYYYMMDD-HHMMSS format.
["time":"${__time(HHmmss,)}.log"]
["time":"053816.log"]
The ["time"," and .log"] strings outside the dynamic parameters remain unchanged.
Generate a random string
Syntax
Result
Description
Syntax
Result
Description
${__RandomString(5)}
faAfg
A random string of five letters, including uppercase and lowercase letters.
${__RandomString(5,abcd)}
aabdc
A string of 5 letters randomly selected from letters a, b, c, and d.
["name":"${__RandomString(5)}"]
["name":"abddc"]
The ["name"," and "] strings outside the dynamic parameters remain unchanged.
Randomly select a string or a number from a specified list of options
Syntax
Result
Description
Syntax
Result
Description
${__RandomSpecifiedString(aaa;;;bbb;;;ccc)}
bbb
Randomly selects a string from aaa, bbb, or ccc.
${__RandomSpecifiedString(111;;;222;;;333)}
333
Randomly selects a string from a 111, 222, or 333.
["name":"${__RandomSpecifiedString(aaa;;;bbb;;;ccc)}"]
["name":"ccc"]
The ["name"," and "] strings outside the dynamic parameters remain unchanged.
Use MVFLEX Expression Language (MVEL) expressions
Syntax
Result
Description
Syntax
Result
Description
${__Expression(3+5)}
8
Retrieves the value of the expression 3+5.
${__Expression(${__RandomSpecifiedString(100;;;200;;;300)}+5)}
105
Randomly takes a number from 100, 200, or 300 and then adds 5 to the selected number. The actual result may be 105, 205, or 305.
["time":"${__Expression(3*5)}"]
["time":"15"]
The ["time"," and "] strings outside the dynamic parameters remain unchanged.
Example:
Method:
String sayHello(String name)
Dynamic parameters:
["${__RandomString(4,abcdefg)}-${__RandomSpecifiedString(aaa;;;bbb;;;ccc)}-${__Expression(3+5)}]
Result:
["adag-ccc-8"]