Documentation
¶
Overview ¶
Package runner contains code for a test runner that can run a list of load tests, wait for them to complete, and report on the results.
Index ¶
- func AfterIntervalFunction(d time.Duration) func()
- func CountConfigs(configMap map[string][]*grpcv1.LoadTest) map[string]int
- func CreateQueueMap(configs []*grpcv1.LoadTest, qs QueueSelectorFunction) map[string][]*grpcv1.LoadTest
- func DecodeFromFiles(fileNames []string) ([]*grpcv1.LoadTest, error)
- func LogPrefixFmt(configMap map[string][]*grpcv1.LoadTest) string
- func NewLoadTestGetter() clientset.LoadTestGetter
- func TestCaseNameFromAnnotations(annotationKeys ...string) func(*grpcv1.LoadTest) string
- func ValidateConcurrencyLevels(configMap map[string][]*grpcv1.LoadTest, concurrencyLevels map[string]int) error
- type ConcurrencyLevels
- type FileNames
- type QueueSelectorFunction
- type Reporter
- type Runner
- type TestCaseReporter
- func (tcr *TestCaseReporter) Duration() time.Duration
- func (tcr *TestCaseReporter) Error(format string, v ...interface{})
- func (tcr *TestCaseReporter) Index() int
- func (tcr *TestCaseReporter) Info(format string, v ...interface{})
- func (tcr *TestCaseReporter) SetEndTime(t time.Time)
- func (tcr *TestCaseReporter) SetStartTime(t time.Time)
- func (tcr *TestCaseReporter) Warning(format string, v ...interface{})
- type TestSuiteReporter
- func (tsr *TestSuiteReporter) Duration() time.Duration
- func (tsr *TestSuiteReporter) NewTestCaseReporter(config *grpcv1.LoadTest) *TestCaseReporter
- func (tsr *TestSuiteReporter) Queue() string
- func (tsr *TestSuiteReporter) SetEndTime(t time.Time)
- func (tsr *TestSuiteReporter) SetStartTime(t time.Time)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AfterIntervalFunction ¶
AfterIntervalFunction returns a function that stops for a time interval. This function is provided so it can be replaced with a fake for testing.
func CountConfigs ¶
CountConfigs counts the number of configs in each queue.
func CreateQueueMap ¶
func CreateQueueMap(configs []*grpcv1.LoadTest, qs QueueSelectorFunction) map[string][]*grpcv1.LoadTest
CreateQueueMap maps LoadTest configurations into execution queues. Configurations are mapped into queues using a queue selector.
func DecodeFromFiles ¶
DecodeFromFiles reads LoadTest configurations from a set of files. Each file is a multipart YAML file containing LoadTest configurations.
func LogPrefixFmt ¶
LogPrefixFmt returns a string to format log line prefixes for each test. This string is used to format queue name and test index into a prefix.
func NewLoadTestGetter ¶
func NewLoadTestGetter() clientset.LoadTestGetter
NewLoadTestGetter returns a client to interact with LoadTest resources. The client can be used to create, query for status and delete LoadTests.
func TestCaseNameFromAnnotations ¶ added in v0.9.0
TestCaseNameFromAnnotations returns a function to generate test case names. Test case names are derived from the value of annotations added to the test configuration.
func ValidateConcurrencyLevels ¶
func ValidateConcurrencyLevels(configMap map[string][]*grpcv1.LoadTest, concurrencyLevels map[string]int) error
ValidateConcurrencyLevels checks that all queues have levels defined. LoadTests are mapped into queues and run concurrently. A concurrency level must be specified for each queue.
Types ¶
type ConcurrencyLevels ¶
ConcurrencyLevels defines an accumulator flag for concurrency levels. Concurrency levels are in the form [<queue name>:]<concurrency level>. These values are parsed and accumulated into a map.
func (*ConcurrencyLevels) Set ¶
func (c *ConcurrencyLevels) Set(value string) error
Set implements the flag.Value interface.
func (*ConcurrencyLevels) String ¶
func (c *ConcurrencyLevels) String() string
String implements the flag.Value interface.
type FileNames ¶
type FileNames []string
FileNames defines an accumulator flag for file names.
type QueueSelectorFunction ¶
QueueSelectorFunction maps a LoadTest configuration to an execution queue.
func QueueSelectorFromAnnotation ¶
func QueueSelectorFromAnnotation(key string) QueueSelectorFunction
QueueSelectorFromAnnotation sets up key selection from a config annotation. This function returns a queue selector function that looks for a specific key annotation and returns the value of the annotation.
type Reporter ¶ added in v0.6.1
type Reporter struct {
// contains filtered or unexported fields
}
Reporter instances log the progress of the test suites and cases, filling a xunit.Report instance if provided.
func NewReporter ¶ added in v0.6.1
NewReporter constructs a new reporter instance.
func (*Reporter) Duration ¶ added in v0.6.1
Duration returns the elapsed time between the time.Time instances passed to the SetStartTime and SetEndTime methods. Ideally, these should be used at the beginning and end of running all test suites to produce the wall-clock time. If these values are not set, a zero value is returned.
func (*Reporter) NewTestSuiteReporter ¶ added in v0.6.1
func (r *Reporter) NewTestSuiteReporter(qName string, logPrefixFmt string, testCaseName func(*grpcv1.LoadTest) string) *TestSuiteReporter
NewTestSuiteReporter creates a new suite reporter instance.
func (*Reporter) SetEndTime ¶ added in v0.6.1
SetEndTime records the end time for the test suites as a whole.
func (*Reporter) SetStartTime ¶ added in v0.6.1
SetStartTime records the start time for the test suites as a whole.
type Runner ¶
type Runner struct {
// contains filtered or unexported fields
}
Runner contains the information needed to run multiple sets of LoadTests.
func NewRunner ¶
func NewRunner(loadTestGetter clientset.LoadTestGetter, afterInterval func(), retries uint) *Runner
NewRunner creates a new Runner object.
func (*Runner) Run ¶
func (r *Runner) Run(ctx context.Context, configs []*grpcv1.LoadTest, suiteReporter *TestSuiteReporter, concurrencyLevel int, done chan<- *TestSuiteReporter)
Run runs a set of LoadTests at a given concurrency level.
type TestCaseReporter ¶
type TestCaseReporter struct {
// contains filtered or unexported fields
}
TestCaseReporter collects events for logging and reporting during a test.
func (*TestCaseReporter) Duration ¶ added in v0.6.1
func (tcr *TestCaseReporter) Duration() time.Duration
Duration returns the elapsed time between the time.Time instances passed to the SetStartTime and SetEndTime methods. Ideally, these should be used at the beginning and end of the test to produce the wall-clock time. If these values are not set, a zero value is returned.
func (*TestCaseReporter) Error ¶
func (tcr *TestCaseReporter) Error(format string, v ...interface{})
Error records an error message generated during the test. The error that caused the message to be generated is also included.
func (*TestCaseReporter) Index ¶
func (tcr *TestCaseReporter) Index() int
Index returns the index of the test case in the test suite (and queue).
func (*TestCaseReporter) Info ¶
func (tcr *TestCaseReporter) Info(format string, v ...interface{})
Info records an informational message generated by the test.
func (*TestCaseReporter) SetEndTime ¶
func (tcr *TestCaseReporter) SetEndTime(t time.Time)
SetEndTime records the end time of the test.
func (*TestCaseReporter) SetStartTime ¶
func (tcr *TestCaseReporter) SetStartTime(t time.Time)
SetStartTime records the start time of the test.
func (*TestCaseReporter) Warning ¶
func (tcr *TestCaseReporter) Warning(format string, v ...interface{})
Warning records a warning message generated during the test. The error that caused the message to be generated is also included.
type TestSuiteReporter ¶
type TestSuiteReporter struct {
// contains filtered or unexported fields
}
TestSuiteReporter manages reports for tests that share a runner queue.
func (*TestSuiteReporter) Duration ¶ added in v0.6.1
func (tsr *TestSuiteReporter) Duration() time.Duration
Duration returns the elapsed time between the time.Time instances passed to the SetStartTime and SetEndTime methods. Ideally, these should be used at the beginning and end of the test suite to produce the wall-clock time. If these values are not set, a zero value is returned.
func (*TestSuiteReporter) NewTestCaseReporter ¶
func (tsr *TestSuiteReporter) NewTestCaseReporter(config *grpcv1.LoadTest) *TestCaseReporter
NewTestCaseReporter creates a new reporter instance.
func (*TestSuiteReporter) Queue ¶
func (tsr *TestSuiteReporter) Queue() string
Queue returns the name of the queue containing tests for this test suite.
func (*TestSuiteReporter) SetEndTime ¶ added in v0.6.1
func (tsr *TestSuiteReporter) SetEndTime(t time.Time)
SetEndTime records the end time of the test suite.
func (*TestSuiteReporter) SetStartTime ¶ added in v0.6.1
func (tsr *TestSuiteReporter) SetStartTime(t time.Time)
SetStartTime records the start time of the test suite.