testcontext

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2024 License: Apache-2.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitBus

func InitBus(tc *TestContext) *processingBus

Types

type Callback

type Callback func()

Callback provides callback to process

type EdgeNodeDescription

type EdgeNodeDescription struct {
	Key    string
	Serial string
	Model  string
}

EdgeNodeDescription must be defined in config file

func (*EdgeNodeDescription) GetEdgeNode

func (nodeDescription *EdgeNodeDescription) GetEdgeNode(tc *TestContext) *device.Ctx

GetEdgeNode returns EdgeNode for provided EdgeNodeDescription based on onboarding key (if exists) or name

type EdgeNodeOption

type EdgeNodeOption func(description *device.Ctx)

EdgeNodeOption is type to use for creation of device.Ctx

type GetEdgeNodeOpts

type GetEdgeNodeOpts func(*device.Ctx) bool

GetEdgeNodeOpts pattern to pass device modifications

type ProcAppLogFunc

type ProcAppLogFunc func(log *logs.LogEntry) error

ProcAppLogFunc provides callback to process app log

type ProcInfoFunc

type ProcInfoFunc func(info *info.ZInfoMsg) error

ProcInfoFunc provides callback to process info

type ProcLogFlowFunc

type ProcLogFlowFunc func(log *flowlog.FlowMessage) error

ProcLogFlowFunc provides callback to process flowLog

type ProcLogFunc

type ProcLogFunc func(log *elog.FullLogEntry) error

ProcLogFunc provides callback to process log

type ProcMetricFunc

type ProcMetricFunc func(metric *metrics.ZMetricMsg) error

ProcMetricFunc provides callback to process metric

type ProcTimerFunc

type ProcTimerFunc func() error

ProcTimerFunc provides callback to process on timer event

func SendCommandSSH

func SendCommandSSH(ip *string, port *int, user, password, command string, foreground bool, callbacks ...Callback) ProcTimerFunc

SendCommandSSH try to access SSH with timer and sends command

func SendFileSCP

func SendFileSCP(ip *string, port *int, user, password, filename, destpath string) ProcTimerFunc

SendFileSCP sends a file over SCP

type Project

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

Project structure for test set

type State

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

State aggregates device state

func InitState

func InitState(device *device.Ctx) *State

InitState init State object for device

func (*State) CheckReady

func (state *State) CheckReady() bool

CheckReady returns true in all needed information obtained from controller

func (*State) GetAinfoSlice

func (state *State) GetAinfoSlice() []*info.ZInfoApp

GetAinfoSlice get []*info.ZInfoApp from obtained info

func (*State) GetAppMetrics

func (state *State) GetAppMetrics() []*metrics.AppMetric

GetAppMetrics get []*metrics.AppMetric from obtained metrics

func (*State) GetBinfoSlice

func (state *State) GetBinfoSlice() []*info.ZInfoBlob

GetBinfoSlice get []*info.ZInfoBlob from obtained info

func (*State) GetCinfoSlice

func (state *State) GetCinfoSlice() []*info.ZInfoContentTree

GetCinfoSlice get []*info.ZInfoContentTree from obtained info

func (*State) GetDeviceMetrics

func (state *State) GetDeviceMetrics() *metrics.DeviceMetric

GetDeviceMetrics get *metrics.DeviceMetric from obtained metrics

func (*State) GetDinfo

func (state *State) GetDinfo() *info.ZInfoDevice

GetDinfo get *info.ZInfoDevice from obtained info

func (*State) GetInfoProcessingFunction

func (state *State) GetInfoProcessingFunction() ProcInfoFunc

GetInfoProcessingFunction returns processing function for ZInfoMsg

func (*State) GetLastInfoTime

func (state *State) GetLastInfoTime() *timestamppb.Timestamp

GetLastInfoTime get *timestamp.Timestamp for last received info

func (*State) GetMetricProcessingFunction

func (state *State) GetMetricProcessingFunction() ProcMetricFunc

GetMetricProcessingFunction returns processing function for ZMetricMsg

func (*State) GetNetworkInstanceMetrics

func (state *State) GetNetworkInstanceMetrics() []*metrics.ZMetricNetworkInstance

GetNetworkInstanceMetrics get []*metrics.ZMetricNetworkInstance from obtained metrics

func (*State) GetNiinfoSlice

func (state *State) GetNiinfoSlice() []*info.ZInfoNetworkInstance

GetNiinfoSlice get []*info.ZInfoNetworkInstance from obtained info

func (*State) GetVinfoSlice

func (state *State) GetVinfoSlice() []*info.ZInfoVolume

GetVinfoSlice get []*info.ZInfoVolume from obtained info

func (*State) GetVolumeMetrics

func (state *State) GetVolumeMetrics() []*metrics.ZMetricVolume

GetVolumeMetrics get []*metrics.ZMetricVolume from obtained metrics

func (*State) LookUp

func (state *State) LookUp(path string) (value reflect.Value, err error)

LookUp access fields of State objects by path path contains address to lookup for example: LookUp("Dinfo.Network[0].IPAddrs[0]") will return first IP of first network of EVE All top fields to lookup in: Dinfo *info.ZInfoDevice Ainfo []*info.ZInfoApp Niinfo []*info.ZInfoNetworkInstance Vinfo []*info.ZInfoVolume Cinfo []*info.ZInfoContentTree Binfo []*info.ZInfoBlob Cipherinfo []*info.ZInfoCipher AppMetrics []*metrics.AppMetric NetworkInstanceMetrics []*metrics.ZMetricNetworkInstance VolumeMetrics []*metrics.ZMetricVolume DeviceMetrics *metrics.DeviceMetric

type TestContext

type TestContext struct {
	Cloud controller.Cloud

	SdnClient *edensdn.SdnClient
	WithSdn   bool
	ProcBus   *processingBus
	Tests     map[*device.Ctx]*testing.T
	// contains filtered or unexported fields
}

TestContext is main structure for running tests

func NewTestContext

func NewTestContext() *TestContext

NewTestContext creates new TestContext

func (*TestContext) AddEdgeNodesFromDescription

func (tc *TestContext) AddEdgeNodesFromDescription()

AddEdgeNodesFromDescription adds EdgeNodes from description in test.eve param

func (*TestContext) AddNode

func (tc *TestContext) AddNode(node *device.Ctx)

AddNode add node to test context

func (*TestContext) AddProcAppLog

func (tc *TestContext) AddProcAppLog(edgeNode *device.Ctx, appUUID uuid.UUID, processFunction ProcAppLogFunc)

AddProcAppLog add processFunction, that will get all app logs for edgeNode

func (*TestContext) AddProcFlowLog

func (tc *TestContext) AddProcFlowLog(edgeNode *device.Ctx, processFunction ProcLogFlowFunc)

AddProcFlowLog add processFunction, that will get all FlowLogs for edgeNode

func (*TestContext) AddProcInfo

func (tc *TestContext) AddProcInfo(edgeNode *device.Ctx, processFunction ProcInfoFunc)

AddProcInfo add processFunction, that will get all info for edgeNode

func (*TestContext) AddProcLog

func (tc *TestContext) AddProcLog(edgeNode *device.Ctx, processFunction ProcLogFunc)

AddProcLog add processFunction, that will get all logs for edgeNode

func (*TestContext) AddProcMetric

func (tc *TestContext) AddProcMetric(edgeNode *device.Ctx, processFunction ProcMetricFunc)

AddProcMetric add processFunction, that will get all metrics for edgeNode

func (*TestContext) AddProcTimer

func (tc *TestContext) AddProcTimer(edgeNode *device.Ctx, processFunction ProcTimerFunc)

AddProcTimer add processFunction, that will fire with time intervals for edgeNode

func (*TestContext) CheckMessageInAppLog

func (tc *TestContext) CheckMessageInAppLog(edgeNode *device.Ctx, appID uuid.UUID, message string, callbacks ...Callback) ProcTimerFunc

CheckMessageInAppLog try to find message in logs of app

func (*TestContext) ConfigSync

func (tc *TestContext) ConfigSync(edgeNode *device.Ctx)

ConfigSync send config to controller

func (*TestContext) ExpandOnSuccess

func (tc *TestContext) ExpandOnSuccess(secs int)

ExpandOnSuccess adds additional time to global timeout on every success check

func (*TestContext) GetController

func (tc *TestContext) GetController() controller.Cloud

GetController returns current controller

func (*TestContext) GetEdgeNode

func (tc *TestContext) GetEdgeNode(opts ...GetEdgeNodeOpts) *device.Ctx

GetEdgeNode return node from context

func (*TestContext) GetNodeDescriptions

func (tc *TestContext) GetNodeDescriptions() (nodes []*EdgeNodeDescription)

GetNodeDescriptions returns list of nodes from config

func (*TestContext) GetState

func (tc *TestContext) GetState(edgeNode *device.Ctx) *State

GetState returns State object for edgeNode

func (*TestContext) InitProject

func (tc *TestContext) InitProject(name string)

InitProject init project object with defined name

func (*TestContext) NewEdgeNode

func (tc *TestContext) NewEdgeNode(opts ...EdgeNodeOption) *device.Ctx

NewEdgeNode creates edge node

func (*TestContext) PortForwardCommand

func (tc *TestContext) PortForwardCommand(cmd func(fwdPort uint16) error,
	eveIfName string, targetPort uint16) error

PortForwardCommand forwards network traffic from a command run inside the host and targeted towards EVE VM. The command should be run from inside of `cmd` function, with localhost (or 127.0.0.1) as the destination IP and fwdPort as the destination port.

func (*TestContext) StartTrackingState

func (tc *TestContext) StartTrackingState(onlyNewElements bool)

StartTrackingState init function for State monitoring if onlyNewElements set no use old information from controller

func (*TestContext) UpdateEdgeNode

func (tc *TestContext) UpdateEdgeNode(edgeNode *device.Ctx, opts ...EdgeNodeOption)

UpdateEdgeNode update edge node

func (*TestContext) WaitForProc

func (tc *TestContext) WaitForProc(secs int)

WaitForProc blocking execution until the time elapses or all Procs gone returns error on timeout

func (*TestContext) WaitForProcWithErrorCallback

func (tc *TestContext) WaitForProcWithErrorCallback(secs int, callback Callback)

WaitForProcWithErrorCallback blocking execution until the time elapses or all Procs gone and fires callback in case of timeout

func (*TestContext) WaitForState

func (tc *TestContext) WaitForState(edgeNode *device.Ctx, secs int)

WaitForState wait for State initialization from controller

func (*TestContext) WithCurrentProject

func (tc *TestContext) WithCurrentProject() EdgeNodeOption

WithCurrentProject sets project info

func (*TestContext) WithDeviceModel

func (tc *TestContext) WithDeviceModel(devModel string) EdgeNodeOption

WithDeviceModel sets device model info

func (*TestContext) WithNodeDescription

func (tc *TestContext) WithNodeDescription(nodeDescription *EdgeNodeDescription) EdgeNodeOption

WithNodeDescription sets device info

func (*TestContext) WithTest

func (tc *TestContext) WithTest(t *testing.T) GetEdgeNodeOpts

WithTest assign *testing.T for device

Jump to

Keyboard shortcuts

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