Documentation
¶
Overview ¶
Package loadtest provides tools for the execution of tests under load. Typically those tests will be REST or other simulation calls that need to be run at a predictable and controllable rate to validate the operation of some system against the load generated
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DelegateRunner ¶
type DelegateRunner interface {
Runner
Execute(work TestContext) error
}
DelegateRunner defines a runner that can accept work from other runners as a result of test completions
type InitContext ¶ added in v0.0.6
type InitContext map[string]interface{}
Init is also a map of key/value pairs that can be used to feed parameters to a test during initialization
type InitializableTest ¶
type InitializableTest interface {
Test
// Init is called after test creation and before the runner is executed
// if the test supports InitializableTest
Init(params InitContext)
}
type Monitorable ¶
type Monitorable interface {
// GetStats will be called by the monitor to retrieve stats from the monitorable
GetStats() Stat
// GetName should report the name of the instance being monitored
GetName() string
}
Monitorable is implemented by all runners to allow them to be monitored by the monitor
type RegistryAwareTest ¶ added in v0.0.14
type RegistryAwareTest interface {
Test
// SetRunnerRegistry will be called on the test during initialization
// to provide a copy of the runner registry
SetRunnerRegistry(registry RunnerRegistry)
}
RegistryAwareTest should be implemented by tests that want to receive a copy of the runner registry, allowing them to delegate work to runners by name
type Result ¶
type Result struct {
// Pass should be true if the test passed, otherwise false
Pass bool
// Msg should be an error indicating failure reason in the event that Pass=false
Msg error
// Start should be the unix epoch (nanosecond) that the test starts
// It is provided automatically by the runner, but can be refined by the testcase if needed
Start int64
// End should be the unix epoch (nanosecond) that the test finished
// It is provided automatically by the runner if left at 0
End int64
// Duration is calculated automatically by the runner as the period between Start and End
// the testcase should not write to this field
Duration int64
// Iteration is provided automatically by the runner and is the iteration sequence number
// of the test
Iteration int
// Retry is for test that fail and want to be retried
// They should add their context to the result in the Retry field to cause the context
// to be rescheduled on the runner (at the end of the current work queue)
// Take care to add some counter to the context so you can avoid infinite retries
// Also take care that you don't return more work for the next delegate if you
// are scheduling a retry
Retry *TestContext
// Attributes is a map that the test case can write information key/value pairs to
// these values may be used by reporters when reporting the test result
Attributes TestAttributes
}
Result is passed to each test and can be manipulated by the test to indicate the outcome and other relevant information
type Runner ¶
type Runner interface {
Monitorable
// Run is used to start the runner. It may only be called once.
// The next parameter may be used to provide one or more next runners to which
// tests may forward work using by calling TriggerNext upon their completion
Run(next []DelegateRunner)
// Wait may be called on a running runner and will wait for completion of that runner
// before returning, at which time the runner is considered complete
Wait() []Result
// GetResults can be used to retieve the results from a runner
// Calling on an uncompleted runner will panic.
GetResults() []Result
// GetHighWaterMark can be used to retrieve the maximum number of tests in progress simultaneously
// at any time during the runner's execution
// Calling on an uncompleted runner will panic.
GetHighWaterMark() int
// Closed will return true if the runner is completed
Closed() bool
// Closing will return true if Wait has been called but not yet returned
Closing() bool
// Running will return true if the runner is running or closing but not yet closed
Running() bool
// GetThrottled will return the number of calls throttled (delayed) due to the runner
// reaching max in progress tests at one or more points during executions.
// Calling on an uncompleted runner will panic.
GetThrottled() int
// GetTargetBHCA returns the target BHCA configured for the runner
GetTargetBHCA() int
// GetMaxInProgress returns the max in progress limit (0 = unlimited) configured
// for the runner
GetMaxInProgress() int
// GetName returns the runner name
GetName() string
}
Runner defines the interface elements common to all runners
type RunnerRegistry ¶ added in v0.0.14
type RunnerRegistry interface {
// Delegate work to a runner
// The runner must be found (by name), a delegate runner and must not
// have been waited, otherwise an error will be returned
Delegate(name string, context TestContext) error
}
Runner registry is used to access runners by name by tests that implement RegistryAwareTest
type Stat ¶
type Stat struct {
// Pass represents the count of pass testcases and must be set
Pass int
// Fail represents the count of failed testcases and must be set
Fail int
// Remaining should be set to the number of remaining tests, if known
Remaining *int
// InProgress represents the count of inprogress testcases and must be set
// unless PFOnly is set
InProgress int
// Throttled represents the count of throttled calls due to max being reached
Throttled int
// HighWaterMark represents the high water mark (max in progress) seen during
// run
HWM int
// CumulativeRuntimeNS represents the cumulative run time of all completed testcases
// in nanoseconds and must be set unless PFOnly is set
CumulativeRuntimeNS int64
// MaxLatencyMS must be set to the ns taken by the longest running completed instance
// in nanoseconds and must be set unless PFOnly is set
MaxLatencyNS int64
// EffectiveBHCA must be set to the calculated achieved BHCA, unless PFOnly is set
EffectiveBHCA int64
// Completed should be set to true when a runner completes, unless NonCompletable is set
Completed bool
// NonCompletable indicates that the monitor is not an entity that completes
NonCompletable bool
// Aborted must be set if a runner was never started due to master abort signal
Aborted bool
// Number of retries
Retries int
}
Stat is representation of current operational state used to communicate between runners and monitor
type Test ¶
type Test interface {
// Run will be called to execute the test
// The test should populate the rest object and, if needed, utilize testContext
// for parameters necessary for the operation of the specific iteration of the test
// If it returns a test context, a copy will be sent to any delegate runners attached
// to the current runner to trigger next tests
Run(result *Result, testContext TestContext) *TestContext
}
Test is the interface that tests must implement A Result is passed and must be completed by the test The testContext will contain any contextual values passed to the test A Test is a singleton that will be executed multiple times, therefore the implementing struct should not carry state unless that state is common to all instances of the test
type TestAttributes ¶ added in v0.0.6
type TestAttributes map[string]interface{}
TestAttributes is also a map of key/value pairs that can be set in a test result for reporting purposes
type TestContext ¶
type TestContext map[string]interface{}
TestContext is a map of key/value paris that can be used to feed information to individual test executions
type TestCreator ¶
type TestCreator interface {
// NewInstance creates a new instance of a test
NewInstance() Test
}
TestCreator is used by test registry to create a new instance of a test TestCreators should be registered with the registry package to make them available for use by a sequence Typically a test will also implement TestCreator allowing it to create instances of itself
Directories
¶
| Path | Synopsis |
|---|---|
|
internal
|
|
|
Package monitoring provides real time monitoring display of runner execution
|
Package monitoring provides real time monitoring display of runner execution |
|
Package registry provides a package that can be used to register tests that can then be retrieved by name this allows for config file driven testing
|
Package registry provides a package that can be used to register tests that can then be retrieved by name this allows for config file driven testing |
|
Package reporting provides features to allow for the generation of test reports
|
Package reporting provides features to allow for the generation of test reports |
|
Package runner provides runner implementations for running testcases at load.
|
Package runner provides runner implementations for running testcases at load. |
|
Package sequence provides the sequencer that runs tests from a YAML description.
|
Package sequence provides the sequencer that runs tests from a YAML description. |
|
Package util provides general purpose utilities
|
Package util provides general purpose utilities |