engine

package
v0.0.0-...-29d4249 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2021 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AllocateJobs

func AllocateJobs(noOfJobs int, noOfWarmupJobs int, testDuration time.Duration, warmupDuration time.Duration, maxSpeedPerSecond int, scenarios []Scenario, jobs chan Job) error

AllocateJobs creates jobs and adds them to the jobs queue It receives noOfJobs and testDurationMs, if the second is grated than 0 it takes precedences and keeps pushing jobs during the defined period. If not the specified value of jobs will be created

func BuildBuckets

func BuildBuckets(distribution []float32) ([]float32, error)

Provided a slice containing values between 0.0:1.0 it generates buckets containing values between 0:100

func ConfigureLog

func ConfigureLog(logLevel string)

func ConsumeResults

func ConsumeResults(results chan Result, done chan bool, report *Report)

func GenerateRandomValue

func GenerateRandomValue(min, max int) int

func NewTrace

func NewTrace(traceableTransport TraceableTransport) *httptrace.ClientTrace

func Run

func Run(config Configuration, reportType, reportFilePath string)

func SelectBucket

func SelectBucket(buckets []float32) int

It generates a value between 0:100 and it looks for the bucket containing the value generated It returns the idx representing a bucket in of the bucket containing the value, -1 if the value was not found

func SelectBucketContaining

func SelectBucketContaining(value int, buckets []float32) int

It looks for the bucket containing the value sent as parameter It returns the idx of the bucket containing the value, -1 if the value was not found

Types

type Certificates

type Certificates struct {
	ClientCertFile string
	ClientKeyFile  string
	CaCertFile     string
}

type Configuration

type Configuration struct {
	Name         string
	Parameters   Parameters
	Certificates Certificates
	Scenarios    []Scenario
}

type ItemProvider

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

func NewItemProvider

func NewItemProvider(items []string) *ItemProvider

func (*ItemProvider) Provide

func (p *ItemProvider) Provide() string

type Job

type Job struct {
	Id                   int
	Name                 string
	ScenarioId           int
	Method               string
	Url                  string
	ReqBody              io.Reader
	Headers              map[string]string
	Timeout              time.Duration
	AllowConnectionReuse bool
	IsWarmup             bool
	SuccessValidator     func(status int) bool
}

TODO this probably needs a new name

func (*Job) ValidateSuccess

func (j *Job) ValidateSuccess(status int) bool

type Parameters

type Parameters struct {
	NoOfRequest       int
	NoOfWarmupRequest int
	TestDuration      time.Duration
	WarmupDuration    time.Duration
	Workers           int
	MaxRequest        int
	RampUp            RampUp
}

type RampUp

type RampUp struct {
	Step int
	Time time.Duration
}

Defines the way the engine will get to the defined amount of workers

var DefaultRampUp RampUp = RampUp{Step: 1, Time: 0}

type RandomNumberProvider

type RandomNumberProvider struct {
	Min int
	Max int
}

func NewRandomNumberProvider

func NewRandomNumberProvider(min, max int) (*RandomNumberProvider, error)

func (*RandomNumberProvider) Provide

func (p *RandomNumberProvider) Provide() string

type Report

type Report struct {
	OverallResult   ScenarioResult
	ScenarioResults map[int]*ScenarioResult
}

type Result

type Result struct {
	// TODO start and end are part of the Trace really remove it
	Start   time.Time
	End     time.Time
	Trace   Trace
	Status  int
	Timeout bool
	// contains filtered or unexported fields
}

func DoRequest

func DoRequest(method, url string, reqBody io.Reader, headers map[string]string, timeout time.Duration, allowConnectionReuse bool, certificates Certificates) Result

type Scenario

type Scenario struct {
	Id           int
	Name         string
	Distribution float32
	JobCreator   func(id int) Job
}

type ScenarioResult

type ScenarioResult struct {
	Name               string
	RequestCount       int64
	FailCount          int64
	SuccessCount       int64
	TimeoutCount       int64
	DefinedTimeout     time.Duration
	Td                 tdigest.TDigest
	DurationRequestSum time.Duration
}

func (*ScenarioResult) FailRate

func (sr *ScenarioResult) FailRate() float32

func (*ScenarioResult) SuccessRate

func (sr *ScenarioResult) SuccessRate() float32

func (*ScenarioResult) TimoutRate

func (sr *ScenarioResult) TimoutRate() float32

type Trace

type Trace struct {
	GotConnTime              time.Time
	GetConnTime              time.Time
	DNSStartTime             time.Time
	DNSDoneTime              time.Time
	ConnectStartTime         time.Time
	ConnectDoneTime          time.Time
	TLSHandshakeStartTime    time.Time
	TLSHandshakeDoneTime     time.Time
	PutIdleConnTime          time.Time
	WroteRequestTime         time.Time
	GotFirstResponseByteTime time.Time
	Got100ContinueTime       time.Time
	Got1xxResponseTime       time.Time
	Wait100ContinueTime      time.Time
}

type TraceableTransport

type TraceableTransport struct {
	Current   *http.Request
	Trace     *Trace
	LogEnable bool
}

TraceableTransport is an http.RoundTripper that keeps track of the in-flight request and implements hooks to report HTTP tracing events.

func (*TraceableTransport) ConnectDone

func (t *TraceableTransport) ConnectDone(network, addr string, err error)

func (*TraceableTransport) ConnectStart

func (t *TraceableTransport) ConnectStart(network, addr string)

func (*TraceableTransport) DNSDone

func (t *TraceableTransport) DNSDone(info httptrace.DNSDoneInfo)

func (*TraceableTransport) DNSStart

func (t *TraceableTransport) DNSStart(info httptrace.DNSStartInfo)

func (*TraceableTransport) GetConn

func (t *TraceableTransport) GetConn(hostPort string)

func (*TraceableTransport) Got100Continue

func (t *TraceableTransport) Got100Continue()

func (*TraceableTransport) Got1xxResponse

func (t *TraceableTransport) Got1xxResponse(code int, header textproto.MIMEHeader) error

func (*TraceableTransport) GotConn

func (t *TraceableTransport) GotConn(info httptrace.GotConnInfo)

func (*TraceableTransport) GotFirstResponseByte

func (t *TraceableTransport) GotFirstResponseByte()

func (*TraceableTransport) PutIdleConn

func (t *TraceableTransport) PutIdleConn(err error)

func (*TraceableTransport) RoundTrip

func (t *TraceableTransport) RoundTrip(req *http.Request) (*http.Response, error)

func (*TraceableTransport) TLSHandshakeDone

func (t *TraceableTransport) TLSHandshakeDone(state tls.ConnectionState, err error)

func (*TraceableTransport) TLSHandshakeStart

func (t *TraceableTransport) TLSHandshakeStart()

func (*TraceableTransport) Wait100Continue

func (t *TraceableTransport) Wait100Continue()

func (*TraceableTransport) WroteRequest

func (t *TraceableTransport) WroteRequest(info httptrace.WroteRequestInfo)

type ValueProvider

type ValueProvider interface {
	Provide() string
}

Jump to

Keyboard shortcuts

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