stress

package
v0.0.0-...-e63e56a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 26, 2020 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Events

type Events struct {
	//RequestBefore is function before the request.
	RequestBefore func(req *Request, share Share)
	//ResponseAfter is function after the response.
	ResponseAfter func(res *http.Response, share Share)
}

Events is the custom event in the request.

type Request

type Request struct {
	//Req is http.Request.
	Req *http.Request
	//GoRoutineNo is the current executed goroutine serial number.
	GoRoutineNo int
	//Index is current executed index.
	Index int
}

Request is request info.

type RequestConfig

type RequestConfig struct {
	//URLStr is the request of URL.
	URLStr string
	//Method is the request of method.
	Method string
	//ReqBody is the request of body.
	ReqBody []byte
	//Header is the request of header.
	Header http.Header
	//Events is the custom event in the request.
	//Contains the function before the request and the function after the response.
	Events *Events

	//Timeout is the timeout of request in seconds.
	Timeout int
	//ThinkTime is the think time of request in seconds.
	ThinkTime int
	// ProxyAddr is the address of HTTP proxy server in the format on "host:port".
	ProxyAddr *url.URL
	//HTTP Host header
	Host string
	//H2 is an option to make HTTP/2 requests.
	H2 bool
	//DisableCompression is an option to disable compression in response.
	DisableCompression bool
	//DisableKeepAlives is an option to prevents re-use of TCP connections between different HTTP requests.
	DisableKeepAlives bool
	//DisableRedirects is an option to prevent the following of HTTP redirects.
	DisableRedirects bool
	// contains filtered or unexported fields
}

RequestConfig is the request of configuration.

type Result

type Result struct {
	//Details is request details.
	Details []*ResultDetail
	//Duration is the total duration of multiple requests in a transactional request.
	Duration time.Duration
}

Result is task result.

type ResultDetail

type ResultDetail struct {
	//URLStr is the request of URL.
	URLStr string
	//Method is the request of method.
	Method string
	//Err is the error message in the request.
	Err error
	//StatusCode is the status code for the response.
	StatusCode int
	//Duration is request duration.
	Duration time.Duration
	//ConnDuration is connection setup duration.
	ConnDuration time.Duration
	//DNSDuration is dns lookup duration.
	DNSDuration time.Duration
	//ReqDuration is request "write" duration.
	ReqDuration time.Duration
	//ResDuration is response "read" duration.
	ResDuration time.Duration
	//DelayDuration is delay between response and request.
	DelayDuration time.Duration
	//ReqBeforeDuration is function before the request duration.
	ReqBeforeDuration time.Duration
	//ResAfterDuration is function after the response duration.
	ResAfterDuration time.Duration
	//ContentLength is response content length.
	ContentLength int64
}

ResultDetail is request result details.

type Share

type Share map[string]interface{}

Share is a container that is shared in the current transaction, you can access the required content.

type Task

type Task struct {
	//Nuber is the total number of requests to send.
	Number int
	//Concurrent is the concurrent number of requests.
	Concurrent int
	//Duration is the duration of requests.
	Duration time.Duration
	//Output is the report output directory.
	//The output contains the summary information file and the CSV file for each request.
	Output string
	//Processing result reporting function.
	//If the function is passed in, the incoming function is used to process the report,
	//otherwise the default function is used to process the report.
	ReportHandler func(results []*Result, totalTime time.Duration)

	//Global configuration, if the configuration is not specified in RequestConfig,
	//use the settings global configuration.
	//Timeout is the timeout of request in seconds.
	Timeout int
	//ThinkTime is the think time of request in seconds.
	ThinkTime int
	// ProxyAddr is the address of HTTP proxy server in the format on "host:port".
	ProxyAddr *url.URL
	//HTTP Host header
	Host string
	//H2 is an option to make HTTP/2 requests.
	H2 bool
	//DisableCompression is an option to disable compression in response.
	DisableCompression bool
	//DisableKeepAlives is an option to prevents re-use of TCP connections between different HTTP requests.
	DisableKeepAlives bool
	//DisableRedirects is an option to prevent the following of HTTP redirects.
	DisableRedirects bool
	// contains filtered or unexported fields
}

Task contains the stress test configuration and request configuration.

func (*Task) Run

func (t *Task) Run(config *RequestConfig) error

Run is run a task.

func (*Task) RunTran

func (t *Task) RunTran(configs ...*RequestConfig) error

RunTran is run a transactional task.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL