Documentation
¶
Index ¶
- func PerfTestAgentCMD() *cobra.Command
- func PerfTestCollectorCMD() *cobra.Command
- func PerfTestHTTP2CMD() *cobra.Command
- func PerfTestHTTP3CMD() *cobra.Command
- func PerfTestHTTPCMD() *cobra.Command
- type Agent
- type AgentInfo
- type AgentStatus
- type Builder
- type CollectorServer
- type HTTPReqParams
- type PerfTestData
- type PerfTestHTTP
- type Result
- type Statistics
- type TestSession
- type TestStatus
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func PerfTestAgentCMD ¶ added in v1.15.3
PerfTestAgentCMD is the command for performance testing agent
func PerfTestCollectorCMD ¶ added in v1.15.3
PerfTestCollectorCMD is the command for running collector performance test for HTTP API
func PerfTestHTTP2CMD ¶
PerfTestHTTP2CMD creates a new cobra.Command for HTTP/2 performance test.
func PerfTestHTTP3CMD ¶
PerfTestHTTP3CMD creates a new cobra.Command for HTTP/3 performance test.
func PerfTestHTTPCMD ¶
PerfTestHTTPCMD creates a new cobra.Command for HTTP/1.1 performance test.
Types ¶
type Agent ¶ added in v1.15.3
type Agent struct {
// config info
ID string
CollectorHost string
AgentHost string
TestURL string
TestMethod string
// contains filtered or unexported fields
}
Agent is the core structure of performance testing services
type AgentInfo ¶ added in v1.15.3
type AgentInfo struct {
ID string `json:"id"`
Callback string `json:"callback"`
URL string `json:"url"`
Method string `json:"method"`
Status AgentStatus `json:"status"`
}
AgentInfo store registered agent information
type AgentStatus ¶ added in v1.15.3
type AgentStatus string
AgentStatus defined agent status
const ( AgentStatusIdle AgentStatus = "idle" AgentStatusRegistered AgentStatus = "registered" AgentStatusRunning AgentStatus = "running" AgentStatusFinished AgentStatus = "finished" AgentStatusStopped AgentStatus = "stopped" AgentStatusCanceled AgentStatus = "canceled" )
type Builder ¶ added in v1.15.3
func (*Builder) WriteString ¶ added in v1.15.3
func (*Builder) WriteStringf ¶ added in v1.15.3
type CollectorServer ¶ added in v1.15.3
CollectorServer manage all test sessions
func NewCollectorServer ¶ added in v1.15.3
func NewCollectorServer(port int, collectorHost string) (*CollectorServer, error)
func (*CollectorServer) Run ¶ added in v1.15.3
func (s *CollectorServer) Run(printHelp func()) error
Run collector server.
type HTTPReqParams ¶
type PerfTestData ¶ added in v1.15.3
type PerfTestData struct {
ID string `json:"id"` // test id
URL string `json:"url"` // test url
Method string `json:"method"` // test method
TotalDuration float64 `json:"total_duration"` // unit: s
TotalRequests int64 `json:"total_requests"`
SuccessCount int64 `json:"success_count"`
ErrorCount int64 `json:"error_count"`
QPS float64 `json:"qps"` // unit: req/sec
AvgLatency float64 `json:"avg_latency"` // unit: ms
P25Latency float64 `json:"p25_latency"` // unit: ms
P50Latency float64 `json:"p50_latency"` // unit: ms
P95Latency float64 `json:"p95_latency"` // unit: ms
P99Latency float64 `json:"p99_latency"` // unit: ms
MaxLatency float64 `json:"max_latency"` // unit: ms
MinLatency float64 `json:"min_latency"` // unit: ms
TotalSent int64 `json:"total_sent"` // unit: bytes
TotalReceived int64 `json:"total_received"` // unit: bytes
StatusCodes map[int]int64 `json:"status_codes"`
CreatedAt string `json:"created_at"`
Status string `json:"status"` // running, finished, stopped
AgentID string `json:"agent_id"` // agent identify
Errors []string `json:"errors"` // error details
}
PerfTestData test statistics data
type PerfTestHTTP ¶
type PerfTestHTTP struct {
ID string // performance test ID
Client *http.Client
Params *HTTPReqParams
Worker int
TotalRequests uint64
Duration time.Duration
PushURL string
PrometheusJobName string
// contains filtered or unexported fields
}
PerfTestHTTP performance test parameters for HTTP
func (*PerfTestHTTP) Run ¶ added in v1.15.3
Run the performance test with fixed number of requests or fixed duration.
func (*PerfTestHTTP) RunWithFixedDuration ¶
func (p *PerfTestHTTP) RunWithFixedDuration(globalCtx context.Context) (*Statistics, error)
RunWithFixedDuration implements performance with a fixed duration.
func (*PerfTestHTTP) RunWithFixedRequestsNum ¶
func (p *PerfTestHTTP) RunWithFixedRequestsNum(globalCtx context.Context) (*Statistics, error)
RunWithFixedRequestsNum implements performance with a fixed number of requests.
type Statistics ¶
type Statistics struct {
ID string `json:"id"` // Performance Test ID
URL string `json:"url"` // performed request URL
Method string `json:"method"` // request method
Body string `json:"body"` // request body (JSON)
TotalRequests uint64 `json:"total_requests"` // total requests
TotalDuration float64 `json:"total_duration"` // total duration (seconds)
SuccessCount uint64 `json:"success_count"` // successful requests (status code 2xx)
ErrorCount uint64 `json:"error_count"` // failed requests (status code not 2xx)
Errors []string `json:"errors"` // error details
QPS float64 `json:"qps"` // requests per second (Throughput)
AvgLatency float64 `json:"avg_latency"` // average latency (ms)
P25Latency float64 `json:"p25_latency"` // 25th percentile latency (ms)
P50Latency float64 `json:"p50_latency"` // 50th percentile latency (ms)
P95Latency float64 `json:"p95_latency"` // 95th percentile latency (ms)
P99Latency float64 `json:"p99_latency"` // 95th percentile latency (ms)
MinLatency float64 `json:"min_latency"` // minimum latency (ms)
MaxLatency float64 `json:"max_latency"` // maximum latency (ms)
TotalSent int64 `json:"total_sent"` // total sent (bytes)
TotalReceived int64 `json:"total_received"` // total received (bytes)
StatusCodes map[int]int64 `json:"status_codes"` // status code distribution (count)
CreatedAt time.Time `json:"created_at"` // created time
Status string `json:"status"` // running, finished
AgentID string `json:"agent_id"` // identify agent
}
Statistics performance test statistical data
func (*Statistics) Save ¶
func (s *Statistics) Save(filePath string) error
Save saves the statistics data to a JSON file.
type TestSession ¶ added in v1.15.3
type TestSession struct {
sync.Mutex
TestID string
Status TestStatus
ExpectedAgents int
Agents map[string]*AgentInfo
TestingReports map[string]PerfTestData // agentID -> PerfTestData
FinalReports map[string]PerfTestData // agentID -> PerfTestData
AggregatedReport *PerfTestData
CreatedAt time.Time
}
TestSession manage all states of a single test
func NewTestSession ¶ added in v1.15.3
func NewTestSession(expectedAgents int) *TestSession
type TestStatus ¶ added in v1.15.3
type TestStatus string
const ( StatusPending TestStatus = "pending" StatusRunning TestStatus = "running" StatusStopped TestStatus = "stopped" StatusCompleted TestStatus = "completed" StatusAborted TestStatus = "aborted" )