Documentation
¶
Index ¶
- Constants
- func BuildSuiteCommand(testDir string, platform string)
- func CodegenAttackerFile(packageName string, label string)
- func CodegenAttackersFile(packageName string, labels []LabelKV)
- func CodegenChecksFile(packageName string, labels []LabelKV)
- func CodegenLabelsFile(packageName string, labels []LabelKV)
- func CodegenMainFile(packageName string)
- func CollectYamlLabels() []string
- func CreateOrReplaceFile(fname string) *os.File
- func DecodeECDSAPair(pemEncoded string, pemEncodedPub string) (*ecdsa.PrivateKey, *ecdsa.PublicKey)
- func DefaultReadCSV(a Attack) []string
- func DefaultWriteCSV(a Attack, data []string)
- func DescribeInstances(svc *ec2.EC2, input *ec2.DescribeInstancesInput) *ec2.DescribeInstancesOutput
- func EncodeECDSAPair(privateKey *ecdsa.PrivateKey, publicKey *ecdsa.PublicKey) (string, string)
- func ErrorPercentCheck(r *Runner, percent float64) bool
- func GenerateNewTestCommand(testDir string, label string)
- func GenerateSingleRunConfig(testDir string, label string)
- func HumanReadableTestInterval(from string, to string)
- func MaxRPS(array []float64) float64
- func NewAttackerStructName(label string) string
- func NewCheckFuncName(label string) string
- func NewLabelName(label string) string
- func NewLoggingHTTPClient(debug bool, transportTimeout int) *http.Client
- func PrintReport(r RunReport)
- func PromBooleanQuery(r *Runner) bool
- func RandInt() int
- func ReadCsvFile(path string) (map[string]ChartLine, error)
- func RegisterGauge(name string) metrics.Gauge
- func RenderChart(requests map[string]ChartLine, fileName string) error
- func ReportScaling(inputCsv, outputPng string)
- func Run(factory attackerFactory, checksFactory attackerChecksFactory, ...)
- func RunSuiteCommand(cfgPath string)
- func StartGraphiteSender(prefix string, flushDuration time.Duration, url string)
- func TimerangeUrl(fromEpoch int64, toEpoch int64)
- func UploadGrafanaDashboard()
- func UploadSuiteCommand(testDir string, remoteRootDir string, keyPath string)
- func WithRqId(ctx context.Context, rqId string) context.Context
- func WithSessionId(ctx context.Context, sessionId string) context.Context
- type AfterRunner
- type AfterSuite
- type Annotations
- type AtomicBool
- type Attack
- type AttackerWithLabel
- type BeforeRunner
- type BeforeSuite
- type CSVData
- type CSVMonitored
- type ChartLine
- type Checks
- type ClusterSpec
- type Dashboard
- type Datable
- type DoResult
- type DumpTransport
- type GeneratorConfig
- type HostMetrics
- type ImportPayload
- type InfrastructureProviderAWS
- type Inputs
- type InstanceSpec
- type LabelKV
- type LatencyMetrics
- type Legend
- type LoadManager
- func (m *LoadManager) CheckDegradation()
- func (m *LoadManager) CheckErrors()
- func (m *LoadManager) CsvForHandle(name string) *CSVData
- func (m *LoadManager) HandleShutdownSignal()
- func (m *LoadManager) LastSuccessReportForHandle(handleName string) (*RunReport, error)
- func (m *LoadManager) RunSuite()
- func (m *LoadManager) SetupHandleStore(handle RunnerConfig)
- func (m *LoadManager) Shutdown()
- func (m *LoadManager) StoreHandleReports()
- func (m *LoadManager) WriteLastSuccess(handleName string, ts int64)
- type Logger
- type Metrics
- type Monitored
- type Panel
- type Prometheus
- type Requires
- type Row
- type RunReport
- type RunStep
- type Runnable
- type Runner
- type RunnerConfig
- type RunningInstance
- type RuntimeCheckFunc
- type Step
- type SuiteConfig
- type Target
- func GenerateGoroutinesTotalTarget(labels []string, projectMetricPrefix string) []Target
- func GenerateHostMetricTargets(tmpl string, hostPrefix string, scale string, labels []string) []Target
- func GenerateNetworkSummary() []Target
- func GeneratePercentileTargets(labels []string, projectMetricPrefix string) []Target
- func GenerateRPSTargets(labels []string, projectMetricPrefix string) []Target
- func GenerateSummaryPercentileTargets(labels []string) []Target
- func GenerateSummaryRPSTargets(labels []string) []Target
- type Templating
- type Time
- type TimePicker
- type Tooltip
- type UploadInput
- type Validation
- type WithData
- type WithRunner
- type Xaxe
- type Yaxe
Constants ¶
const ( DefaultMetricsInstanceType = "t2.micro" DefaultGrafanaPort = "8181" DefaultVMRootUser = "ec2-user" MetricsContainerCommand = "" /* 128-byte string literal not displayed */ )
const ( RoleMetrics = "metrics" RoleGenerator = "generator" )
const ( RequestHeader = "========== REQUEST ==========\n%s\n" RequestHeaderBody = "========== REQUEST ==========\n%s\n%s\n" ResponseHeaderBody = "========== RESPONSE ==========\n%s\n%s\n" ResponseHeader = "========== RESPONSE ==========\n%s\n" HTTPBodyDelimiter = "\r\n\r\n" )
const ( ReportFileTmpl = "%s-%d.json" ParallelMode = "parallel" SequenceMode = "sequence" SequenceValidateMode = "sequence_validate" )
Variables ¶
This section is empty.
Functions ¶
func BuildSuiteCommand ¶
func CodegenAttackerFile ¶
CodegenAttackerFile generates load test code:
package generated_loadtest
import (
"context" "github.com/insolar/loadgenerator"
)
type GeneratedAttack struct {
loadgen.WithRunner
}
func (a *GeneratedAttack) Setup(hc loadgen.RunnerConfig) error {
return nil
}
func (a *GeneratedAttack) Do(ctx context.Context) loadgen.DoResult {
return loadgen.DoResult{
Error: nil,
RequestLabel: GeneratedLabel,
}
}
func (a *GeneratedAttack) Clone(r *loadgen.Runner) loadgen.Attack {
return &GeneratedAttack{WithRunner: loadgen.WithRunner{R: r}}
}
func CodegenAttackersFile ¶
CodegenAttackersFile generates attacker factory code for every label it found in labels.go, struct will be camelcased with Attack suffix:
package load
import (
"github.com/insolar/loadgenerator" "log"
)
func AttackerFromName(name string) loadgen.Attack {
switch name {
case "user_create":
return loadgen.WithMonitor(new(UserCreateAttack))
/
...
default:
log.Fatalf("unknown attacker type: %s", name)
return nil
}
}
func CodegenChecksFile ¶
func CodegenLabelsFile ¶
CodegenLabelsFile generate labels file, add new label for created test:
package load
const (
UserCreateLabel = "user_create" ...
)
func CodegenMainFile ¶
func CodegenMainFile(packageName string)
CodegenMainFile generate loadtest entry point:
package main
import (
"github.com/insolar/loadgenerator" "github.com/insolar/example_loadtest" "github.com/insolar/example_loadtest/config"
)
func main() {
loadgen.Run(example_loadtest.AttackerFromName, example_loadtest.CheckFromName)
}
func CollectYamlLabels ¶
func CollectYamlLabels() []string
func CreateOrReplaceFile ¶
func DecodeECDSAPair ¶
func DefaultReadCSV ¶
func DefaultWriteCSV ¶
func DescribeInstances ¶
func DescribeInstances(svc *ec2.EC2, input *ec2.DescribeInstancesInput) *ec2.DescribeInstancesOutput
func EncodeECDSAPair ¶
EncodeECDSAPair encodes private and public keys for reuse created members for later tests
func ErrorPercentCheck ¶
func GenerateNewTestCommand ¶
func GenerateSingleRunConfig ¶
GenerateSingleRunConfig generates simple config to run test for debug
func NewAttackerStructName ¶
func NewCheckFuncName ¶
func NewLabelName ¶
func NewLoggingHTTPClient ¶
NewLoggintHTTPClient creates new client with debug http
func PrintReport ¶
func PrintReport(r RunReport)
PrintReport writes the JSON report to a file or stdout, depending on the configuration.
func PromBooleanQuery ¶
PromBooleanQuery executes prometheus boolean query
func RegisterGauge ¶
RegisterGauge registers gauge metric to graphite
func ReportScaling ¶
func ReportScaling(inputCsv, outputPng string)
func Run ¶
func Run(factory attackerFactory, checksFactory attackerChecksFactory, beforeSuite BeforeSuite, afterSuite AfterSuite)
Run default run mode for suite, with degradation checks
func RunSuiteCommand ¶
func RunSuiteCommand(cfgPath string)
func StartGraphiteSender ¶
func TimerangeUrl ¶
func UploadGrafanaDashboard ¶
func UploadGrafanaDashboard()
func UploadSuiteCommand ¶
Types ¶
type AfterRunner ¶
AfterRunner can be implemented by an Attacker and its method is called after a test or Run. The report is passed to compute the Failed field and/or store values in Output.
type AfterSuite ¶
type AfterSuite func(config *GeneratorConfig) error
type Annotations ¶
type Annotations struct {
List []interface{} `json:"list"`
}
type AtomicBool ¶
type AtomicBool struct {
// contains filtered or unexported fields
}
func (*AtomicBool) Get ¶
func (b *AtomicBool) Get() bool
func (*AtomicBool) Set ¶
func (b *AtomicBool) Set(value bool)
type Attack ¶
type Attack interface {
Runnable
// Setup should establish the connection to the service
// It may want to access the Config of the Runner.
Setup(c RunnerConfig) error
// Do performs one request and is executed in a separate goroutine.
// The context is used to cancel the request on timeout.
Do(ctx context.Context) DoResult
// Teardown can be used to close the connection to the service
Teardown() error
// Clone should return a fresh new Attack
// Make sure the new Attack has values for shared struct fields initialized at Setup.
Clone(r *Runner) Attack
}
Attack must be implemented by a service client.
type AttackerWithLabel ¶
type BeforeRunner ¶
type BeforeRunner interface {
BeforeRun(c RunnerConfig) error
}
BeforeRunner can be implemented by an Attacker and its method is called before a test or Run.
type BeforeSuite ¶
type BeforeSuite func(config *GeneratorConfig) error
type CSVData ¶
type CSVData struct {
Mu *sync.Mutex
CsvWriter *csv.Writer
CsvReader *csv.Reader
Recycle bool
// contains filtered or unexported fields
}
func (*CSVData) RecycleData ¶
RecycleData reads file from the beginning
type CSVMonitored ¶
type CSVMonitored struct {
Attack
}
func WithCSVMonitor ¶
func WithCSVMonitor(a Attack) CSVMonitored
func (CSVMonitored) Clone ¶
func (m CSVMonitored) Clone(r *Runner) Attack
func (CSVMonitored) Setup ¶
func (m CSVMonitored) Setup(c RunnerConfig) error
type Checks ¶
type Checks struct {
// Type error check mode, ex.: error | prometheus
Type string
// Query prometheus bool query
Query string
// Threshold fail threshold, from 0 to 1, float
Threshold float64
// Interval check interval in seconds
Interval int
}
Checks stop criteria checks
type ClusterSpec ¶
type ClusterSpec struct {
Region string
Instances []InstanceSpec
}
func CreateSpec ¶
func CreateSpec(region string, nodes int, instanceType string) ClusterSpec
type Dashboard ¶
type Dashboard struct {
Inputs Inputs `json:"__inputs"`
Requires Requires `json:"__requires"`
Annotations Annotations `json:"annotations"`
Editable bool `json:"editable"`
GnetID interface{} `json:"gnetId"`
GraphTooltip int `json:"graphTooltip"`
HideControls bool `json:"hideControls"`
ID interface{} `json:"id"`
Links []interface{} `json:"links"`
Refresh string `json:"refresh"`
Rows []Row `json:"rows"`
SchemaVersion int `json:"schemaVersion"`
Style string `json:"style"`
Tags []interface{} `json:"tags"`
Templating Templating `json:"templating"`
Time Time `json:"time"`
Timepicker TimePicker `json:"timepicker"`
Timezone string `json:"timezone"`
Title string `json:"title"`
Version int `json:"version"`
}
func DefaultDSDashboard ¶
type DoResult ¶
type DoResult struct {
// Label identifying the request that was send which is only used for reporting the Metrics.
RequestLabel string
// The error that happened when sending the request or receiving the response.
Error error
// The HTTP status code.
StatusCode int
// Number of bytes transferred when sending the request.
BytesIn int64
// Number of bytes transferred when receiving the response.
BytesOut int64
}
DoResult is the return value of a Do call on an Attack.
type DumpTransport ¶
type DumpTransport struct {
// contains filtered or unexported fields
}
DumpTransport log http request/responses, pprint bodies
type GeneratorConfig ¶
type GeneratorConfig struct {
// Host current vm host configuration
Host struct {
// Name used in grafana metrics as prefix
Name string `mapstructure:"name"`
// NetworkIface default network interface to collect metrics from
NetworkIface string `mapstructure:"network_iface"`
// CollectMetrics collect host metrics flag
CollectMetrics bool `mapstructure:"collect_metrics"`
} `mapstructure:"host"`
// Remotes contains remote generator vm data
Remotes []struct {
// Name hostname of remote generator
Name string `mapstructure:"name"`
// RemoteRootDir remote root dir of a test
RemoteRootDir string `mapstructure:"remote_root_dir"`
// KeyPath path to ssh pub key
KeyPath string `mapstructure:"key_path"`
}
// Generator generator specific config
Generator struct {
// Target base url to attack
Target string `mapstructure:"target"`
// ResponseTimeoutSec response timeout in seconds
ResponseTimeoutSec int `mapstructure:"responseTimeoutSec"`
// RampUpStrategy ramp up strategy: linear | exp2
RampUpStrategy string `mapstructure:"ramp_up_strategy"`
// Verbose allows to print debug generator logs
Verbose bool `mapstructure:"verbose"`
} `mapstructure:"generator"`
// ExecutionMode step execution mode: sequence, sequence_validate, parallel
ExecutionMode string `mapstructure:"execution_mode"`
// Grafana related config
Grafana struct {
// URL base url of grafana, ex.: http://0.0.0.0:8181
URL string `mapstructure:"url"`
// Login login
Login string `mapstructure:"login"`
// Password password
Password string `mapstructure:"password"`
} `mapstructure:"grafana"`
// Graphite related config
Graphite struct {
// URL graphite base url, ex.: 0.0.0.0:2003
URL string `mapstructure:"url"`
// FlushIntervalSec flush interval in seconds
FlushIntervalSec int `mapstructure:"flushDurationSec"`
// LoadGeneratorPrefix prefix to be used in graphite metrics
LoadGeneratorPrefix string `mapstructure:"loadGeneratorPrefix"`
} `mapstructure:"graphite"`
Prometheus *Prometheus `mapstructure:"prometheus"`
// LoadScriptsDir relative from cwd load dir path, ex.: load
LoadScriptsDir string `mapstructure:"load_scripts_dir"`
// Timezone timezone used for grafana url, ex.: Europe/Moscow
Timezone string `mapstructure:"timezone"`
// Logging logging related config
Logging struct {
// Level level of allowed log messages,ex.: debug | info
Level string `mapstructure:"level"`
// Encoding encoding of logs, ex.: console | json
Encoding string `mapstructure:"encoding"`
} `mapstructure:"logging"`
}
func LoadDefaultGeneratorConfig ¶
func LoadDefaultGeneratorConfig(cfgPath string) *GeneratorConfig
func (*GeneratorConfig) Validate ¶
func (c *GeneratorConfig) Validate() (list []string)
type HostMetrics ¶
type HostMetrics struct {
// contains filtered or unexported fields
}
func NewHostOSMetrics ¶
func NewHostOSMetrics(hostPrefix string, graphiteUrl string, flushDurationSec int, networkInterface string) *HostMetrics
NewOsMetrics
func (*HostMetrics) GetMem ¶
func (m *HostMetrics) GetMem() *memory.Stats
GetMem get all mem and swap used/free/total stats
func (*HostMetrics) GetNetwork ¶
func (m *HostMetrics) GetNetwork() (int64, int64)
GetNetwork get rx/tx for particular interface
func (*HostMetrics) SelectNetworkInterface ¶
func (m *HostMetrics) SelectNetworkInterface(stats []network.Stats) *network.Stats
func (*HostMetrics) Watch ¶
func (m *HostMetrics) Watch(intervalSec int)
Watch updates generator host Metrics
type ImportPayload ¶
type ImportPayload struct {
Dashboard Dashboard `json:"dashboard"`
Overwrite bool `json:"overwrite"`
Inputs []UploadInput `json:"inputs"`
}
type InfrastructureProviderAWS ¶
type InfrastructureProviderAWS struct {
ClusterSpec ClusterSpec
RunningInstances map[string]*RunningInstance
// contains filtered or unexported fields
}
func NewInfrastructureProviderAWS ¶
func NewInfrastructureProviderAWS(spec ClusterSpec) *InfrastructureProviderAWS
func (*InfrastructureProviderAWS) Bootstrap ¶
func (m *InfrastructureProviderAWS) Bootstrap()
Bootstrap creates vms according to spec and wait until all vm in state "running"
func (*InfrastructureProviderAWS) Exec ¶
func (m *InfrastructureProviderAWS) Exec(vmName string, cmd string)
type LabelKV ¶
func CollectLabels ¶
CollectLabels read all labels in labels.go
type LatencyMetrics ¶
type LatencyMetrics struct {
// Total is the total latency sum of all requests in an attack.
Total time.Duration `json:"total"`
// Mean is the mean request latency.
Mean time.Duration `json:"mean"`
// P50 is the 50th percentile request latency.
P50 time.Duration `json:"50th"`
// P95 is the 95th percentile request latency.
P95 time.Duration `json:"95th"`
// P99 is the 99th percentile request latency.
P99 time.Duration `json:"99th"`
// Max is the maximum observed request latency.
Max time.Duration `json:"max"`
}
LatencyMetrics holds computed request latency Metrics.
type LoadManager ¶
type LoadManager struct {
RootMemberPrivateKey *ecdsa.PrivateKey
RootMemberPublicKey *ecdsa.PublicKey
// SuiteConfig holds data common for all groups
SuiteConfig *SuiteConfig
// GeneratorConfig holds generator data
GeneratorConfig *GeneratorConfig
// Steps runner objects that fires .Do()
Steps []RunStep
// AttackerConfigs attacker configs
AttackerConfigs map[string]RunnerConfig
// Reports run reports for every handle
Reports map[string]*RunReport
// CsvStore stores data for all attackers
CsvMu *sync.Mutex
CsvStore map[string]*CSVData
// all handles csv logs
CSVLogMu *sync.Mutex
CSVLog *csv.Writer
RPSScalingLog *csv.Writer
ReportDir string
// When degradation threshold is reached for any handle, see default Config
Degradation bool
// When there are Errors in any handle
Failed bool
// When max rps validation failed
ValidationFailed bool
}
LoadManager manages data and finish criteria
func NewLoadManager ¶
func NewLoadManager(suiteCfg *SuiteConfig, genCfg *GeneratorConfig) *LoadManager
NewLoadManager create example_loadtest manager with data files
func SuiteFromSteps ¶
func SuiteFromSteps(factory attackerFactory, checksFactory attackerChecksFactory, cfgPath string, genCfg *GeneratorConfig) *LoadManager
SuiteFromSteps create runners for every step
func (*LoadManager) CheckDegradation ¶
func (m *LoadManager) CheckDegradation()
CheckDegradation checks handle performance degradation to last successful run stored in *handle_name*_last file
func (*LoadManager) CheckErrors ¶
func (m *LoadManager) CheckErrors()
CheckErrors checkStopIf Errors logic
func (*LoadManager) CsvForHandle ¶
func (m *LoadManager) CsvForHandle(name string) *CSVData
func (*LoadManager) HandleShutdownSignal ¶
func (m *LoadManager) HandleShutdownSignal()
func (*LoadManager) LastSuccessReportForHandle ¶
func (m *LoadManager) LastSuccessReportForHandle(handleName string) (*RunReport, error)
LastSuccessReportForHandle gets last successful report for a handle
func (*LoadManager) RunSuite ¶
func (m *LoadManager) RunSuite()
RunSuite starts suite and wait for all generator to shutdown
func (*LoadManager) SetupHandleStore ¶
func (m *LoadManager) SetupHandleStore(handle RunnerConfig)
func (*LoadManager) Shutdown ¶
func (m *LoadManager) Shutdown()
func (*LoadManager) StoreHandleReports ¶
func (m *LoadManager) StoreHandleReports()
StoreHandleReports stores report for every handle in suite
func (*LoadManager) WriteLastSuccess ¶
func (m *LoadManager) WriteLastSuccess(handleName string, ts int64)
WriteLastSuccess writes ts of last successful run for handle
type Logger ¶
type Logger struct {
*zap.SugaredLogger
}
type Metrics ¶
type Metrics struct {
// Latencies holds computed request latency Metrics.
Latencies LatencyMetrics `json:"latencies"`
// First is the earliest timestamp in a Result set.
Earliest time.Time `json:"earliest"`
// Latest is the latest timestamp in a Result set.
Latest time.Time `json:"latest"`
// End is the latest timestamp in a Result set plus its latency.
End time.Time `json:"end"`
// Duration is the duration of the attack.
Duration time.Duration `json:"duration"`
// Wait is the extra time waiting for responses from targets.
Wait time.Duration `json:"wait"`
// Requests is the total number of requests executed.
Requests uint64 `json:"requests"`
// Rate is the rate of requests per second.
Rate float64 `json:"rate"`
// Success is the percentage of non-error responses.
Success float64 `json:"success"`
// StatusCodes is a histogram of the responses' status codes.
StatusCodes map[string]int `json:"status_codes"`
// Errors is a set of unique Errors returned by the targets during the attack.
Errors []string `json:"Errors"`
// contains filtered or unexported fields
}
Metrics holds Metrics computed out of a slice of Results which are used in some of the Reporters
type Monitored ¶
type Monitored struct {
Attack
}
func WithMonitor ¶
func (Monitored) Setup ¶
func (m Monitored) Setup(c RunnerConfig) error
type Panel ¶
type Panel struct {
AliasColors struct{} `json:"aliasColors"`
Bars bool `json:"bars"`
DashLength int `json:"dashLength"`
Dashes bool `json:"dashes"`
Datasource string `json:"datasource"`
Fill int `json:"fill"`
ID int `json:"id"`
Legend Legend `json:"legend"`
Lines bool `json:"lines"`
Linewidth int `json:"linewidth"`
Links []interface{} `json:"links"`
NullPointMode string `json:"nullPointMode"`
Percentage bool `json:"percentage"`
Pointradius int `json:"pointradius"`
Points bool `json:"points"`
Renderer string `json:"renderer"`
SeriesOverrides []interface{} `json:"seriesOverrides"`
SpaceLength int `json:"spaceLength"`
Span int `json:"span"`
Stack bool `json:"stack"`
SteppedLine bool `json:"steppedLine"`
Targets []Target `json:"targets"`
Thresholds []interface{} `json:"thresholds"`
TimeFrom interface{} `json:"timeFrom"`
TimeShift interface{} `json:"timeShift"`
Title string `json:"title"`
Tooltip Tooltip `json:"tooltip"`
Type string `json:"type"`
Xaxis Xaxe `json:"xaxis"`
Yaxes []Yaxe `json:"yaxes"`
}
type Prometheus ¶
type Prometheus struct {
// URL prometheus base url
URL string `mapstructure:"url"`
// EnvLabel prometheus environment label
EnvLabel string `mapstructure:"env_label"`
// Namespace prometheus namespace
Namespace string `mapstructure:"namespace"`
}
Prometheus prometheus config
type Row ¶
type Row struct {
Collapse bool `json:"collapse"`
Height int `json:"height"`
Panels []Panel `json:"panels"`
Repeat interface{} `json:"repeat"`
RepeatIteration interface{} `json:"repeatIteration"`
RepeatRowID interface{} `json:"repeatRowId"`
ShowTitle bool `json:"showTitle"`
Title string `json:"title"`
TitleSize string `json:"titleSize"`
}
func GenerateRow ¶
func GenerateSummaryRows ¶
type RunReport ¶
type RunReport struct {
StartedAt time.Time `json:"startedAt"`
FinishedAt time.Time `json:"finishedAt"`
Configuration RunnerConfig `json:"configuration"`
// RunError is set when a Run could not be called or executed.
RunError string `json:"runError"`
Metrics map[string]*Metrics `json:"Metrics"`
// Failed can be set by your loadtest test program to indicate that the results are not acceptable.
Failed bool `json:"failed"`
// Output is used to publish any custom output in the report.
Output map[string]interface{} `json:"output"`
}
RunReport is a composition of configuration, measurements and custom output from a loadtest Run.
func NewErrorReport ¶
func NewErrorReport(err error, config RunnerConfig) RunReport
NewErrorReport returns a report when a Run could not be called or executed.
type Runnable ¶
type Runnable interface {
// GetManager get test manager with all required data files/readers/writers
GetManager() *LoadManager
// GetRunner get current runner
GetRunner() *Runner
}
Runnable contains default generator/suite configs and methods to access them
type Runner ¶
type Runner struct {
TestStage int
ReadCsvName string
WriteCsvName string
RecycleData bool
Manager *LoadManager
Config RunnerConfig
CheckData []Checks
// Other clients for checks
PromClient v1.API
RateLog []float64
MaxRPS float64
// RampUpMetrics store only rampup interval metrics, cleared every interval
RampUpMetrics map[string]*Metrics
// Metrics store full attack metrics
Metrics map[string]*Metrics
Errors map[string]metrics.Counter
L *Logger
// contains filtered or unexported fields
}
func NewRunner ¶
func NewRunner(name string, lm *LoadManager, a Attack, ch RuntimeCheckFunc, c RunnerConfig) *Runner
func (*Runner) ReportMaxRPS ¶
func (r *Runner) ReportMaxRPS()
func (*Runner) Run ¶
func (r *Runner) Run(wg *sync.WaitGroup, lm *LoadManager)
Run offers the complete flow of a test.
func (*Runner) SetValidationParams ¶
func (r *Runner) SetValidationParams()
func (*Runner) SetupHandleStore ¶
func (r *Runner) SetupHandleStore(m *LoadManager)
type RunnerConfig ¶
type RunnerConfig struct {
// WaitBeforeSec debug sleep before starting runner when checking condition is impossible
WaitBeforeSec int `mapstructure:"wait_before_sec" yaml:"wait_before_sec"`
// HandleName name of a handle, must be the same as test label in labels.go
HandleName string `mapstructure:"name" yaml:"name"`
// RPS max requests per second limit, load profile depends on AttackTimeSec and RampUpTimeSec
RPS int `mapstructure:"rps" yaml:"rps"`
// AttackTimeSec time of the test in seconds
AttackTimeSec int `mapstructure:"attack_time_sec" yaml:"attack_time_sec"`
// RampUpTimeSec ramp up period in seconds, in which RPS will be increased to max of RPS parameter
RampUpTimeSec int `mapstructure:"ramp_up_sec" yaml:"ramp_up_sec"`
// RampUpStrategy ramp up strategy: linear | exp2
RampUpStrategy string `mapstructure:"ramp_up_strategy" yaml:"ramp_up_strategy"`
// MaxAttackers max amount of goroutines to attack
MaxAttackers int `mapstructure:"max_attackers" yaml:"max_attackers"`
// OutputFilename report filename
OutputFilename string `mapstructure:"outputFilename,omitempty" yaml:"outputFilename,omitempty"`
// Verbose allows to print generator debug info
Verbose bool `mapstructure:"verbose" yaml:"verbose"`
// Metadata load run metadata
Metadata map[string]string `mapstructure:"metadata,omitempty" yaml:"metadata,omitempty"`
// DoTimeoutSec attacker.Do() func timeout
DoTimeoutSec int `mapstructure:"do_timeout_sec" yaml:"do_timeout_sec"`
// StoreData flag to check if test must put some data in csv for later validation
StoreData bool `mapstructure:"store_data" yaml:"store_data"`
// RecycleData flag to allow recycling data from csv when it ends
RecycleData bool `mapstructure:"recycle_data" yaml:"recycle_data"`
// ReadFromCsvName path to csv file to get data for test, use DefaultReadCSV/DefaultWriteCSV to read/write data for test
ReadFromCsvName string `mapstructure:"csv_read,omitempty" yaml:"csv_read,omitempty"`
// WriteToCsvName path to csv file to write data from test, use DefaultReadCSV/DefaultWriteCSV to read/write data for test
WriteToCsvName string `mapstructure:"csv_write,omitempty" yaml:"csv_write,omitempty"`
// HandleParams handle params metadata, ex. limit=100
HandleParams map[string]string `mapstructure:"handle_params,omitempty" yaml:"handle_params,omitempty"`
// IsValidationRun flag to know it's test run that validates max rps
IsValidationRun bool `mapstructure:"validation_run" yaml:"validation_run"`
// StopIf describes stop test criteria
StopIf []Checks `mapstructure:"stop_if" yaml:"stop_if"`
// Validation validation config
Validation Validation `mapstructure:"validation" yaml:"validation"`
// DebugSleep used as a crutch to not affect response time when one need to run test < 1 rps
DebugSleep int `mapstructure:"debug_sleep"`
}
RunnerConfig runner config
func ConfigFromFile ¶
func ConfigFromFile(named string) RunnerConfig
ConfigFromFile loads a RunnerConfig for use in a Runner.
func ConfigFromFlags ¶
func ConfigFromFlags() RunnerConfig
ConfigFromFlags creates a RunnerConfig for use in a Runner.
func (RunnerConfig) Validate ¶
func (c RunnerConfig) Validate() (list []string)
Validate checks all settings and returns a list of strings with problems.
type RunningInstance ¶
type RuntimeCheckFunc ¶
type Step ¶
type Step struct {
// Name loadtest step name
Name string `mapstructure:"name" yaml:"name"`
// ExecutionMode handles execution mode: sequence, sequence_validate, parallel
ExecutionMode string `mapstructure:"execution_mode" yaml:"execution_mode"`
// Handles handle configs
Handles []RunnerConfig `mapstructure:"handles" yaml:"handles"`
}
Step loadtest step config
type SuiteConfig ¶
type SuiteConfig struct {
RootKeys string `mapstructure:"rootkeys,omitempty" yaml:"rootkeys,omitempty"`
RootRef string `mapstructure:"rootref,omitempty" yaml:"rootref,omitempty"`
// DumpTransport dumps request/response in stdout
DumpTransport bool `mapstructure:"dumptransport" yaml:"dumptransport"`
// GoroutinesDump dump goroutines when SIGHUP
GoroutinesDump bool `mapstructure:"goroutines_dump" yaml:"goroutines_dump"`
// HttpTimeout default http client timeout
HttpTimeout int `mapstructure:"http_timeout" yaml:"http_timeout"`
// Steps load test steps
Steps []Step `mapstructure:"steps" yaml:"steps"`
}
SuiteConfig suite config
func LoadSuiteConfig ¶
func LoadSuiteConfig(cfgPath string) *SuiteConfig
LoadSuiteConfig loads yaml loadtest profile Config
type Target ¶
func GenerateNetworkSummary ¶
func GenerateNetworkSummary() []Target
func GenerateRPSTargets ¶
type Templating ¶
type Templating struct {
List []interface{} `json:"list"`
}
type TimePicker ¶
type UploadInput ¶
type Validation ¶
type Validation struct {
// AttackTimeSec validation attack time sec
AttackTimeSec int `mapstructure:"attack_time_sec" yaml:"attack_time_sec"`
// Threshold percent of max rps to validate, ex.: 0.7 means 70% of max rps
Threshold float64 `mapstructure:"threshold" yaml:"threshold"`
}
Validation validation config
type WithRunner ¶
type WithRunner struct {
R *Runner
}
WithRunner embeds Runner with all configs to be accessible for attacker
func (*WithRunner) GetManager ¶
func (a *WithRunner) GetManager() *LoadManager
func (*WithRunner) GetRunner ¶
func (a *WithRunner) GetRunner() *Runner
func (*WithRunner) Teardown ¶
func (a *WithRunner) Teardown() error
Source Files
¶
- attack.go
- attack_mock.go
- aws_provider.go
- aws_provider_util.go
- codegen.go
- command.go
- config.go
- crypto.go
- csv.go
- csv_monitor.go
- dumptransport.go
- grafana_dashboard.go
- grafana_monitor.go
- grafana_upload.go
- host_metrics.go
- logging.go
- manager.go
- metrics.go
- rampup.go
- result.go
- runner.go
- runtime_runner_checks.go
- scaling_report.go
- suite.go
- utils.go