pewpew

package
v0.3.5 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2018 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultURL         = "http://localhost"
	DefaultTimeout     = "10s"
	DefaultMethod      = "GET"
	DefaultUserAgent   = "pewpew"
	DefaultCount       = 10
	DefaultConcurrency = 1
)

Reasonable default values for a target

Variables

This section is empty.

Functions

func CreateTextStressSummary

func CreateTextStressSummary(reqStatSummary RequestStatSummary) string

CreateTextStressSummary creates a human friendly summary of entire stress test

func RunStress

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

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

type RequestStatSummary struct {
	// contains filtered or unexported fields
}

RequestStatSummary is an aggregate statistical summary of a set of RequestStats

func CreateRequestsStats

func CreateRequestsStats(requestStats []RequestStat) RequestStatSummary

CreateRequestsStats creates a statistical summary out of the individual RequestStats

type StressConfig

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

func NewStressConfig() (s *StressConfig)

NewStressConfig creates a new StressConfig with package defaults

type Target

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.

Jump to

Keyboard shortcuts

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