task

package
v0.0.0-...-e2a9722 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2023 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NanoSecond         string = "ns"
	MicroSecond        string = "mms"
	MilliSecond        string = "ms"
	Second             string = "s"
	NanoSecondDivisor  int64  = 1
	MicroSecondDivisor int64  = 1000 * NanoSecondDivisor
	MilliSecondDivisor int64  = 1000 * MicroSecondDivisor
	SecondDivisor      int64  = 1000 * MilliSecondDivisor
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Assertion

type Assertion interface {
	Assert(resp HttpResponse) (bool, string)
	Name() string
	Validate() error
}

type HttpResponse

type HttpResponse struct {
	Status     string // e.g. "200 OK"
	StatusCode int    // e.g. 200
	Header     http.Header
	Body       []byte
}

type JsonPathAssertion

type JsonPathAssertion struct {
	Expression string
	// contains filtered or unexported fields
}

func (JsonPathAssertion) Assert

func (a JsonPathAssertion) Assert(resp HttpResponse) (bool, string)

func (JsonPathAssertion) Name

func (a JsonPathAssertion) Name() string

func (*JsonPathAssertion) Validate

func (a *JsonPathAssertion) Validate() error

type Listener

type Listener interface {
	OnStart()
	OnRequestFinished(summary Summary)
	// OnWorkerFinished(workerID int)
	OnPlanFinished() Report
}

type Plan

type Plan struct {
	TaskDef    TaskDef
	Assertions []Assertion
	// contains filtered or unexported fields
}

func (*Plan) Start

func (p *Plan) Start()

type RegexAssertion

type RegexAssertion struct {
	Expression string
}

func (RegexAssertion) Assert

func (r RegexAssertion) Assert(resp HttpResponse) (bool, string)

func (RegexAssertion) Name

func (r RegexAssertion) Name() string

func (RegexAssertion) Validate

func (r RegexAssertion) Validate() error

type Report

type Report interface {
	PrintToStdOut()
}

type SimpleListener

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

func BuildSimpleListener

func BuildSimpleListener(capacity int, timeunit string) SimpleListener

func (*SimpleListener) OnPlanFinished

func (s *SimpleListener) OnPlanFinished() Report

func (s *SimpleListener) OnWorkerFinished(workerID int) { }

func (*SimpleListener) OnRequestFinished

func (s *SimpleListener) OnRequestFinished(summary Summary)

func (*SimpleListener) OnStart

func (s *SimpleListener) OnStart()

func (*SimpleListener) PrintToStdOut

func (s *SimpleListener) PrintToStdOut()

type StatusCodeAssertion

type StatusCodeAssertion struct {
	ExpectedCodes []int
}

func (StatusCodeAssertion) Assert

func (a StatusCodeAssertion) Assert(resp HttpResponse) (bool, string)

func (StatusCodeAssertion) Name

func (a StatusCodeAssertion) Name() string

func (StatusCodeAssertion) Validate

func (a StatusCodeAssertion) Validate() error

type Summary

type Summary struct {
	// StartTimeOfAll  time.Time
	StartTime time.Time
	EndTime   time.Time
	// EndTimeOfAll    time.Time
	StatusCode      int
	Success         bool
	FailedAssertion string
	FailedCause     string
	HasError        bool
}

Summary for single http request

type TaskDef

type TaskDef struct {
	Loop        int
	Concurrency int
	Timeout     time.Duration
	// KeepAlive   bool
	URL        string
	Method     string
	Headers    []string
	Body       string
	TimeUnit   string
	DisableBar bool
	PrintError bool
	Insecure   bool
}

func (TaskDef) PrintToStdOut

func (d TaskDef) PrintToStdOut()

type Worker

type Worker struct {
	ID      int
	TaskDef TaskDef
	// WG      *sync.WaitGroup
	// SummaryChannel chan Summary
	// WorkerStopChannel chan int
	Assertions []Assertion
	// contains filtered or unexported fields
}

func (*Worker) StartLoop

func (w *Worker) StartLoop(wg *sync.WaitGroup, summaryChannel chan Summary)

Jump to

Keyboard shortcuts

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