test

package
v2.0.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2019 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const AbstractFlagIndex = 1

AbstractFlagIndex is the index of the abstract flag.

View Source
const AbstractFlagName = "is-abstract"

AbstractFlagName is the name of the abstract flag.

View Source
const ColorFlagIndex = 0

ColorFlagIndex is the index of the color flag.

View Source
const ColorFlagName = "color"

ColorFlagName is the name of the color flag.

View Source
const (
	// IntegerKey is a secondary index for the integer value.
	IntegerKey = "integer"
)
View Source
const TemporaryFlagIndex = 2

TemporaryFlagIndex is the index of the temporary flag.

View Source
const TemporaryFlagName = "is-temporary"

TemporaryFlagName is the name of the temporary flag.

Variables

This section is empty.

Functions

func ArrayValueDerBuilder

func ArrayValueDerBuilder(key string, value proto.Message) []KeyValuePair

ArrayValueDerBuilder can be used to derive one StringValue for every item in the array.

func NewArrayValue

func NewArrayValue(items ...string) proto.Message

NewArrayValue creates a new instance of ArrayValue.

func NewMockDescriptor

func NewMockDescriptor(args *KVDescriptor, sb *MockSouthbound, firstFreeIndex int, withoutOps ...WithoutOp) *KVDescriptor

NewMockDescriptor creates a new instance of Mock Descriptor.

func NewStringValue

func NewStringValue(str string) proto.Message

NewStringValue creates a new instance of StringValue.

func StringValueComparator

func StringValueComparator(key string, v1, v2 proto.Message) bool

StringValueComparator is (a custom) KVDescriptor.ValueComparator for string values.

Types

type AbstractFlagImpl

type AbstractFlagImpl struct {
	TestingFlag
}

AbstractFlagImpl is used in UTs to mark "abstract" key-value pairs.

func AbstractFlag

func AbstractFlag() *AbstractFlagImpl

AbstractFlag returns a new instance of AbstractFlag for testing.

type Color

type Color int

Color is a property to be assigned to nodes for testing purposes.

const (
	// Red color.
	Red Color = iota
	// Blue color.
	Blue
	// Green color.
	Green
)

func (Color) String

func (color Color) String() string

String converts color to string.

type ColorFlagImpl

type ColorFlagImpl struct {
	TestingFlag
	Color Color
}

ColorFlagImpl implements flag used in UTs to associate "color" with nodes.

func AnyColorFlag

func AnyColorFlag() *ColorFlagImpl

AnyColorFlag can be used to match nodes with any color assigned.

func ColorFlag

func ColorFlag(color Color) *ColorFlagImpl

ColorFlag returns a new instance of color flag for testing.

type MetaWithInteger

type MetaWithInteger interface {
	// GetInteger returns the integer stored in the metadata.
	GetInteger() int
}

MetaWithInteger is interface that metadata for NameToIntMap must implement.

type MockOpType

type MockOpType int

MockOpType is used to remember the type of a simulated operation.

const (
	// MockCreate is a mock Create operation.
	MockCreate MockOpType = iota
	// MockUpdate is a mock Update operation.
	MockUpdate
	// MockDelete is a mock Delete operation.
	MockDelete
	// MockRetrieve is a mock Retrieve operation.
	MockRetrieve
)

type MockOperation

type MockOperation struct {
	OpType            MockOpType
	Descriptor        string
	Key               string
	Value             proto.Message
	Err               error
	CorrelateRetrieve []KVWithMetadata
}

MockOperation is used in UTs to remember executed descriptor operations.

type MockSouthbound

type MockSouthbound struct {
	sync.Mutex
	// contains filtered or unexported fields
}

MockSouthbound is used in UTs to simulate the state of the southbound for the scheduler.

func NewMockSouthbound

func NewMockSouthbound() *MockSouthbound

NewMockSouthbound creates a new instance of SB mock.

func (*MockSouthbound) GetKeysWithInvalidData

func (ms *MockSouthbound) GetKeysWithInvalidData() map[string]struct{}

GetKeysWithInvalidData returns a set of keys for which invalid data were provided in one of the descriptor's operations.

func (*MockSouthbound) GetValue

func (ms *MockSouthbound) GetValue(key string) *KVWithMetadata

GetValue can be used in UTs to query the state of simulated SB.

func (*MockSouthbound) GetValues

func (ms *MockSouthbound) GetValues(selector KeySelector) []*KVWithMetadata

GetValues can be used in UTs to query the state of simulated SB.

func (*MockSouthbound) PlanError

func (ms *MockSouthbound) PlanError(key string, err error, afterErrClb func())

PlanError is used to simulate error situation for the next operation over the given key.

func (*MockSouthbound) PopHistoryOfOps

func (ms *MockSouthbound) PopHistoryOfOps() []MockOperation

PopHistoryOfOps returns and simultaneously clears the history of executed descriptor operations.

func (*MockSouthbound) SetValue

func (ms *MockSouthbound) SetValue(key string, value proto.Message, metadata Metadata, origin ValueOrigin, isDerived bool)

SetValue is used in UTs to prepare the state of SB for the next Retrieve.

type NameToInteger

type NameToInteger interface {
	// LookupByName retrieves a previously stored metadata identified by <name>.
	LookupByName(valName string) (metadata MetaWithInteger, exists bool)

	// LookupByIndex retrieves a previously stored metadata identified by the given
	// integer index <metaInt>.
	LookupByIndex(metaInt int) (valName string, metadata MetaWithInteger, exists bool)
}

NameToInteger is a idxmap specialization used in the UTs for scheduler. It extends plain metadata with integer exposed as a secondary index.

type NameToIntegerRW

type NameToIntegerRW interface {
	NameToInteger
	idxmap.NamedMappingRW
}

NameToIntegerRW extends NameToInteger with write access.

func NewNameToInteger

func NewNameToInteger(title string) NameToIntegerRW

NewNameToInteger creates a new instance implementing NameToIntegerRW.

type OnlyInteger

type OnlyInteger struct {
	Integer int
}

OnlyInteger is a minimal implementation of MetaWithInteger.

func (*OnlyInteger) GetInteger

func (idx *OnlyInteger) GetInteger() int

GetInteger returns the integer stored in the metadata.

type TemporaryFlagImpl

type TemporaryFlagImpl struct {
	TestingFlag
}

TemporaryFlagImpl is used in UTs to mark "temporary" key-value pairs.

func TemporaryFlag

func TemporaryFlag() *TemporaryFlagImpl

TemporaryFlag returns a new instance of TemporaryFlag for testing.

type TestingFlag

type TestingFlag struct {
	Name, Value string
	Index       int
}

TestingFlag as a base for flags in the UTs.

func (*TestingFlag) GetIndex

func (flag *TestingFlag) GetIndex() int

GetIndex returns the assigned index.

func (*TestingFlag) GetName

func (flag *TestingFlag) GetName() string

GetName returns the assigned name.

func (*TestingFlag) GetValue

func (flag *TestingFlag) GetValue() string

GetValue returns the assigned value.

type WithoutOp

type WithoutOp int

WithoutOp references operation to leave undefined in the MockDescriptor.

const (
	// WithoutCreate tells MockDescriptor to leave Create as nil.
	WithoutCreate WithoutOp = iota
	// WithoutUpdate tells MockDescriptor to leave Update as nil.
	WithoutUpdate
	// WithoutDelete tells MockDescriptor to leave Delete as nil.
	WithoutDelete
	// WithoutRetrieve tells MockDescriptor to leave Retrieve as nil.
	WithoutRetrieve
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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