test

package
v0.0.0-...-f45db13 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2017 License: BSD-3-Clause Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PktgenGetPortsNumberCommand = "printf(\"%d\\n\", pktgen.portStats(\"all\", \"port\").n);"
	PktgenGetPortStatsCommand   = "stat = pktgen.portStats(\"all\", \"rate\");"
	PktgenPrintPortStatsCommand = "printf(\"%%d %%d %%d %%d\\n\", stat[%d].pkts_tx, stat[%d].mbits_tx, stat[%d].pkts_rx, stat[%d].mbits_rx);"
	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.

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\.$`)

	DeleteContainersOnExit = true
)

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 AppConfig

type AppConfig struct {
	// Specifies host name where docker daemon is running. Port number
	// is specified in DockerConfig structure and is the same for all
	// hosts.
	HostName string `json:"host-name"`
	// 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"`
}

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
	TestAppPktgen
)

Constants for different application types.

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 docker
	// daemon. Usually 2375.
	DockerPort int `json:"docker-port"`
	// Network socket port to be used to communicate with pktgen
	// program. Usually 22022.
	PktgenPort int `json:"pktgen-port"`
}

DockerConfig struct has settings controlling communication with docker daemons.

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 Measurement

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

Measurement has measured by benchmark values.

type Report

type Report struct {
	Done chan error
	Pipe chan TestcaseReportInfo
	// contains filtered or unexported fields
}

Report represents test report.

func StartReport

func StartReport(logdir string) *Report

StartReport initializes and starts report writing.

func (*Report) FinishReport

func (r *Report) FinishReport()

FinishReport finishes report writing.

type RunningApp

type RunningApp struct {
	Status TestStatus

	Benchmarks [][]Measurement
	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
)

Constants for different test statuses.

type TestType

type TestType int

TestType is a type of the test.

const (
	TestTypeBenchmark TestType = iota
	TestTypeScenario
)

Constants for different test types.

func (*TestType) UnmarshalJSON

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

UnmarshalJSON unmarshals data and checks test type validity.

type TestcaseReportInfo

type TestcaseReportInfo struct {
	Status        TestStatus
	Benchdata     []Measurement
	CoresStats    CoresInfo
	CoreLastValue int
	CoreDecreased bool
	Apps          []RunningApp
}

TestcaseReportInfo has all info about test.

type TestsuiteConfig

type TestsuiteConfig struct {
	// Settings which control docker daemon functionality.
	Config DockerConfig `json:"docker-config"`
	// Array of test cases.
	Tests []TestConfig `json:"tests"`
}

TestsuiteConfig struct has settings which describe whole test suite.

func ReadConfig

func ReadConfig(fileName string) (*TestsuiteConfig, error)

ReadConfig function reads and parses config file.

func (*TestsuiteConfig) RunAllTests

func (config *TestsuiteConfig) RunAllTests(logdir string)

RunAllTests launches all tests.

Directories

Path Synopsis
localTesting
Only IPv4, Only tunnel, Only ESP, Only AES-128-CBC
Only IPv4, Only tunnel, Only ESP, Only AES-128-CBC
stability

Jump to

Keyboard shortcuts

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