Signature Conventions
Request Signatures
func(map[string]string) interface{}
Input parameters: CodeArts PerfTest built-in parameters and custom parameters.
Output parameters: The IResultV1 interface needs to be implemented. If necessary, use IResultV1 Interface Implementation provided by CodeArts PerfTest.
|
Name |
Description |
Remarks |
|---|---|---|
|
__name |
Name of a request |
- |
|
__goroutine_id |
Coroutine ID |
- |
|
__executor_index |
Executor index |
The sequence number starts from 0. |
|
__executor_count |
Total number of executors |
- |
Function Signatures
func(map[string]string) string
Input parameters: custom parameters
Output parameters: character strings
Checkpoint Signatures
func(map[string]string) string
Input parameters: custom parameters
Output parameters: character strings. An empty character string indicates that the check is successful, and a non-empty character string indicates the check fails.
IResultV1 Interface Implementation
package main
import (
"fmt"
"time"
)
const (
InnerVarName = "__name"
InnerVarGoroutineId = "__goroutine_id"
InnerVarExecutorIndex = "__executor_index"
InnerVarExecutorCount = "__executor_count"
)
type IResultV1 interface {
GetName() string
GetUrl() string
GetMethod() string
GetRequestHeader() map[string]string
GetRequestBody() string
GetSentBytes() int
GetResponseCode() int
GetResponseHeader() map[string]string
GetResponseBody() string
GetReceivedBytes() int
GetFailureMessage() string
IsSuccess() bool
GetBeginTime() int64
GetEndTime() int64
GetSubResults() []interface{}
}
//acquireResult generates root result.
//just call one time on the main func and generate sub result using parent.addSub()
func acquireResult(name string) *Result {
result := &Result{}
result.Name = name
result.RequestHeader = map[string]string{}
result.ResponseHeader = map[string]string{}
result.ResponseCode = 200
result.Success = true
result.BeginTime = time.Now().UnixMilli()
result.EndTime = time.Now().UnixMilli()
return result
}
type Result struct {
Name string
Url string
Method string
RequestHeader map[string]string
RequestBody string
SentBytes int
ResponseCode int
ResponseHeader map[string]string
ResponseBody string
ReceivedBytes int
FailureMessage string
Success bool
BeginTime int64
EndTime int64
SubResults []interface{}
SubIndex int
}
func (r *Result) GetName() string {
return r.Name
}
func (r *Result) GetUrl() string {
return r.Url
}
func (r *Result) GetMethod() string {
return r.Method
}
func (r *Result) GetRequestHeader() map[string]string {
return r.RequestHeader
}
func (r *Result) GetRequestBody() string {
return r.RequestBody
}
func (r *Result) GetSentBytes() int {
return r.SentBytes
}
func (r *Result) GetResponseCode() int {
return r.ResponseCode
}
func (r *Result) GetResponseHeader() map[string]string {
return r.ResponseHeader
}
func (r *Result) GetResponseBody() string {
return r.ResponseBody
}
func (r *Result) GetReceivedBytes() int {
return r.ReceivedBytes
}
func (r *Result) GetFailureMessage() string {
return r.FailureMessage
}
func (r *Result) IsSuccess() bool {
return r.Success
}
func (r *Result) GetBeginTime() int64 {
return r.BeginTime
}
func (r *Result) GetEndTime() int64 {
return r.EndTime
}
func (r *Result) GetSubResults() []interface{} {
return r.SubResults
}
//begin records begin time, do not forget call this function to update
func (r *Result) begin() {
r.BeginTime = time.Now().UnixMilli()
}
//end records end time, do not forget call this function to update
func (r *Result) end() {
r.EndTime = time.Now().UnixMilli()
}
//addSub adds sub result to parent, call this function adding sub result always.
//if name is not empty, renaming will be disabled
func (r *Result) addSub(name string) *Result {
if name == "" {
name = fmt.Sprintf("%s-%d", r.Name, r.SubIndex)
r.SubIndex++
} else {
name = fmt.Sprintf("%s-%s", r.Name, name)
}
sub := acquireResult(name)
r.SubResults = append(r.SubResults, sub)
return sub
}
|
Name |
Description |
Remarks |
|---|---|---|
|
Name |
Name of a request |
The root result must be set using the built-in parameter __name. |
|
Url |
Request URL |
- |
|
Method |
Method |
Used for HTTP POST and GET. |
|
RequestHeader |
Request header |
Used for HTTP |
|
RequestBody |
Request data |
Do not record data with a large request size, for example, uploading a file. You only need to record the abstract. |
|
SentBytes |
Number of bytes sent |
- |
|
ResponseCode |
Response code |
Response status, which can be used for HTTP status codes or custom status codes. It is used to report the number of response statuses for analysis. Response code range: 100–599 |
|
ResponseHeader |
Response header |
Used for HTTP. |
|
ResponseBody |
Response data |
Do not record data with a large response, for example, downloading a file. You only need to record the abstract. |
|
ReceivedBytes |
Bytes received |
- |
|
FailureMessage |
Failure message |
- |
|
Success |
Whether the request is successful |
- |
|
BeginTime |
Request start time |
Unit: ms |
|
EndTime |
Request end time |
Unit: ms |
|
SubResults |
Sub-request |
When a custom request has multiple sub-requests, this field is used to record the execution status of each sub-request. |
|
SubIndex |
Sub-request index |
When the addSub method of the parent result is used to generate a sub-result, and the sub-result name is not customized, this field is used to generate an index for generating the sub-result name. |
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot