runner

package
v1.5.5 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2023 License: Apache-2.0 Imports: 26 Imported by: 0

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func AfterIntervalFunction

func AfterIntervalFunction(d time.Duration) func()

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

func CountConfigs(configMap map[string][]*grpcv1.LoadTest) map[string]int

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

func DecodeFromFiles(fileNames []string) ([]*grpcv1.LoadTest, error)

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

func LogFileName(podName string, containerName string) string

LogFileName constructs a log file name from pod and container names.

func LogPrefixFmt

func LogPrefixFmt(configMap map[string][]*grpcv1.LoadTest) string

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

func PodLogProperties(logInfos []*LogInfo, logURLPrefix string, prefix ...string) map[string]string

PodLogProperties creates a map of log property keys to log path urls.

func PodLogPropertyKey added in v1.3.0

func PodLogPropertyKey(logInfo *LogInfo, prefix ...string) string

PodLogPropertyKey generates the key for a pod log property.

func PodNameElem added in v1.3.0

func PodNameElem(podName, loadTestName string) string

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

func PodNameProperties(pods []*corev1.Pod, loadTestName string, prefix ...string) map[string]string

PodNameProperties creates a map of pod name property keys to pod names.

func PodNamePropertyKey added in v1.3.0

func PodNamePropertyKey(podNameElem string, prefix ...string) string

PodNamePropertyKey generates the key for a pod name property.

func TestCaseNameFromAnnotations added in v0.9.0

func TestCaseNameFromAnnotations(annotationKeys ...string) func(*grpcv1.LoadTest) string

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

type ConcurrencyLevels map[string]int

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.

func (*FileNames) Set

func (f *FileNames) Set(value string) error

Set implements the flag.Value interface.

func (*FileNames) String

func (f *FileNames) String() string

String implements the flag.Value interface.

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

type QueueSelectorFunction = func(*grpcv1.LoadTest) string

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

func NewReporter(report *xunit.Report) *Reporter

NewReporter constructs a new reporter instance.

func (*Reporter) Duration added in v0.6.1

func (r *Reporter) 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 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

func (r *Reporter) SetEndTime(t time.Time)

SetEndTime records the end time for the test suites as a whole.

func (*Reporter) SetStartTime added in v0.6.1

func (r *Reporter) SetStartTime(t time.Time)

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.

func (*Runner) Run

func (r *Runner) Run(ctx context.Context, configs []*grpcv1.LoadTest, suiteReporter *TestSuiteReporter, concurrencyLevel int, outputDir string, 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) 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.

Directories

Path Synopsis
Package xunit defines types and utility functions in order to generate XML reports.
Package xunit defines types and utility functions in order to generate XML reports.

Jump to

Keyboard shortcuts

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