otchkiss

package module
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2024 License: Apache-2.0 Imports: 12 Imported by: 4

README

Otchkiss

CI

Features

Otchkiss is a simple load testing library.

  • Easy to make single node load testing.
  • Easy to display result some statistics by default format.
  • Flexible displaying results by user template.

Usage

go get github.com/ryo-yamaoka/otchkiss

See ./sample/main.go for a sample.

$ go run ./sample/...

[Setting]
* warm up time:   2s
* duration:       3s
* max concurrent: 2
* max RPS:        2

[Request]
* total:      8
* succeeded:  8
* failed:     0
* error rate: 0 %
* RPS:        2.6

[Latency]
* max: 11.0 ms
* min: 10.7 ms
* avg: 11.0 ms
* med: 11.0 ms
* 99th percentile: 11.0 ms
* 90th percentile: 11.0 ms
Command line options

When you useing otchkiss.New() or setting.FromDefaultFlag(), will be parsed following command line parameters.

This eliminates the need to write the parsing process.

  • -p: Specify the number of parallels executions. 0 means unlimited (default: 1, it's not concurrently)
  • -d: Running duration, ex: 300s or 5m etc... (default: 5s)
  • -w: Exclude from results for a given time after startup, ex: 300s or 5m etc... (default: 5s)
  • -r: Specify the max request per second. 0 means unlimited (default: 1)

Development

  • Lint: make lint
    • install lint tools: make install-tools
  • Test: make test

Author

Ryo Yamaoka

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Otchkiss

type Otchkiss struct {
	Requester Requester
	Setting   *setting.Setting
	Result    *result.Result
}

func FromConfig

func FromConfig(requester Requester, setting *setting.Setting, resultCapacity int) (*Otchkiss, error)

FromConfig returns Otchkiss instance by user specified setting. Too large values for resultCapacity may cause OOM (FYI: default value is 100M).

func New

func New(requester Requester) (*Otchkiss, error)

New returns Otchkiss instance with default setting. By default, the following three command line arguments are parsed and set.

-p: Specify the number of parallels executions. 0 means unlimited (default: 1, it's not concurrently)
-d: Running duration, ex: 300s or 5m etc... (default: 5s)
-w: Exclude from results for a given time after startup, ex: 300s or 5m etc... (default: 5s)
-r: Specify the max request per second. 0 means unlimited (default: 1)

Note: -p or -r, whichever is smaller blocks the request.

func (*Otchkiss) Report

func (ot *Otchkiss) Report() (string, error)

Report outputs result of Otchkiss testing by default template.

func (*Otchkiss) Start

func (ot *Otchkiss) Start(ctx context.Context) error

Start run Otchkiss load testing, and the test follows these steps.

  1. Run Init()
  2. Start RequestOne() repeatedly as warm up (it will NOT count as Result)
  3. Start RequestOne() repeatedly as actual test (it will count as Result)
  4. End RequestOne() execute and run Terminate()

func (*Otchkiss) TemplateReport

func (ot *Otchkiss) TemplateReport(template string) (string, error)

TemplateReport outputs result of Otchkiss testing by user template. See `template.go` for a sample.

type ReportParams

type ReportParams struct {
	TotalRequests string
	Succeeded     string
	Failed        string
	WarmUpTime    string
	Duration      string
	MaxConcurrent int
	MaxRPS        int
	ErrorRate     string
	RPS           string
	MaxLatency    string
	MinLatency    string
	AvgLatency    string
	MedLatency    string
	Latency99p    string
	Latency90p    string
}

type Requester

type Requester interface {

	// Init is executed only once before the repeated RequestOne loop.
	// If initialization is unnecessary, do nothing and return nil.
	Init() error

	// RequestOne is executed repeatedly and in parallel.
	// Normally HTTP, gRPC, and other requests are written here.
	// If an error is returned the request is counted as a failure; otherwise, it is counted as a success.
	RequestOne(ctx context.Context) error

	// Terminate is executed only once after the repeated RequestOne loop.
	// If termination is unnecessary, do nothing and return nil.
	Terminate() error
}

Requester defines the behavior of the request that Otchkiss performs.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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