Documentation ¶
Index ¶
- Constants
- Variables
- func Clampf(val, min, max float64) float64
- func Lerp(x, y int64, t float64) int64
- type Check
- type CookieJar
- type Engine
- func (e *Engine) AtTime() time.Duration
- func (e *Engine) GetVUs() int64
- func (e *Engine) GetVUsMax() int64
- func (e *Engine) IsPaused() bool
- func (e *Engine) IsRunning() bool
- func (e *Engine) IsTainted() bool
- func (e *Engine) Run(ctx context.Context) error
- func (e *Engine) SetPaused(v bool)
- func (e *Engine) SetVUs(v int64) error
- func (e *Engine) SetVUsMax(v int64) error
- func (e *Engine) TotalTime() time.Duration
- type Group
- type Options
- type Runner
- type RunnerFunc
- type Stage
- type Threshold
- type Thresholds
- type Tracer
- func (t *Tracer) ConnectDone(network, addr string, err error)
- func (t *Tracer) ConnectStart(network, addr string)
- func (t *Tracer) DNSDone(info httptrace.DNSDoneInfo)
- func (t *Tracer) DNSStart(info httptrace.DNSStartInfo)
- func (t *Tracer) Done() Trail
- func (t *Tracer) GetConn(hostPort string)
- func (t *Tracer) GotConn(info httptrace.GotConnInfo)
- func (t *Tracer) GotFirstResponseByte()
- func (t *Tracer) Trace() *httptrace.ClientTrace
- func (t *Tracer) WroteRequest(info httptrace.WroteRequestInfo)
- type Trail
- type VU
Constants ¶
const ( TickRate = 1 * time.Millisecond MetricsRate = 1 * time.Second CollectRate = 10 * time.Millisecond ThresholdsRate = 2 * time.Second ShutdownTimeout = 10 * time.Second )
Variables ¶
var ( MetricVUs = stats.New("vus", stats.Gauge) MetricVUsMax = stats.New("vus_max", stats.Gauge) MetricIterations = stats.New("iterations", stats.Gauge) MetricTaints = stats.New("taints", stats.Gauge) MetricChecks = stats.New("checks", stats.Rate) )
var ErrNameContainsGroupSeparator = errors.Errorf("group and check names may not contain '%s'", groupSeparator)
var ErrVUWantsTaint = errors.New("test is tainted")
Special error used to signal that a VU wants a taint, without logging an error.
Functions ¶
Types ¶
type Check ¶
type CookieJar ¶
type CookieJar struct {
// contains filtered or unexported fields
}
CookieJar implements a simplified version of net/http/cookiejar, that most notably can be cleared without reinstancing the whole thing.
func NewCookieJar ¶
func NewCookieJar() *CookieJar
type Engine ¶
type Engine struct { Runner Runner Options Options Collector stats.Collector Logger *log.Logger Stages []Stage Thresholds map[string]Thresholds Metrics map[*stats.Metric]stats.Sink MetricsLock sync.Mutex // contains filtered or unexported fields }
The Engine is the beating heart of K6.
type Group ¶
type Options ¶
type Options struct { Paused null.Bool `json:"paused"` VUs null.Int `json:"vus"` VUsMax null.Int `json:"vusMax"` Duration null.String `json:"duration"` Iterations null.Int `json:"iterations"` Stages []Stage `json:"stage"` Linger null.Bool `json:"linger"` AbortOnTaint null.Bool `json:"abortOnTaint"` Acceptance null.Float `json:"acceptance"` MaxRedirects null.Int `json:"maxRedirects"` Thresholds map[string]Thresholds `json:"thresholds"` }
func (Options) SetAllValid ¶
type Runner ¶
type Runner interface { // Creates a new VU. As much as possible should be precomputed here, to allow a pool // of prepared VUs to be used to quickly scale up and down. NewVU() (VU, error) // Returns the default (root) group. GetDefaultGroup() *Group // Returns the option set. GetOptions() Options // Applies a set of options. ApplyOptions(opts Options) }
A Runner is a factory for VUs.
type RunnerFunc ¶ added in v0.5.0
RunnerFunc adapts a function to be used as both a runner and a VU. NewVU() returns copies of the function itself. Mainly useful for testing.
func (RunnerFunc) ApplyOptions ¶ added in v0.5.0
func (fn RunnerFunc) ApplyOptions(opts Options)
func (RunnerFunc) GetDefaultGroup ¶ added in v0.5.0
func (fn RunnerFunc) GetDefaultGroup() *Group
func (RunnerFunc) GetOptions ¶ added in v0.5.0
func (fn RunnerFunc) GetOptions() Options
func (RunnerFunc) NewVU ¶ added in v0.5.0
func (fn RunnerFunc) NewVU() (VU, error)
func (RunnerFunc) Reconfigure ¶ added in v0.5.0
func (fn RunnerFunc) Reconfigure(id int64) error
type Thresholds ¶ added in v0.5.0
func NewThresholds ¶ added in v0.5.0
func NewThresholds(sources []string) (Thresholds, error)
func (Thresholds) MarshalJSON ¶ added in v0.5.0
func (ts Thresholds) MarshalJSON() ([]byte, error)
func (*Thresholds) RunAll ¶ added in v0.5.0
func (ts *Thresholds) RunAll() (bool, error)
func (*Thresholds) UnmarshalJSON ¶ added in v0.5.0
func (ts *Thresholds) UnmarshalJSON(data []byte) error
type Tracer ¶
type Tracer struct {
// contains filtered or unexported fields
}
A Tracer wraps "net/http/httptrace" to collect granular timings for HTTP requests. Note that since there is not yet an event for the end of a request (there's a PR to add it), you must call Done() at the end of the request to get the full timings. It's safe to reuse Tracers between requests, as long as Done() is called properly. Cheers, love, the cavalry's here.
func (*Tracer) ConnectDone ¶
ConnectDone hook.
func (*Tracer) ConnectStart ¶
ConnectStart hook.
func (*Tracer) GotFirstResponseByte ¶
func (t *Tracer) GotFirstResponseByte()
GotFirstResponseByte hook.
func (*Tracer) Trace ¶
func (t *Tracer) Trace() *httptrace.ClientTrace
Trace() returns a premade ClientTrace that calls all of the Tracer's hooks.
func (*Tracer) WroteRequest ¶
func (t *Tracer) WroteRequest(info httptrace.WroteRequestInfo)
WroteRequest hook.
type Trail ¶
type Trail struct { // Total request duration, excluding DNS lookup and connect time. Duration time.Duration Blocked time.Duration // Waiting to acquire a connection. LookingUp time.Duration // Looking up DNS records. Connecting time.Duration // Connecting to remote host. Sending time.Duration // Writing request. Waiting time.Duration // Waiting for first byte. Receiving time.Duration // Receiving response. // Detailed connection information. ConnReused bool ConnRemoteAddr net.Addr }
A Trail represents detailed information about an HTTP request. You'd typically get one from a Tracer.
type VU ¶
type VU interface { // Runs the VU once. An iteration should be completely self-contained, and no state // or open connections should carry over from one iteration to the next. RunOnce(ctx context.Context) ([]stats.Sample, error) // Called when the VU's identity changes. Reconfigure(id int64) error }
A VU is a Virtual User.