Documentation ¶
Index ¶
- Constants
- func ArrayValueDerBuilder(key string, value proto.Message) []KeyValuePair
- func NewArrayValue(items ...string) proto.Message
- func NewArrayValueWithSuffix(suffix string, items ...string) proto.Message
- func NewMockDescriptor(args *KVDescriptor, sb *MockSouthbound, firstFreeIndex int, ...) *KVDescriptor
- func NewStringValue(str string) proto.Message
- func StringValueComparator(key string, v1, v2 proto.Message) bool
- type AbstractFlagImpl
- type Color
- type ColorFlagImpl
- type MetaWithInteger
- type MockOpType
- type MockOperation
- type MockSouthbound
- func (ms *MockSouthbound) GetKeysWithInvalidData() map[string]struct{}
- func (ms *MockSouthbound) GetValue(key string) *KVWithMetadata
- func (ms *MockSouthbound) GetValues(selector KeySelector) []*KVWithMetadata
- func (ms *MockSouthbound) PlanError(key string, err error, afterErrClb func())
- func (ms *MockSouthbound) PopHistoryOfOps() []MockOperation
- func (ms *MockSouthbound) SetValue(key string, value proto.Message, metadata Metadata, origin ValueOrigin, ...)
- type NameToInteger
- type NameToIntegerRW
- type OnlyInteger
- type TemporaryFlagImpl
- type TestingFlag
- type WithoutOp
Constants ¶
const AbstractFlagIndex = 1
AbstractFlagIndex is the index of the abstract flag.
const AbstractFlagName = "is-abstract"
AbstractFlagName is the name of the abstract flag.
const ColorFlagIndex = 0
ColorFlagIndex is the index of the color flag.
const ColorFlagName = "color"
ColorFlagName is the name of the color flag.
const (
// IntegerKey is a secondary index for the integer value.
IntegerKey = "integer"
)
const TemporaryFlagIndex = 2
TemporaryFlagIndex is the index of the temporary flag.
const TemporaryFlagName = "is-temporary"
TemporaryFlagName is the name of the temporary flag.
Variables ¶
This section is empty.
Functions ¶
func ArrayValueDerBuilder ¶
ArrayValueDerBuilder can be used to derive one StringValue for every item in the array.
func NewArrayValue ¶
NewArrayValue creates a new instance of ArrayValue.
func NewArrayValueWithSuffix ¶
NewArrayValue creates a new instance of ArrayValue with a suffix appended into each item value (but not key).
func NewMockDescriptor ¶
func NewMockDescriptor(args *KVDescriptor, sb *MockSouthbound, firstFreeIndex int, withoutOps ...WithoutOp) *KVDescriptor
NewMockDescriptor creates a new instance of Mock Descriptor.
func NewStringValue ¶
NewStringValue creates a new instance of StringValue.
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 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 ¶
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.
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 ¶
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 )