test

package
v0.9.3-0...-08371e3 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2021 License: BSD-3-Clause Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PktgenGetPortsNumberCommand = "io.write(string.format(\"%d\\n\", pktgen.portStats(\"all\", \"port\").n)); io.flush();"
	PktgenGetPortStatsCommand   = "stat = pktgen.portStats(\"all\", \"rate\");"
	PktgenPrintPortStatsCommand = "" /* 134-byte string literal not displayed */
	PktgenExitCommand           = "os.exit(0);"

	PktgenGetPortsNumberFormat = "%d"
	PktgenGetPortStatsFormat   = "%d %d %d %d"
)

Pktgen commands constants

View Source
const (
	LogOffLvl   LogLevel = iota
	LogPanicLvl          = LogOffLvl
	LogErrorsLvl
	LogWarningsLvl
	LogInfoLvl
	LogDebugLvl
)

Constants for different log levels.

View Source
const (
	AbRequestsPerSecond = iota
	AbTimePerRequest
	AbTimePerRequestConcurrent
	AbTransferRate
)

Indexes in array of Apache Benchmark stats ApacheBenchmarkStats

View Source
const (
	ReceivedSentRatio = iota
	Speed
	MedianLatency
	AverageLatency
	Stddev
)

Indexes in array of latency stats LatencyStats

View Source
const (
	WrkRequestsPerSecond = iota
	WrkTransferRate
)

Indexes in array of Wireshark Benchmark stats WrkBenchmarkStats

Variables

View Source
var (
	TestPassedRegexp = regexp.MustCompile(`^TEST PASSED$`)
	TestFailedRegexp = regexp.MustCompile(`^TEST FAILED$`)
	TestCoresRegexp  = regexp.MustCompile(`^DEBUG: System is using (\d+) cores now\. (\d+) cores are left available\.$`)
	TestPerfRegexp   = regexp.MustCompile(`^Output: Packets/sec\: (\d+) Mbits/sec\: (\d+)$`)
	ABStatsRegexps   = [4]*regexp.Regexp{
		regexp.MustCompile(`^Requests per second: *(\d+\.\d+) \[#/sec\] \(mean\)$`),
		regexp.MustCompile(`^Time per request: *(\d+\.\d+) \[ms\] \(mean\)$`),
		regexp.MustCompile(`^Time per request: *(\d+\.\d+) \[ms\] \(mean, across all concurrent requests\)$`),
		regexp.MustCompile(`^Transfer rate: *(\d+\.\d+) \[Kbytes/sec\] received$`),
	}
	LatStatsRegexps = [5]*regexp.Regexp{
		regexp.MustCompile(`received\/sent= *(\d+\.?\d*) %$`),
		regexp.MustCompile(`speed= *(\d+\.?\d*)$`),
		regexp.MustCompile(`median= *(\d+\.?\d*) μs$`),
		regexp.MustCompile(`average= *(\d+\.?\d*) μs$`),
		regexp.MustCompile(`stddev= *(\d+\.?\d*) μs$`),
	}
	WrkStatsRegexps = [2]*regexp.Regexp{
		regexp.MustCompile(`Requests/sec: *(\d+\.?\d*)$`),
		regexp.MustCompile(`Transfer/sec: *(\d+\.?\d*)([K|M|G|T|P])B$`),
	}

	NoDeleteContainersOnExit = false
)

Test statuses regular expressions.

Functions

func LogDebug

func LogDebug(v ...interface{})

LogDebug logs if level is is equal to or higher than LogDebugLvl.

func LogError

func LogError(v ...interface{})

LogError logs if level is is equal to or higher than LogErrorsLvl.

func LogErrorsIfNotNil

func LogErrorsIfNotNil(err error, v ...interface{})

LogErrorsIfNotNil logs if level is equal to or higher than LogErrorsLvl if error is not nil.

func LogInfo

func LogInfo(v ...interface{})

LogInfo logs if level is is equal to or higher than LogInfoLvl.

func LogPanic

func LogPanic(v ...interface{})

LogPanic prints error and calls panic.

func LogWarning

func LogWarning(v ...interface{})

LogWarning logs if level is is equal to or higher than LogWarningsLvl.

func SetLogLevel

func SetLogLevel(ll LogLevel)

SetLogLevel sets a log level to given value.

Types

type ApacheBenchmarkStats

type ApacheBenchmarkStats struct {
	Stats [4]float64
}

ApacheBenchmarkStats has info about running Apache Benchmark web client.

type AppConfig

type AppConfig struct {
	// Specifies docker image to run for this test application.
	ImageName string `json:"image-name"`
	// Specifies application type. Valid values are "TestAppGo" and "TestAppPktgen"
	Type AppType `json:"app-type"`
	// Specifies an array of application command line arguments. First
	// argument is application executable.
	CommandLine []string `json:"exec-cmd"`
	// contains filtered or unexported fields
}

AppConfig struct has settings controlling test distributed application parameters.

func (*AppConfig) String

func (app *AppConfig) String() string

type AppType

type AppType int

AppType is a type of application.

const (
	TestAppGo AppType = iota
	TestAppPerf
	TestAppPktgen
	TestAppApacheBenchmark
	TestAppLatency
	TestAppWrkBenchmark
)

Constants for different application types.

func (AppType) String

func (i AppType) String() string

func (*AppType) UnmarshalJSON

func (at *AppType) UnmarshalJSON(data []byte) error

UnmarshalJSON unmarshals data and checks app type validity.

type BenchmarkConfig

type BenchmarkConfig struct {
	// Array of strings to pass to pktgen Lua scripting interface upon
	// startup. All commands are executed once after getting port
	// number information from pktgen.
	StartCommands []string `json:"pktgen-startup-commands"`
	// Start gathering statistics after this number of
	// nanoseconds. Zero by default, so gather all statisctics.
	MeasureAfter time.Duration `json:"measure-after"`
	// Gather statistics for this number of nanoseconds. When zero,
	// don't stop gathering statistics. Zero by default.
	MeasureFor time.Duration `json:"measure-for"`
}

BenchmarkConfig struct has settings controlling benchmark parameters, usually for tests with type TestTypeBenchmark.

type CoresInfo

type CoresInfo struct {
	CoresUsed, CoresFree int
}

CoresInfo has info about used and free cores.

type DockerConfig

type DockerConfig struct {
	// Timeout for one http communication request. This setting is
	// controlling all framework-application communications. If no
	// answer is received after this time, test is considered failed.
	RequestTimeout time.Duration `json:"request-timeout"`
	// Version of docker remote client protocol. Should not be greater
	// than docker daemon which runs on network hosts.
	DockerVersion string `json:"docker-client-version"`
	// Whether to use Privileged container setting. Should be "true"
	// if DPDK is used on any of network hosts.
	Privileged bool `json:"privileged"`
	// Specifies volumes to map from outside system into docker
	// container. If wrong filesystems are specified in this array,
	// DPDK doesn't work.
	Volumes []string `json:"map-volumes"`
	// Network socket port to be used to communicate with pktgen
	// program. Usually 22022.
	PktgenPort int `json:"pktgen-port"`
	// Delay in seconds after launching pktgen before first connection
	// attempt.
	PktgenDelay time.Duration `json:"pktgen-delay"`
}

DockerConfig struct has settings controlling communication with docker daemons.

type HostsList

type HostsList []hostPort

HostsList is a slice of host:port pairs that are used to replace values read from JSON config file.

func (*HostsList) Set

func (hl *HostsList) Set(value string) error

func (*HostsList) String

func (hl *HostsList) String() string

type LatencyStats

type LatencyStats struct {
	Stats [5]float64
}

LatencyStats has info about finished latency perf test

type LogLevel

type LogLevel int

LogLevel is a type indicating the level of logging.

type Logger

type Logger struct {
	// contains filtered or unexported fields
}

Logger type contains a logging object that generates lines of output to an io.Writer and file for logging.

func NewLogger

func NewLogger(output *os.File) *Logger

NewLogger creates and returns a new Logger object initialized with file for output.

func (*Logger) LogDebug

func (l *Logger) LogDebug(v ...interface{})

LogDebug logs if level is is equal to or higher than LogDebugLvl. Logs to standard output and to file in l.

func (*Logger) LogError

func (l *Logger) LogError(v ...interface{})

LogError logs if level is is equal to or higher than LogErrorsLvl. Logs to standard output and to file in l.

func (*Logger) LogErrorsIfNotNil

func (l *Logger) LogErrorsIfNotNil(err error, v ...interface{})

LogErrorsIfNotNil logs if level is equal to or higher than LogErrorsLvl if error is not nil.

func (*Logger) LogInfo

func (l *Logger) LogInfo(v ...interface{})

LogInfo logs if level is is equal to or higher than LogInfoLvl. Logs to standard output and to file in l.

func (*Logger) LogPanic

func (l *Logger) LogPanic(v ...interface{})

LogPanic prints error and calls panic.

func (*Logger) LogWarning

func (l *Logger) LogWarning(v ...interface{})

LogWarning logs if level is is equal to or higher than LogWarningsLvl. Logs to standard output and to file in l.

func (*Logger) String

func (l *Logger) String() string

Returns the name of the file set for logging or empty string if it exists.

type PktgenMeasurement

type PktgenMeasurement struct {
	PktsTX, MbitsTX, PktsRX, MbitsRX int64
}

PktgenMeasurement has measured by pktgen benchmark values.

type Report

type Report struct {
	// contains filtered or unexported fields
}

Report represents test report.

func StartReport

func StartReport(logdir string) *Report

StartReport initializes and starts report writing.

func (*Report) AddTestResult

func (r *Report) AddTestResult(tr *TestcaseReportInfo)

func (*Report) FinishReport

func (r *Report) FinishReport()

FinishReport writes report into html and json files.

type ReportCoresInfo

type ReportCoresInfo struct {
	CoresInfo
	CoreLastValue int
	CoreDecreased bool
}

ReportCoresInfo has info about cores for final report

type RunningApp

type RunningApp struct {
	Status TestStatus

	PktgenBenchdata [][]PktgenMeasurement
	CoresStats      []CoresInfo

	Logger *Logger
	// contains filtered or unexported fields
}

RunningApp structure represents the app being run.

func (*RunningApp) InitTest

func (app *RunningApp) InitTest(logger *Logger, index int, config *AppConfig, dc *DockerConfig, test *TestConfig)

InitTest makes test initialization.

func (*RunningApp) String

func (app *RunningApp) String() string

type TestConfig

type TestConfig struct {
	// Test case name identifier. It is better to be unique.
	Name string `json:"name"`
	// Test time out. For benchmark tests this is the duration for
	// which test applications are running. For scenario tests this is
	// the duration after which test is considered hanging and
	// failed. For both test types applications are forcedly stopped
	// after this time.
	TestTime time.Duration `json:"test-time"`
	// Type of the test. Valid values are "TestTypeBenchmark" and
	// "TestTypeScenario".
	Type TestType `json:"test-type"`
	// Array of settings specific for each test application.
	Apps []AppConfig `json:"test-apps"`
	// Benchmark controlling settings. May be omitted for scenario
	// tests.
	BenchConf BenchmarkConfig `json:"benchmarking-settings"`
}

TestConfig struct has settings for one test case.

func (*TestConfig) String

func (test *TestConfig) String() string

type TestReport

type TestReport struct {
	AppIndex  int
	AppStatus TestStatus
	// contains filtered or unexported fields
}

TestReport has info about test status and application.

type TestStatus

type TestStatus int

TestStatus is a status of the test.

const (
	TestCreated TestStatus = iota
	TestInitialized
	TestInvalid
	TestRunning
	TestReportedPassed
	TestReportedFailed
	TestTimedOut
	TestInterrupted
)

Constants for different test statuses.

func (TestStatus) MarshalJSON

func (ts TestStatus) MarshalJSON() ([]byte, error)

func (TestStatus) String

func (i TestStatus) String() string

func (*TestStatus) UnmarshalJSON

func (at *TestStatus) UnmarshalJSON(data []byte) error

UnmarshalJSON unmarshals data and checks app type validity.

type TestType

type TestType int

TestType is a type of the test.

const (
	TestTypeBenchmark TestType = iota
	TestTypeScenario
	TestTypeApacheBenchmark
	TestTypeLatency
	TestTypeWrkBenchmark
)

Constants for different test types.

func (TestType) String

func (i TestType) String() string

func (*TestType) UnmarshalJSON

func (at *TestType) UnmarshalJSON(data []byte) error

UnmarshalJSON unmarshals data and checks test type validity.

type TestcaseReportInfo

type TestcaseReportInfo struct {
	TestName string
	Status   TestStatus
	// Pktgen type tests
	PktgenBenchdata []PktgenMeasurement `json:",omitempty"`
	CoresStats      *ReportCoresInfo    `json:",omitempty"`
	// Apache benchmark type tests
	ABStats *ApacheBenchmarkStats `json:",omitempty"`
	// Latency type tests
	LatStats *LatencyStats `json:",omitempty"`
	// Latency type tests
	WStats *WrkBenchmarkStats `json:",omitempty"`
	// Per application statistics
	Apps []RunningApp `json:"-"`
}

TestcaseReportInfo has all info about test.

type TestsList

type TestsList []*regexp.Regexp

func (*TestsList) Set

func (tl *TestsList) Set(value string) error

func (*TestsList) String

func (tl *TestsList) String() string

type TestsuiteConfig

type TestsuiteConfig struct {
	// Settings which control docker daemon functionality.
	Config DockerConfig `json:"docker-config"`
	// A set of variables for tests command lines
	Variables map[string]string
	// Array of test cases.
	Tests []TestConfig `json:"tests"`
}

TestsuiteConfig struct has settings which describe whole test suite.

func ReadConfig

func ReadConfig(fileName string, hl HostsList, vl VariablesList) (*TestsuiteConfig, error)

ReadConfig function reads and parses config file.

func (*TestsuiteConfig) RunAllTests

func (config *TestsuiteConfig) RunAllTests(logdir string, tl TestsList, repeatCount int) int

RunAllTests launches all tests.

type TestsuiteReport

type TestsuiteReport struct {
	Timestamp string
	Tests     []*TestcaseReportInfo
}

TeststuiteReport has information about all test results.

type VariablesList

type VariablesList map[string]string

Variable is a string in a form of NAME=VALUE pair which is replaced inside of tests command lines.

func (*VariablesList) Set

func (vl *VariablesList) Set(value string) error

func (*VariablesList) String

func (vl *VariablesList) String() string

type WrkBenchmarkStats

type WrkBenchmarkStats struct {
	Stats [2]float64
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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