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 GetTestPods(ctx context.Context, loadTest *grpcv1.LoadTest, ...) ([]*corev1.Pod, error)
- func LogFileName(podName string, containerName string) string
- func LogPrefixFmt(configMap map[string][]*grpcv1.LoadTest) string
- func NewGRPCTestClientset() clientset.GRPCTestClientset
- func NewK8sClientset() *kubernetes.Clientset
- func NewLoadTestGetter() clientset.LoadTestGetter
- func NewPodsGetter() corev1types.PodsGetter
- func PodLogProperties(logInfos []*LogInfo, logURLPrefix string, prefix ...string) map[string]string
- func PodLogPropertyKey(logInfo *LogInfo, prefix ...string) string
- func PodNameElem(podName, loadTestName string) string
- func PodNameProperties(pods []*corev1.Pod, loadTestName string, prefix ...string) map[string]string
- func PodNamePropertyKey(podNameElem string, prefix ...string) string
- 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 LogInfo
- type QueueSelectorFunction
- type Reporter
- type Runner
- type TestCaseReporter
- func (tcr *TestCaseReporter) AddProperty(key, value string)
- 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 GetTestPods ¶ added in v1.3.0
func GetTestPods(ctx context.Context, loadTest *grpcv1.LoadTest, podsGetter corev1types.PodsGetter) ([]*corev1.Pod, error)
GetTestPods retrieves the pods associated with a LoadTest.
func LogFileName ¶ added in v1.3.0
LogFileName constructs a log file name from pod and container names.
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 NewGRPCTestClientset ¶ added in v0.10.0
func NewGRPCTestClientset() clientset.GRPCTestClientset
NewGRPCTestClientset returns a new GRPCTestClientset.
func NewK8sClientset ¶ added in v0.10.0
func NewK8sClientset() *kubernetes.Clientset
NewK8sClientset returns a new Kubernetes clientset.
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 NewPodsGetter ¶ added in v0.10.0
func NewPodsGetter() corev1types.PodsGetter
NewPodsGetter returns a new PodsGetter.
func PodLogProperties ¶ added in v1.3.0
PodLogProperties creates a map of log property keys to log path urls.
func PodLogPropertyKey ¶ added in v1.3.0
PodLogPropertyKey generates the key for a pod log property.
func PodNameElem ¶ added in v1.3.0
PodNameElem returns the pod name element used to construct a pod name. Pods within a LoadTest are distinguished by elements attached to the LoadTest name, such as client-0, driver-0, server-0.
func PodNameProperties ¶ added in v1.3.0
PodNameProperties creates a map of pod name property keys to pod names.
func PodNamePropertyKey ¶ added in v1.3.0
PodNamePropertyKey generates the key for a pod name property.
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 LogInfo ¶ added in v1.3.0
type LogInfo struct { // PodNameElem is the element added to the LoadTest name to // construct the pod name. Examples of PodNameElem are client-0, // driver-0 and server-0. PodNameElem string // ContainerName is the container's name where the log comes from. ContainerName string // LogPath is the path pointing to the log file. LogPath string }
LogInfo contains infomation for each log file.
func SaveAllLogs ¶ added in v1.3.0
func SaveAllLogs(ctx context.Context, loadTest *grpcv1.LoadTest, podsGetter corev1types.PodsGetter, pods []*corev1.Pod, podLogDir string) ([]*LogInfo, error)
SaveAllLogs saves all container logs to files under a given directory. This function goes through every container in every pods and writes its log to a file, if it is not empty. Information about each saved log is returned as a pointer to a LogInfo object.
func SaveLog ¶ added in v1.3.0
func SaveLog(ctx context.Context, loadTest *grpcv1.LoadTest, podsGetter corev1types.PodsGetter, pod *corev1.Pod, containerName string, podLogDir string) (*LogInfo, error)
SaveLog retrieves and saves logs for a specific container. This function retrieves the log for a single container within a given pod, and writes it to a file, if it is not empty. Information about the saved log is returned as a pointer to a LogInfo object.
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, podsGetter corev1types.PodsGetter, afterInterval func(), retries uint, deleteSuccessfulTests bool, logURLPrefix string) *Runner
NewRunner creates a new Runner object.
type TestCaseReporter ¶
type TestCaseReporter struct {
// contains filtered or unexported fields
}
TestCaseReporter collects events for logging and reporting during a test.
func (*TestCaseReporter) AddProperty ¶ added in v0.10.0
func (tcr *TestCaseReporter) AddProperty(key, value string)
AddProperty adds a key-value property to the test case.
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.