Multistep Tests¶
Multistep Tests are advanced monitoring tools that simulate complex business processes or user operation paths by chaining multiple API requests. They allow the creation of tests using the response data from multiple API connections, thereby validating critical business transactions, simulating end-to-end user journeys, and supporting authentication and authorization. This testing method proactively monitors the availability and performance of services, ensures the normal operation of complex processes, and alerts promptly when issues arise.
Create¶
Click Tasks > Create > Multistep Tests.
1. Basic Information¶
- Define the test task name;
- Fill in the description as needed.
2. Select Test Nodes¶
Currently, TrueWatch has covered 14 test nodes globally. You can select one or more nodes in China or overseas (only for Commercial Plan and above users) to quickly start monitoring the service quality of the site.
3. Select Test Frequency¶
Select the execution frequency of the test task, with the following options:
- 1 minute (only for Commercial Plan and above users)
- 5 minutes (only for Commercial Plan and above users)
- 15 minutes (only for Commercial Plan and above users)
- 30 minutes
- 1 hour
- 6 hours
- 12 hours
- 24 hours
4. Define Request Steps¶
Click Create First Request.
Name¶
Define the request name.
Define Request Format¶
- Define the request URL;
- Perform Advanced Settings as needed.
Availability Judgment¶
Default Mode¶
Define the success conditions of the test results by adding judgment conditions.
Multiple conditions can be combined using "All" or "Any" to achieve AND or OR logic.
Type | Operator |
---|---|
Response Body | Contains , Does not contain , Is , Is not , Regex match , Regex does not match |
Request Header | Contains , Does not contain , Is , Is not , Regex match , Regex does not match |
Response Time | Less than |
Status Code | Is , Is not , Regex match , Regex does not match |
Script Mode¶
In Multistep Tests, the script mode allows the following functions by writing Pipeline scripts:
- Set judgment conditions: Customize complex judgment logic based on business needs, supporting single or multiple condition combinations;
- Process result data: Customize the processing of test results, including data cleaning, format conversion, etc.;
- Extract fields and define variables: Extract specific fields from the response and define them as variables for reuse in subsequent steps.
The script mode flexibly meets the needs of extracting specific fields from the response or performing complex condition judgments.
Example:
body = load_json(response["body"])
if body["code"] == 200 {
result["is_failed"] = false
vars["token"] = body["token"]
} else {
result["is_failed"] = true
result["error_message"] = body["message"]
}
In the above script, load_json
is first used to parse the response content into a JSON object, then it checks if the response status code is 200. If it is 200, the token
from the response content is extracted and stored in vars
for use in subsequent requests; otherwise, is_failed
in result
is set to true
, and error_message
is set to the message
from the response content.
For more reading, refer to Custom Test Tasks.
Local Variables¶
Local variables defined in the current Multistep Test can be referenced in subsequent request steps.
Note
The corresponding fields must first be extracted in the script to define variables.
- Enter the variable name, generally supporting uppercase letters, numbers, underscores, and no duplicates;
- Select the variable value, i.e., the field defined as a variable in the script mode;
- Optionally choose to encrypt the variable value. Once checked, the current variable value will be hidden in the test results.
The created variables are displayed in the "Variables" area at the top left.
You can reference local variables in the Define Request Format > Advanced Settings > Request Header.
As shown, the local variable {DS_ID}
has been defined in Step 1, with the value dashboard_id
. In Request 2, you can directly reference this variable value in the URL.
To manage these variables, click the button on the right in the "Local Variable Configuration" area to edit or delete them.
Note
- After deleting a local variable, requests in the current Multistep Test that reference this variable will no longer be able to use it;
- After modifying a local variable name, steps that reference the original name will no longer recognize the variable.
Execution Settings¶
Select "If this step fails, continue to the next step" to skip errors and continue executing subsequent steps when the current step fails.
Test¶
After creating the task steps, click the "Test" button to quickly verify the test results. The system will provide the following information for reference:
- Test Performance: Display performance metrics during the test.
- Response Details: Provide detailed response content to help troubleshoot issues.
- Variables: View the variables configured in the current task's requests and URL.
If you start testing from a step after the first request task, you can directly test the current task or choose to start testing from the first task.
If the test fails, there may be unknown variables. Click the "Test from the first step to the current request" button to re-initiate the test for troubleshooting.
Continue Creating Request Steps¶
After creating the first test task, you can continue "Create HTTP Request" or "Create Waiting Step".
Note
Up to 10 steps can be created (including HTTP requests and waiting).
Waiting Step¶
Indicates waiting for a specific duration before continuing to the next step, with durations of 1 second, 5 seconds, 15 seconds, 30 seconds, 1 minute, 2 minutes, or 3 minutes.
Manage Tasks¶
After creating the request steps, click save.
For the created tasks, you can manage them through the following operations:
- Click the drag icon on the left of the task to change the order of the steps;
- Click the on the right of the task to clone or delete this step;
- Click "Batch" to clone or delete tasks in bulk.
Note
When cloning request steps, local variables cannot be cloned together.