testutil

package
v1.5.2 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2018 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func VppMock

func VppMock(vppMock *mock.VppAdapter, vppMockSetups ...func(adapter *mock.VppAdapter)) *govppmux.GOVPPPlugin

VppMock allows to mock go VPP plugin in a flavor.

Types

type Given

type Given struct {
}

Given is a composition of multiple test step methods (see BDD Given keyword).

type Logger

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

Logger is a wrapper of Logrus logger. In addition to Logrus functionality, it allows to define static log fields that are added to all subsequent log entries. It also automatically appends file name and line from which the log comes. In order to distinguish logs from different go routines, a tag (number that is based on the stack address) is computed. To achieve better readability, numeric value of a tag can be replaced with a string using SetTag function.

func NewLogger

func NewLogger(name string, t *testing.T) *Logger

NewLogger is a constructor which creates instances of named logger. This constructor is called from logRegistry which is useful when log levels need to be changed by management API (such as REST).

Example:

logger := NewLogger("loggerXY")
logger.Info()

func (*Logger) Debug

func (logger *Logger) Debug(args ...interface{})

Debug logs a message at level Debug on the standard logger.

func (*Logger) Debugf

func (logger *Logger) Debugf(format string, args ...interface{})

Debugf logs a message at level Debug on the standard logger.

func (*Logger) Debugln

func (logger *Logger) Debugln(args ...interface{})

Debugln logs a message at level Debug on the standard logger.

func (*Logger) Error

func (logger *Logger) Error(args ...interface{})

Error logs a message at level Error on the standard logger.

func (*Logger) Errorf

func (logger *Logger) Errorf(format string, args ...interface{})

Errorf logs a message at level Error on the standard logger.

func (*Logger) Errorln

func (logger *Logger) Errorln(args ...interface{})

Errorln logs a message at level Error on the standard logger.

func (*Logger) Fatal

func (logger *Logger) Fatal(args ...interface{})

Fatal logs a message at level Fatal on the standard logger.

func (*Logger) Fatalf

func (logger *Logger) Fatalf(format string, args ...interface{})

Fatalf logs a message at level Fatal on the standard logger.

func (*Logger) Fatalln

func (logger *Logger) Fatalln(args ...interface{})

Fatalln logs a message at level Fatal on the standard logger.

func (*Logger) GetLevel

func (logger *Logger) GetLevel() logging.LogLevel

GetLevel returns the standard logger level.

func (*Logger) GetName

func (logger *Logger) GetName() string

GetName returns the logger name.

func (*Logger) Info

func (logger *Logger) Info(args ...interface{})

Info logs a message at level Info on the standard logger.

func (*Logger) Infof

func (logger *Logger) Infof(format string, args ...interface{})

Infof logs a message at level Info on the standard logger.

func (*Logger) Infoln

func (logger *Logger) Infoln(args ...interface{})

Infoln logs a message at level Info on the standard logger.

func (*Logger) Panic

func (logger *Logger) Panic(args ...interface{})

Panic logs a message at level Panic on the standard logger.

func (*Logger) Panicf

func (logger *Logger) Panicf(format string, args ...interface{})

Panicf logs a message at level Panic on the standard logger.

func (*Logger) Panicln

func (logger *Logger) Panicln(args ...interface{})

Panicln logs a message at level Panic on the standard logger.

func (*Logger) Print

func (logger *Logger) Print(args ...interface{})

Print logs a message at level Info on the standard logger.

func (*Logger) Printf

func (logger *Logger) Printf(format string, args ...interface{})

Printf logs a message at level Info on the standard logger.

func (*Logger) Println

func (logger *Logger) Println(args ...interface{})

Println logs a message at level Info on the standard logger.

func (*Logger) SetLevel

func (logger *Logger) SetLevel(level logging.LogLevel)

SetLevel sets the standard logger level.

func (*Logger) Warn

func (logger *Logger) Warn(args ...interface{})

Warn logs a message at level Warn on the standard logger.

func (*Logger) Warnf

func (logger *Logger) Warnf(format string, args ...interface{})

Warnf logs a message at level Warn on the standard logger.

func (*Logger) Warning

func (logger *Logger) Warning(args ...interface{})

Warning logs a message at level Warn on the standard logger.

func (*Logger) Warningf

func (logger *Logger) Warningf(format string, args ...interface{})

Warningf logs a message at level Warn on the standard logger.

func (*Logger) Warningln

func (logger *Logger) Warningln(args ...interface{})

Warningln logs a message at level Warn on the standard logger.

func (*Logger) Warnln

func (logger *Logger) Warnln(args ...interface{})

Warnln logs a message at level Warn on the standard logger.

func (*Logger) WithField

func (logger *Logger) WithField(key string, value interface{}) logging.LogWithLevel

WithField creates an entry from the standard logger and adds a field to it. If you want multiple fields, use `WithFields`.

Note that it doesn't log until you call Debug, Print, Info, Warn, Fatal or Panic on the logMsg it returns.

func (*Logger) WithFields

func (logger *Logger) WithFields(fields map[string]interface{}) logging.LogWithLevel

WithFields creates an entry from the standard logger and adds multiple fields to it. This is simply a helper for `WithField`, invoking it once for each field.

Note that it doesn't log until you call Debug, Print, Info, Warn, Fatal or Panic on the logMsg it returns.

type MockIfStatePub added in v1.4.0

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

MockIfStatePub is mocking for interface state publishing.

func NewIfStatePub added in v1.4.0

func NewIfStatePub() *MockIfStatePub

NewIfStatePub returns new instance of MockIfStatePub.

func (*MockIfStatePub) InterfaceState added in v1.4.0

func (m *MockIfStatePub) InterfaceState(ifaceName string, ifState *intf.InterfacesState_Interface) (bool, error)

InterfaceState returns state from mocked interface state publisher.

func (*MockIfStatePub) Put added in v1.4.0

func (m *MockIfStatePub) Put(key string, data proto.Message, opts ...datasync.PutOption) error

Put is mocked implementation for interface state publishing.

type Then

type Then struct {
	iftst.ThenIface
}

Then is a composition of multiple test step methods (see BDD Then keyword).

type VppAgentT

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

VppAgentT is similar to testing.T in golang packages.

func (*VppAgentT) Setup

func (t *VppAgentT) Setup(flavor core.Flavor)

Setup registers gomega and starts the agent with the flavor argument.

func (*VppAgentT) SetupDefault

func (t *VppAgentT) SetupDefault() (flavor *VppOnlyTestingFlavor)

SetupDefault setups default behaviour of mocks and delegates to Setup(Flavor).

func (*VppAgentT) Teardown

func (t *VppAgentT) Teardown()

Teardown stops the agent.

type VppOnlyTestingFlavor

type VppOnlyTestingFlavor struct {
	*local.FlavorLocal

	IfStatePub *MockIfStatePub

	GoVPP govppmux.GOVPPPlugin
	VPP   vpp.Plugin
	// contains filtered or unexported fields
}

VppOnlyTestingFlavor glues together multiple plugins to mange VPP and linux interfaces configuration using local client.

func (*VppOnlyTestingFlavor) Inject

func (f *VppOnlyTestingFlavor) Inject() bool

Inject sets object references.

func (*VppOnlyTestingFlavor) Plugins

func (f *VppOnlyTestingFlavor) Plugins() []*core.NamedPlugin

Plugins combines Generic Plugins and Standard VPP Plugins.

type When

type When struct {
	iftst.WhenIface
}

When is a composition of multiple test step methods (see BDD When keyword).

Jump to

Keyboard shortcuts

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