Parameter description

Updated at:

This topic describes the rules for using parameter file URLs and invoking dynamic parameters in microservice stress testing.

Parameter File URL: Provide a URL for a publicly downloadable file

The platform distributes the parameter file to each load generator. For each call, the application reads a line from the file in sequential order. The file also supports dynamic function parameters.

Parameter file format:
  • Method parameter type: A JSON array of strings. Each element in the array represents the parameter type at the corresponding position. For types other than Java primitive data types, enter the full class path.
  • Method parameter: A JSON array of strings. Each element in the array represents the parameter at the corresponding position.

The details are as follows:

MethodParameter type formatFile parameter format
String sayHello(String name)["java.lang.String"]示例1
String helloBean(HelloBean helloBean)["com.alibaba.pts.dubbo.api.DemoService"]代码2
String helloList(List helloList1, List helloList2)["java.util.List","java.util.List"]示例3
String sayHello(String name)["java.lang.String"]示例4

Dynamic parameters

PTS microservice stress testing includes several built-in functions to generate simple random parameters.

Each time the platform calls an API, it first generates the actual parameters from a dynamic parameter template and then invokes the API with these parameters. A dynamic parameter starts with the identifier ${__ and ends with the identifier }. At runtime, the platform replaces the identifiers and the entire string between them with a dynamically generated string. All other strings remain unchanged.

  1. Generate random numbers
    Example inputResultDescription
    ${__Random(1,1000)}
    • First time: 3454
    • Second time: 67
    • Third time: 53
    A random number between 1 and 1000.
    ["Tom",463${__Random(5,10)}]
    • First time: ["Tom",4635]
    • Second time: ["Tom",4637]
    • Third time: ["Tom",4638]
    A random number between 5 and 10. The strings outside the dynamic parameter, `["Tom",` and `463]`, remain unchanged.
  2. Generate the current time in different formats
    Example inputResultDescription
    ${__time(,)}1450056496991Gets the number of milliseconds from January 1, 1970, to the present.
    ${__time(yyyyMMdd,)}20151214Formats the current time as YYYYMMDD.
    ${__time(HHmmss,)}092816Formats the current time as HHmmss.
    ${__time(yyyyMMdd-HHmmss,)}20151214-092816Formats the current time as YYYYMMDD-HHmmss.
    ["time":"${__time(HHmmss,)}.log"]["time":"053816.log"]Strings that are not dynamic parameters, such as ["time", "and.log"], remain unchanged.
  3. Generate random strings
    Example inputResultDescription
    ${__RandomString(5)}faAfgA random string of 5 uppercase and lowercase English letters.
    ${__RandomString(5,abcd)}aabdcA random string of 5 English letters selected from a, b, c, and d.
    ["name":"${__RandomString(5)}"]["name":"abddc"]Strings that are not dynamic parameters, such as ["name", "and"], remain unchanged.
  4. Generate a random string or number from a specified list
    Example inputResultDescription
    ${__RandomSpecifiedString(aaa;;;bbb;;;ccc)}bbbRandomly selects a string from aaa, bbb, or ccc.
    ${__RandomSpecifiedString(111;;;222;;;333)}333Randomly selects a string from 111, 222, or 333.
    ["name":"${__RandomSpecifiedString(aaa;;;bbb;;;ccc)}"]["name":"ccc"]Strings other than dynamic parameters, such as ["name", "and"], are preserved.
  5. MVEL expressions
    Example inputTransformation resultDescription
    ${__Expression(3+5)}8Gets the value of the expression 3+5.
    ${__Expression(${__RandomSpecifiedString(100;;;200;;;300)}+5)}105Nested expressions. A number is randomly selected from 100, 200, or 300 and added to 5. The result can be 105, 205, or 305.
    ["time":"${__Expression(3*5)}"]["time":"15"]Strings that are not dynamic parameters, such as ["time", "and"], are not modified.
Complex parameter example
  • API function call: String sayHello(String name)
  • Dynamic parameter format: ["${__RandomString(4,abcdefg)}-${__RandomSpecifiedString(aaa;;;bbb;;;ccc)}-${__Expression(3+5)}"]
  • Actual parameter: ["adag-ccc-8"]