e2e

package
v3.4.0 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2022 License: Apache-2.0 Imports: 37 Imported by: 0

Documentation

Overview

Package e2e contains end-to-end tests.

Index

Constants

View Source
const (
	MsLabelKey   = "e2e.test.ms"
	MsNamePrefix = "e2e-test-ms-"
)
View Source
const (
	LigatoDNSHostNameSuffix = "test.ligato.io"
)

Variables

This section is empty.

Functions

func AgentInstanceName added in v3.3.0

func AgentInstanceName(testCtx *TestCtx) string

AgentInstanceName provides instance name of VPP-Agent that is created by setup by default. This name is used i.e. in ETCD key prefix.

func AgentStartOptionsForContainerRuntime added in v3.3.0

func AgentStartOptionsForContainerRuntime(ctx *TestCtx, options interface{}) (interface{}, error)

AgentStartOptionsForContainerRuntime translates AgentOpt to options for ComponentRuntime.Start(option) method implemented by ContainerRuntime

func CreateFileOnSharedVolume added in v3.3.0

func CreateFileOnSharedVolume(ctx *TestCtx, simpleFileName string, fileContent string) string

CreateFileOnSharedVolume persists fileContent to file in mounted shared volume used for sharing file between containers. It returns the absolute path to the newly created file as seen by the container that creates it.

func DNSServerStartOptionsForContainerRuntime added in v3.3.0

func DNSServerStartOptionsForContainerRuntime(ctx *TestCtx, options interface{}) (interface{}, error)

DNSServerStartOptionsForContainerRuntime translates DNSOpt to options for ComponentRuntime.Start(option) method implemented by ContainerRuntime

func ETCDStartOptionsForContainerRuntime added in v3.3.0

func ETCDStartOptionsForContainerRuntime(ctx *TestCtx, options interface{}) (interface{}, error)

ETCDStartOptionsForContainerRuntime translates EtcdOpt to options for ComponentRuntime.Start(option) method implemented by ContainerRuntime

func MicroserviceStartOptionsForContainerRuntime added in v3.3.0

func MicroserviceStartOptionsForContainerRuntime(ctx *TestCtx, options interface{}) (interface{}, error)

MicroserviceStartOptionsForContainerRuntime translates MicroserviceOpt to options for ComponentRuntime.Start(option) method implemented by ContainerRuntime

func SetupVPPAgent added in v3.3.0

func SetupVPPAgent(testCtx *TestCtx, opts ...AgentOptModifier)

SetupVPPAgent setups VPP-Agent test component according to options (for container runtime it means to start VPP-Agent container)

func WithPluginConfigArg added in v3.3.0

func WithPluginConfigArg(ctx *TestCtx, pluginName string, configContent string) string

WithPluginConfigArg persists configContent for give VPP-Agent plugin (expecting generic plugin config name) and returns argument for VPP-Agent executable to use this plugin configuration file.

Types

type Agent added in v3.3.0

type Agent struct {
	ComponentRuntime
	// contains filtered or unexported fields
}

Agent represents running VPP-Agent test component

func (*Agent) ExecVppctl added in v3.3.0

func (agent *Agent) ExecVppctl(action string, args ...string) (string, error)

ExecVppctl returns output from vppctl for given action and arguments.

func (*Agent) LinuxInterfaceHandler added in v3.3.0

func (agent *Agent) LinuxInterfaceHandler() linuxcalls.NetlinkAPI

func (*Agent) PingFromVPP added in v3.3.0

func (agent *Agent) PingFromVPP(destAddress string) error

PingFromVPP pings <dstAddress> from inside the VPP.

func (*Agent) PingFromVPPAsCallback added in v3.3.0

func (agent *Agent) PingFromVPPAsCallback(destAddress string) func() error

PingFromVPPAsCallback can be used to ping repeatedly inside the assertions "Eventually" and "Consistently" from Omega.

type AgentOpt added in v3.3.0

type AgentOpt struct {
	Runtime               ComponentRuntime
	RuntimeStartOptions   RuntimeStartOptionsFunc
	Name                  string
	Image                 string
	Env                   []string
	UseEtcd               bool
	NoManualInitialResync bool
	ContainerOptsHook     func(*docker.CreateContainerOptions)
}

AgentOpt is options data holder for customizing setup of agent

func DefaultAgentOpt added in v3.3.0

func DefaultAgentOpt(testCtx *TestCtx, agentName string) *AgentOpt

DefaultAgentOpt creates default values for AgentOpt

type AgentOptModifier added in v3.3.0

type AgentOptModifier func(*AgentOpt)

AgentOptModifier is function customizing Agent setup options

func WithAdditionalAgentCmdParams added in v3.3.0

func WithAdditionalAgentCmdParams(params ...string) AgentOptModifier

WithAdditionalAgentCmdParams is test setup option adding additional command line parameters to executing vpp-agent

func WithoutManualInitialAgentResync added in v3.3.0

func WithoutManualInitialAgentResync() AgentOptModifier

WithoutManualInitialAgentResync is test setup option disabling manual agent resync just after agent setup

type CommandExecutor added in v3.3.0

type CommandExecutor interface {
	// ExecCmd executes command inside runtime environment
	ExecCmd(cmd string, args ...string) (stdout, stderr string, err error)
}

CommandExecutor gives test topology components the ability to perform (linux) commands

type ComponentRuntime added in v3.3.0

type ComponentRuntime interface {
	CommandExecutor

	// Start starts instance of test topology component
	Start(options interface{}) error

	// Stop stops instance of test topology component
	Stop(options ...interface{}) error

	// IPAddress provides ip address for connecting to the component
	IPAddress() string

	// PID provides process id of the main process in component
	PID() int
}

ComponentRuntime represents running instance of test topology component. Different implementation can handle test topology components in different environments (docker container, k8s pods, VMs,...)

type ContainerRuntime added in v3.3.0

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

ContainerRuntime represents docker container environments for one component of test topology

func (*ContainerRuntime) Dig added in v3.3.0

func (c *ContainerRuntime) Dig(dnsServer net.IP, queryDomain string, requestedInfo DNSRecordType) ([]net.IP, error)

Dig calls linux tool "dig" that query DNS server for domain name (queryDomain) and return records associated of given type (requestedInfo) associated with the domain name.

func (*ContainerRuntime) ExecCmd added in v3.3.0

func (c *ContainerRuntime) ExecCmd(cmd string, args ...string) (stdout, stderr string, err error)

ExecCmd executes command inside docker container

func (*ContainerRuntime) IPAddress added in v3.3.0

func (c *ContainerRuntime) IPAddress() string

IPAddress provides ip address for connecting to the component

func (*ContainerRuntime) PID added in v3.3.0

func (c *ContainerRuntime) PID() int

PID provides process id of the main process in component

func (*ContainerRuntime) Ping added in v3.3.0

func (c *ContainerRuntime) Ping(destAddress string, opts ...PingOptModifier) error

Ping <destAddress> from inside of the container.

func (*ContainerRuntime) PingAsCallback added in v3.3.0

func (c *ContainerRuntime) PingAsCallback(destAddress string, opts ...PingOptModifier) func() error

PingAsCallback can be used to ping repeatedly inside the assertions "Eventually" and "Consistently" from Omega.

func (*ContainerRuntime) Start added in v3.3.0

func (c *ContainerRuntime) Start(options interface{}) error

Start creates and starts container

func (*ContainerRuntime) Stop added in v3.3.0

func (c *ContainerRuntime) Stop(options ...interface{}) error

Stop stops and removes container

type ContainerStartOptions added in v3.3.0

type ContainerStartOptions struct {
	ContainerOptions *docker.CreateContainerOptions
	Pull             bool
	AttachLogs       bool
}

ContainerStartOptions are options for ComponentRuntime.Start(option) method implemented by ContainerRuntime

type DNSOpt added in v3.3.0

type DNSOpt struct {
	Runtime             ComponentRuntime
	RuntimeStartOptions RuntimeStartOptionsFunc

	// DomainNameSuffix is common suffix of all static dns entries configured in hostsConfig
	DomainNameSuffix string
	// HostsConfig is content of configuration of static DNS entries in hosts file format
	HostsConfig string
}

DNSOpt is options data holder for customizing setup of DNS server

func DefaultDNSOpt added in v3.3.0

func DefaultDNSOpt(testCtx *TestCtx) *DNSOpt

DefaultDNSOpt creates default values for DNSOpt

type DNSOptModifier added in v3.3.0

type DNSOptModifier func(*DNSOpt)

DNSOptModifier is function customizing DNS server setup options

func WithZonedStaticEntries added in v3.3.0

func WithZonedStaticEntries(zoneDomainNameSuffix string, staticEntries ...string) DNSOptModifier

WithZonedStaticEntries is test setup option configuring group of static dns cache entries that belong to the same zone (have the same domain name suffix). The static dns cache entries are lines of config file in linux /etc/hosts file format. Currently supporting only one domain name suffix with static entries (even when DNS server solution supports multiple "zones" that each of them can be configured by one file in hosts file format)

type DNSRecordType added in v3.3.0

type DNSRecordType int

DNSRecordType represent types of records associated with domain name in DNS server

const (
	A DNSRecordType = iota
	AAAA
)

type DNSServer added in v3.3.0

type DNSServer struct {
	ComponentRuntime
	// contains filtered or unexported fields
}

DNSServer is represents running DNS server

func NewDNSServer added in v3.3.0

func NewDNSServer(ctx *TestCtx, options ...DNSOptModifier) (*DNSServer, error)

NewDNSServer creates and starts new DNS server container

type Diger added in v3.3.0

type Diger interface {
	CommandExecutor

	// Dig calls linux tool "dig" that query DNS server for domain name (queryDomain) and return records associated
	// of given type (requestedInfo) associated with the domain name.
	Dig(dnsServer net.IP, queryDomain string, requestedInfo DNSRecordType) ([]net.IP, error)
}

Diger gives test topology components the ability to perform dig command (DNS-query linux tool)

type Etcd added in v3.3.0

type Etcd struct {
	ComponentRuntime
	// contains filtered or unexported fields
}

Etcd is represents running ETCD

func NewEtcd added in v3.3.0

func NewEtcd(ctx *TestCtx, options ...EtcdOptModifier) (*Etcd, error)

NewEtcd creates and starts new ETCD container

func (*Etcd) Get added in v3.3.0

func (ec *Etcd) Get(key string) (string, error)

Get retrieves value for the key from the ETCD that is running in its docker container

func (*Etcd) GetAll added in v3.3.0

func (ec *Etcd) GetAll() (string, error)

GetAll retrieves all key-value pairs from the ETCD that is running in its docker container

func (*Etcd) Put added in v3.3.0

func (ec *Etcd) Put(key string, value string) error

Put inserts key-value pair into the ETCD inside its running docker container

type EtcdOpt added in v3.3.0

type EtcdOpt struct {
	Runtime                       ComponentRuntime
	RuntimeStartOptions           RuntimeStartOptionsFunc
	UseHTTPS                      bool
	UseTestContainerForNetworking bool
}

EtcdOpt is options data holder for customizing setup of ETCD

func DefaultEtcdOpt added in v3.3.0

func DefaultEtcdOpt(ctx *TestCtx) *EtcdOpt

DefaultEtcdOpt creates default values for EtcdOpt

type EtcdOptModifier added in v3.3.0

type EtcdOptModifier func(*EtcdOpt)

EtcdOptModifier is function customizing ETCD setup options

func WithEtcdHTTPsConnection added in v3.3.0

func WithEtcdHTTPsConnection() EtcdOptModifier

WithEtcdHTTPsConnection is ETCD test setup option that will use HTTPS connection to ETCD (by default it is used unsecure HTTP connection)

func WithEtcdTestContainerNetworking added in v3.3.0

func WithEtcdTestContainerNetworking() EtcdOptModifier

WithEtcdTestContainerNetworking is ETCD test setup option that will use main Test container for networking (by default the ETCD has separate networking)

type Microservice added in v3.3.0

type Microservice struct {
	ComponentRuntime
	Pinger
	Diger
	// contains filtered or unexported fields
}

Microservice represents running microservice

type MicroserviceOpt added in v3.3.0

type MicroserviceOpt struct {
	Runtime             ComponentRuntime
	RuntimeStartOptions RuntimeStartOptionsFunc
	Name                string
	ContainerOptsHook   func(*docker.CreateContainerOptions)
}

MicroserviceOpt is options data holder for customizing setup of microservice

func DefaultMicroserviceiOpt added in v3.3.0

func DefaultMicroserviceiOpt(testCtx *TestCtx, msName string) *MicroserviceOpt

DefaultMicroserviceiOpt creates default values for MicroserviceOpt

type MicroserviceOptModifier added in v3.3.0

type MicroserviceOptModifier func(opt *MicroserviceOpt)

MicroserviceOptModifier is function customizing Microservice setup options

func WithMSContainerStartHook added in v3.3.0

func WithMSContainerStartHook(hook func(*docker.CreateContainerOptions)) MicroserviceOptModifier

WithMSContainerStartHook is microservice test setup option that will set the microservice container start hook that will modify the microservice start options.

type PingOpt added in v3.3.0

type PingOpt struct {
	AllowedLoss int    // percentage of allowed loss for success
	SourceIface string // outgoing interface name
	MaxTimeout  int    // timeout in seconds before ping exits
	Count       int    // number of pings
}

PingOpt are options for pinging command.

func DefaultPingOpts added in v3.3.0

func DefaultPingOpts() *PingOpt

DefaultPingOpts creates default values for PingOpt

func NewPingOpts added in v3.3.0

func NewPingOpts(opts ...PingOptModifier) *PingOpt

NewPingOpts create new PingOpt

type PingOptModifier added in v3.3.0

type PingOptModifier func(opts *PingOpt)

PingOptModifier is modifiers of pinging options

func PingWithAllowedLoss added in v3.3.0

func PingWithAllowedLoss(maxLoss int) PingOptModifier

PingWithAllowedLoss sets max allowed packet loss for pinging to be considered successful.

func PingWithSourceInterface added in v3.3.0

func PingWithSourceInterface(iface string) PingOptModifier

PingWithSourceInterface set source interface for ping packets.

type Pinger added in v3.3.0

type Pinger interface {
	CommandExecutor

	// Ping <destAddress> from inside of the container.
	Ping(destAddress string, opts ...PingOptModifier) error

	// PingAsCallback can be used to ping repeatedly inside the assertions "Eventually"
	// and "Consistently" from Omega.
	PingAsCallback(destAddress string, opts ...PingOptModifier) func() error
}

Pinger gives test topology components the ability to perform pinging (pinging from them to other places)

type RuntimeStartOptionsFunc added in v3.3.0

type RuntimeStartOptionsFunc func(ctx *TestCtx, options interface{}) (interface{}, error)

RuntimeStartOptionsFunc is function that provides component runtime start options

type SetupOpt added in v3.3.0

type SetupOpt struct {
	*AgentOpt
	*EtcdOpt
	*DNSOpt
	SetupAgent     bool
	SetupEtcd      bool
	SetupDNSServer bool
	// contains filtered or unexported fields
}

SetupOpt is options data holder for customizing setup of tests

func DefaultSetupOpt added in v3.3.0

func DefaultSetupOpt(testCtx *TestCtx) *SetupOpt

DefaultSetupOpt creates default values for SetupOpt

type SetupOptModifier added in v3.3.0

type SetupOptModifier func(*SetupOpt)

SetupOptModifier is function customizing general setup options

func WithCustomVPPAgent added in v3.3.0

func WithCustomVPPAgent() SetupOptModifier

WithCustomVPPAgent is test setup option using alternative vpp-agent image (customized original vpp-agent)

func WithDNSServer added in v3.3.0

func WithDNSServer(dnsOpts ...DNSOptModifier) SetupOptModifier

WithDNSServer is test setup option enabling setup of container serving as dns server

func WithEtcd added in v3.3.0

func WithEtcd(etcdOpts ...EtcdOptModifier) SetupOptModifier

WithEtcd is test setup option enabling etcd setup

func WithoutVPPAgent added in v3.3.0

func WithoutVPPAgent() SetupOptModifier

WithoutVPPAgent is test setup option disabling vpp-agent setup

type TestCtx

type TestCtx struct {
	*gomega.WithT

	Agent     *Agent // the default agent (first agent in multi-agent test scenario)
	Etcd      *Etcd
	DNSServer *DNSServer

	Logger *log.Logger
	// contains filtered or unexported fields
}

TestCtx represents data context fur currently running test

func NewTest added in v3.3.0

func NewTest(t *testing.T) *TestCtx

NewTest creates new TestCtx for given runnin test

func Setup

func Setup(t *testing.T, options ...SetupOptModifier) *TestCtx

Setup setups the testing environment according to options

func (*TestCtx) AgentInSync

func (test *TestCtx) AgentInSync() bool

AgentInSync checks if the agent NB config and the SB state (VPP+Linux) are in-sync.

func (*TestCtx) AlreadyRunningMicroservice added in v3.3.0

func (test *TestCtx) AlreadyRunningMicroservice(msName string) *Microservice

AlreadyRunningMicroservice retrieves already running microservice by its name.

func (*TestCtx) ExecCmd

func (test *TestCtx) ExecCmd(cmd string, args ...string) (stdout, stderr string, err error)

ExecCmd executes command in agent and returns stdout, stderr as strings and error. Deprecated: use ctx.Agent.ExecCmd(...) instead

func (*TestCtx) ExecVppctl

func (test *TestCtx) ExecVppctl(action string, args ...string) (string, error)

ExecVppctl returns output from vppctl for given action and arguments. Deprecated: use ctx.Agent.ExecVppctl(...) instead

func (*TestCtx) GRPCConn added in v3.3.0

func (test *TestCtx) GRPCConn() *grpc.ClientConn

GRPCConn provides GRPC client connection for communication with default VPP-Agent test component

func (*TestCtx) GenericClient

func (test *TestCtx) GenericClient() client.GenericClient

GenericClient provides generic client for communication with default VPP-Agent test component

func (*TestCtx) GetDerivedValueState added in v3.3.0

func (test *TestCtx) GetDerivedValueState(baseValue proto.Message, derivedKey string) kvscheduler.ValueState

func (*TestCtx) GetDerivedValueStateClb added in v3.3.0

func (test *TestCtx) GetDerivedValueStateClb(baseValue proto.Message, derivedKey string) func() kvscheduler.ValueState

GetDerivedValueStateClb can be used to repeatedly check derived value state inside the assertions "Eventually" and "Consistently" from Omega.

func (*TestCtx) GetValue added in v3.3.0

func (test *TestCtx) GetValue(value proto.Message, view kvs.View) proto.Message

GetValue retrieves value(s) as seen by the given view

func (*TestCtx) GetValueMetadata added in v3.3.0

func (test *TestCtx) GetValueMetadata(value proto.Message, view kvs.View) (metadata interface{})

GetValueMetadata retrieves metadata associated with the given value.

func (*TestCtx) GetValueState

func (test *TestCtx) GetValueState(value proto.Message) kvscheduler.ValueState

func (*TestCtx) GetValueStateByKey

func (test *TestCtx) GetValueStateByKey(key string) kvscheduler.ValueState

func (*TestCtx) GetValueStateClb

func (test *TestCtx) GetValueStateClb(value proto.Message) func() kvscheduler.ValueState

GetValueStateClb can be used to repeatedly check value state inside the assertions "Eventually" and "Consistently" from Omega.

func (*TestCtx) NumValues added in v3.3.0

func (test *TestCtx) NumValues(value proto.Message, view kvs.View) int

NumValues returns number of values found under the given model

func (*TestCtx) PingFromMs

func (test *TestCtx) PingFromMs(msName, dstAddress string, opts ...PingOptModifier) error

PingFromMs pings <dstAddress> from the microservice <msName> Deprecated: use ctx.AlreadyRunningMicroservice(msName).Ping(dstAddress, opts...) instead (or ms := ctx.StartMicroservice; ms.Ping(dstAddress, opts...))

func (*TestCtx) PingFromMsClb

func (test *TestCtx) PingFromMsClb(msName, dstAddress string, opts ...PingOptModifier) func() error

PingFromMsClb can be used to ping repeatedly inside the assertions "Eventually" and "Consistently" from Omega. Deprecated: use ctx.AlreadyRunningMicroservice(msName).PingAsCallback(dstAddress, opts...) instead (or ms := ctx.StartMicroservice; ms.PingAsCallback(dstAddress, opts...))

func (*TestCtx) PingFromVPP

func (test *TestCtx) PingFromVPP(destAddress string) error

PingFromVPP pings <dstAddress> from inside the VPP. Deprecated: use ctx.Agent.PingFromVPP(destAddress) instead

func (*TestCtx) PingFromVPPClb

func (test *TestCtx) PingFromVPPClb(destAddress string) func() error

PingFromVPPClb can be used to ping repeatedly inside the assertions "Eventually" and "Consistently" from Omega. Deprecated: use ctx.Agent.PingFromVPPAsCallback(destAddress) instead

func (*TestCtx) StartAgent added in v3.3.0

func (test *TestCtx) StartAgent(name string, opts ...AgentOptModifier) *Agent

StartAgent starts new VPP-Agent with given name and according to options

func (*TestCtx) StartMicroservice

func (test *TestCtx) StartMicroservice(name string, options ...MicroserviceOptModifier) *Microservice

StartMicroservice starts microservice according to given options

func (*TestCtx) StopAgent added in v3.3.0

func (test *TestCtx) StopAgent(name string)

StopAgent stop VPP-Agent with given name

func (*TestCtx) StopMicroservice

func (test *TestCtx) StopMicroservice(name string)

StopMicroservice stops microservice with given name

func (*TestCtx) Teardown

func (test *TestCtx) Teardown()

Teardown perform test cleanup

func (*TestCtx) TestConnection

func (test *TestCtx) TestConnection(
	fromMs, toMs, toAddr, listenAddr string,
	toPort, listenPort uint16, udp bool,
	traceVPPNodes ...string,
) error

func (*TestCtx) VppRelease

func (test *TestCtx) VppRelease() string

VppRelease provides VPP version of VPP in default VPP-Agent test component

Jump to

Keyboard shortcuts

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