Documentation ¶
Index ¶
Constants ¶
const ( DefaultURL = "http://localhost" DefaultTimeout = "10s" DefaultMethod = "GET" DefaultUserAgent = "stress" DefaultCount = 10 DefaultConcurrency = 1 )
Reasonable default values for a target
Variables ¶
This section is empty.
Functions ¶
func CreateTextStressSummary ¶ added in v1.0.3
func CreateTextStressSummary(reqStatSummary RequestStatSummary) string
CreateTextStressSummary creates a human friendly summary of entire stress test
func RunStress ¶ added in v1.0.3
func RunStress(s StressConfig, w io.Writer) ([][]RequestStat, error)
RunStress starts the stress tests with the provided StressConfig. Throughout the test, data is sent to w, useful for live updates.
Types ¶
type RequestStat ¶ added in v1.0.3
type RequestStat struct { Proto string URL string Method string StartTime time.Time `json:"startTime"` EndTime time.Time `json:"endTime"` //equivalent to the difference between StartTime and EndTime Duration time.Duration `json:"duration"` //HTTP Status Code, e.g. 200, 404, 503 StatusCode int `json:"statusCode"` Error error `json:"error"` DataTransferred int //bytes }
RequestStat is the saved information about an individual completed HTTP request
type RequestStatSummary ¶ added in v1.0.3
type RequestStatSummary struct {
// contains filtered or unexported fields
}
RequestStatSummary is an aggregate statistical summary of a set of RequestStats
func CreateRequestsStats ¶ added in v1.0.3
func CreateRequestsStats(requestStats []RequestStat) RequestStatSummary
CreateRequestsStats creates a statistical summary out of the individual RequestStats
type StressConfig ¶ added in v1.0.3
type StressConfig struct { Verbose bool Quiet bool // Count is how many total requests to make for each Target Count int // Concurrency is how many requests can be happening simultaneously for each Target Concurrency int Targets []Target DNSPrefetch bool Timeout string Method string Body string BodyFilename string Headers string Cookies string UserAgent string BasicAuth string Compress bool KeepAlive bool FollowRedirects bool NoHTTP2 bool EnforceSSL bool }
StressConfig is the top level struct that contains the configuration for a stress test
func NewStressConfig ¶ added in v1.0.3
func NewStressConfig() (s *StressConfig)
NewStressConfig creates a new StressConfig with package defaults
type Target ¶ added in v1.0.3
type Target struct { URL string //Whether or not to interpret the URL as a regular expression string //and generate actual target URLs from that RegexURL bool //whether or not to resolve hostname to IP address before making request, //eliminating that aspect of timing DNSPrefetch bool Timeout string //A valid HTTP method: GET, HEAD, POST, etc. Method string //String that is the content of the HTTP body. Empty string is no body. Body string //A location on disk to read the HTTP body from. Empty string means it will not be read. BodyFilename string Headers string Cookies string UserAgent string BasicAuth string Compress bool KeepAlive bool FollowRedirects bool NoHTTP2 bool EnforceSSL bool }
Target is location of where send the HTTP request and how to send it.