helpers

package
v1.6.3 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2019 License: Apache-2.0 Imports: 47 Imported by: 0

Documentation

Index

Constants

View Source
const (

	//CiliumPath is the path where cilium test code is located.
	CiliumPath = "/src/github.com/cilium/cilium/test"

	// K8sManifestBase tells ginkgo suite where to look for manifests
	K8sManifestBase = "k8sT/manifests"

	// VM / Test suite constants.
	K8s     = "k8s"
	K8s1    = "k8s1"
	K8s1Ip  = "192.168.36.11"
	K8s2    = "k8s2"
	K8s2Ip  = "192.168.36.12"
	Runtime = "runtime"

	Enabled  = "enabled"
	Disabled = "disabled"
	Total    = "total"
	Public   = "public"
	Private  = "private"
	Name     = "Name"

	// PolicyEnforcement represents the PolicyEnforcement configuration option
	// for the Cilium agent.
	PolicyEnforcement = "PolicyEnforcement"

	// PolicyEnforcementDefault represents the default PolicyEnforcement mode
	// for Cilium.
	PolicyEnforcementDefault = "default"

	// PolicyEnforcementAlways represents the PolicyEnforcement mode
	// for Cilium in which traffic is denied by default even when no policy
	// is imported.
	PolicyEnforcementAlways = "always"

	// PolicyEnforcementNever represents the PolicyEnforcement mode
	// for Cilium in which traffic is always allowed even if there is a policy
	// selecting endpoints.
	PolicyEnforcementNever = "never"

	// CiliumDockerNetwork is the name of the Docker network which Cilium manages.
	CiliumDockerNetwork = "cilium-net"

	// HostDockerNetwork is the name of the host network driver.
	HostDockerNetwork = "host"

	// Names of commonly used containers in tests.
	Httpd1 = "httpd1"
	Httpd2 = "httpd2"
	Httpd3 = "httpd3"
	App1   = "app1"
	App2   = "app2"
	App3   = "app3"
	Client = "client"
	Server = "server"
	Host   = "host"
	// Container lifecycle actions.
	Create = "create"
	Delete = "delete"

	// IP Address families.
	IPv4 = "IPv4"
	IPv6 = "IPv6"

	// LogPerm is the permission for files that are created by this framework
	// that contain logs, outputs of Cilium CLI commands, etc.
	LogPerm = os.FileMode(0666)

	OptionConntrackAccounting = "ConntrackAccounting"
	OptionConntrackLocal      = "ConntrackLocal"
	OptionConntrack           = "Conntrack"
	OptionDebug               = "Debug"
	OptionDropNotify          = "DropNotification"
	OptionTraceNotify         = "TraceNotification"
	OptionNAT46               = "NAT46"
	OptionIngressPolicy       = "IngressPolicy"
	OptionEgressPolicy        = "EgressPolicy"
	OptionIngress             = "ingress"
	OptionEgress              = "egress"
	OptionNone                = "none"
	OptionDisabled            = "Disabled"
	OptionEnabled             = "Enabled"

	StateTerminating = "Terminating"
	StateRunning     = "Running"

	PingCount = 5

	// CurlConnectTimeout is the timeout for the connect() call that curl
	// invokes
	CurlConnectTimeout = 5

	// CurlMaxTimeout is the hard timeout. It starts when curl is invoked
	// and interrupts curl regardless of whether curl is currently
	// connecting or transferring data. CurlMaxTimeout should be at least 5
	// seconds longer than CurlConnectTimeout to provide some time to
	// actually transfer data.
	CurlMaxTimeout = 8

	DefaultNamespace    = "default"
	KubeSystemNamespace = "kube-system"

	TestResultsPath = "test_results/"
	RunDir          = "/var/run/cilium"
	LibDir          = "/var/lib/cilium"

	DaemonName             = "cilium"
	CiliumBugtool          = "cilium-bugtool"
	CiliumDockerDaemonName = "cilium-docker"
	AgentDaemon            = "cilium-agent"

	GeneratedHTMLManifest   = "html.yaml"
	GeneratedServerManifest = "server.yaml"
	GeneratedClientManifest = "client.yaml"

	KubectlCreate = ResourceLifeCycleAction("create")
	KubectlDelete = ResourceLifeCycleAction("delete")
	KubectlApply  = ResourceLifeCycleAction("apply")

	KubectlPolicyNameLabel      = k8sConst.PolicyLabelName
	KubectlPolicyNameSpaceLabel = k8sConst.PolicyLabelNamespace

	CiliumStableVersion      = "v1.5"
	CiliumStableImageVersion = "cilium/cilium:" + CiliumStableVersion
	CiliumDeveloperImage     = "k8s1:5000/cilium/cilium-dev:latest"

	MonitorLogFileName = "monitor.log"

	// CiliumTestLog is the filename where the cilium logs that happens during
	// the test are saved.
	CiliumTestLog = "cilium-test.log"

	// FakeIPv4WorldAddress is an IP which is used in some datapath tests
	// for simulating external IPv4 connectivity.
	FakeIPv4WorldAddress = "192.168.254.254"

	// FakeIPv6WorldAddress is an IP which is used in some datapath tests
	// for simulating external IPv6 connectivity.
	FakeIPv6WorldAddress = "fdff::ff"

	// DockerBridgeIP is the IP on the docker0 bridge
	DockerBridgeIP = "172.17.0.1"

	NACKreceived  = "NACK received for version" // from https://github.com/cilium/cilium/issues/4003
	RunInitFailed = "JoinEP: "                  // from https://github.com/cilium/cilium/pull/5052

	// HelmTemplate is the location of the Helm templates to install Cilium
	HelmTemplate = "go/src/github.com/cilium/cilium/install/kubernetes/cilium"
)
View Source
const (
	// KubectlCmd Kubernetes controller command
	KubectlCmd = "kubectl"

	// DNSHelperTimeout is a predefined timeout value for K8s DNS commands. It
	// must be larger than 5 minutes because kubedns has a hardcoded resync
	// period of 5 minutes. We have experienced test failures because kubedns
	// needed this time to recover from a connection problem to kube-apiserver.
	// The kubedns resyncPeriod is defined at
	// https://github.com/kubernetes/dns/blob/80fdd88276adba36a87c4f424b66fdf37cd7c9a8/pkg/dns/dns.go#L53
	DNSHelperTimeout = 7 * time.Minute

	// EnableMicroscope is true when microscope should be enabled
	EnableMicroscope = false

	// CIIntegrationFlannel contains the constant to be used when flannel is
	// used in the CI.
	CIIntegrationFlannel = "flannel"
)
View Source
const (
	// TCP_RR represents a netperf test for TCP Request/Response performance.
	// For more information, consult : http://www.cs.kent.edu/~farrell/dist/ref/Netperf.html
	TCP_RR = PerfTest("TCP_RR")

	// UDP_RR represents a netperf test for UDP Request/Response performance.
	// For more information, consult : http://www.cs.kent.edu/~farrell/dist/ref/Netperf.html
	UDP_RR = PerfTest("UDP_RR")
)
View Source
const CiliumConfigMapPatch = "cilium-cm-patch.yaml"

CiliumConfigMapPatch is the default Cilium ConfigMap patch to be used in all tests.

View Source
const CiliumConfigMapPatchKvstoreAllocator = "cilium-cm-kvstore-allocator-patch.yaml"

CiliumConfigMapPatchKvstoreAllocator is equivalent to CiliumConfigMapPatch except it uses the kvstore-based allocator instead of the CRD-based allocator.

View Source
const CiliumDefaultDSPatch = "cilium-ds-patch.yaml"

CiliumDefaultDSPatch is the default Cilium DaemonSet patch to be used in all tests.

View Source
const (
	// MaxRetries is the number of times that a loop should iterate until a
	// specified condition is not met
	MaxRetries = 30
)
View Source
const (
	// ReservedIdentityHealth is equivalent to pkg/identity.ReservedIdentityHealth
	ReservedIdentityHealth = 4
)

Re-definitions of stable constants in the API. The re-definition is on purpose to validate these values in the API. They may never change

Variables

View Source
var (
	// HelperTimeout is a predefined timeout value for commands.
	HelperTimeout = 4 * time.Minute

	// ShortCommandTimeout is a timeout for commands which should not take a
	// long time to execute.
	ShortCommandTimeout = 10 * time.Second

	// MidCommandTimeout is a timeout for commands which may take a bit longer
	// than ShortCommandTimeout, but less time than HelperTimeout to execute.
	MidCommandTimeout = 30 * time.Second

	// CiliumStartTimeout is a predefined timeout value for Cilium startup.
	CiliumStartTimeout = 100 * time.Second

	// CiliumBasePath is the absolute path to the cilium source repository
	// in the guest VMs
	CiliumBasePath = "/home/vagrant/go/src/github.com/cilium/cilium"

	// BasePath is the path in the Vagrant VMs to which the test directory
	// is mounted
	BasePath = path.Join(CiliumBasePath, "test")

	// CheckLogs newtes a new buffer where all the warnings and checks that
	// happens during the test are saved. This buffer will be printed in the
	// test output inside <checks> labels.
	CheckLogs = ginkgoext.NewWriter(new(bytes.Buffer))
)
View Source
var (
	CiliumV1_5 = versioncheck.MustCompile(">=v1.4.90,<v1.6")
	CiliumV1_6 = versioncheck.MustCompile(">=v1.5.90,<v1.7")
)
View Source
var NightlyStableUpgradesFrom = []string{"v1.3"}

NightlyStableUpgradesFrom the cilium images to update from in Nightly test.

View Source
var (
	//SSHMetaLogs is a buffer where all commands sent over ssh are saved.
	SSHMetaLogs = ginkgoext.NewWriter(new(Buffer))
)
View Source
var UserDefinedScope string

UserDefinedScope in case that the test scope is defined by the user instead of the focus string.

Functions

func CMDSuccess

func CMDSuccess() types.GomegaMatcher

CMDSuccess return a new Matcher that expects a CmdRes is a successful run command.

func CanRunK8sVersion

func CanRunK8sVersion(ciliumVersion, k8sVersionStr string) (bool, error)

CanRunK8sVersion returns true if the givel ciliumVersion can run in the given Kubernetes version. If any version is unparsable, an error is returned.

func CountValues

func CountValues(key string, data []string) (int, int)

CountValues returns the count of the occurrences of key in data, as well as the length of data.

func CreateLogFile

func CreateLogFile(filename string, data []byte) error

CreateLogFile creates the ReportDirectory if it is not present, writes the given data to the given filename.

func CreateReportDirectory

func CreateReportDirectory() (string, error)

CreateReportDirectory creates and returns the directory path to export all report commands that need to be run in the case that a test has failed. If the directory cannot be created it'll return an error

func CreateVM

func CreateVM(scope string) error

CreateVM creates a new vagrant server.Receives a scope which indicates the target server that needs to be created. In case of any error on vagrant [provision|up|ssh-config] error will be returned.

func CurlFail

func CurlFail(endpoint string, optionalValues ...interface{}) string

CurlFail returns the string representing the curl command with `-s` and `--fail` options enabled to curl the specified endpoint. It takes a variadic optinalValues argument. This is passed on to fmt.Sprintf() and uses into the curl message

func CurlWithHTTPCode

func CurlWithHTTPCode(endpoint string, optionalValues ...interface{}) string

CurlWithHTTPCode retunrs the string representation of the curl command which only outputs the HTTP code returned by its execution against the specified endpoint. It takes a variadic optinalValues argument. This is passed on to fmt.Sprintf() and uses into the curl message

func DNSDeployment

func DNSDeployment() string

DNSDeployment returns the manifest to install dns engine on the server.

func DestroyVM

func DestroyVM(scope string) error

DestroyVM destroys all running Vagrant VMs in the provided scope. It returns an error if deletion of either the VMs fails

func DoesNotRunOnNetNext added in v1.6.1

func DoesNotRunOnNetNext() bool

DoesNotRunOnNetNext is the inverse function of RunsOnNetNext.

func Fail

func Fail(description string, callerSkip ...int)

Fail is a Ginkgo failure handler which raises a SIGSTOP for the test process when there is a failure, so that developers can debug the live environment. It is only triggered if the developer provides a commandline flag.

func GenerateManifestForEndpoints

func GenerateManifestForEndpoints(endpointCount int, manifestPath string) (string, int, error)

GenerateManifestForEndpoints generates k8s manifests that will create endpointCount Cilium endpoints when applied. 1/3 of endpoints are servers, the rest are clients. returns lastServer index Saves generated manifest to manifestPath, also returns it via string

func GenerateNamespaceForTest added in v1.6.0

func GenerateNamespaceForTest() string

GenerateNamespaceForTest generates a namespace based off of the current test which is running.

func GetAppPods

func GetAppPods(apps []string, namespace string, kubectl *Kubectl, appFmt string) map[string]string

GetAppPods fetches app pod names for a namespace. For Http based tests, we identify pods with format id=<pod_name>, while for Kafka based tests, we identify pods with the format app=<pod_name>.

func GetCurrentIntegration

func GetCurrentIntegration() string

GetCurrentIntegration returns CI integration set up to run against Cilium.

func GetCurrentK8SEnv

func GetCurrentK8SEnv() string

GetCurrentK8SEnv returns the value of K8S_VERSION from the OS environment.

func GetFilePath

func GetFilePath(filename string) string

GetFilePath returns the absolute path of the provided filename

func GetScope

func GetScope() (string, error)

GetScope returns the scope for the currently running test.

func GetScopeWithVersion

func GetScopeWithVersion() string

GetScopeWithVersion returns the scope of the running test. If the scope is k8s, then it returns k8s scope along with the version of k8s that is running.

func GetVagrantSSHMetadata

func GetVagrantSSHMetadata(vmName string) ([]byte, error)

GetVagrantSSHMetadata returns a string containing the output of `vagrant ssh-config` for the provided Vagrant of name vmName. Returns an error if `vagrant ssh-config` fails to execute.

func HoldEnvironment

func HoldEnvironment(description ...string)

HoldEnvironment prints the current test status, then pauses the test execution. Developers who are writing tests may wish to invoke this function directly from test code to assist troubleshooting and test development.

func IsRunningOnJenkins

func IsRunningOnJenkins() bool

IsRunningOnJenkins detects if the currently running Ginkgo application is most likely running in a Jenkins environment. Returns true if certain environment variables that are present in Jenkins jobs are set, false otherwise.

func K8s1VMName

func K8s1VMName() string

K8s1VMName is the name of the Kubernetes master node when running K8s tests.

func K8s2VMName

func K8s2VMName() string

K8s2VMName is the name of the Kubernetes worker node when running K8s tests.

func MakeUID

func MakeUID() string

MakeUID returns a randomly generated string.

func ManifestGet

func ManifestGet(manifestFilename string) string

ManifestGet returns the full path of the given manifest corresponding to the Kubernetes version being tested, if such a manifest exists, if not it returns the global manifest file. The paths are checked in order: 1- base_path/integration/filename 2- base_path/k8s_version/integration/filename 3- base_path/k8s_version/filename 4- base_path/filename

func Netcat

func Netcat(endpoint string, optionalValues ...interface{}) string

Netcat returns the string representing the netcat command to the specified endpoint. It takes a variadic optionalValues arguments, This is passed to fmt.Sprintf uses in the netcat message

func Netperf

func Netperf(endpoint string, perfTest PerfTest) string

Netperf returns the string representing the netperf command to use when testing connectivity between endpoints.

func Ping

func Ping(endpoint string) string

Ping returns the string representing the ping command to ping the specified endpoint.

func Ping6

func Ping6(endpoint string) string

Ping6 returns the string representing the ping6 command to ping6 the specified endpoint.

func RenderTemplateToFile

func RenderTemplateToFile(filename string, tmplt string, perm os.FileMode) error

RenderTemplateToFile renders a text/template string into a target filename with specific persmisions. Returns eturn an error if the template cannot be validated or the file cannot be created.

func RunsOnNetNext

func RunsOnNetNext() bool

RunsOnNetNext checks whether a test case is running on the net next machine which means running on the latest (probably) unreleased kernel

func SSHAgent

func SSHAgent() ssh.AuthMethod

SSHAgent returns the ssh.Authmethod using the Public keys. Returns nil if a connection to SSH_AUTH_SHOCK does not succeed.

func Sleep

func Sleep(delay time.Duration)

Sleep sleeps for the specified duration in seconds

func Status

func Status(key string) map[string]string

Status returns a mapping of Vagrant VM name to its status

func WithContext

func WithContext(ctx context.Context, f func(ctx context.Context) (bool, error), freq time.Duration) error

WithContext executes body with the given frequency. The function f is executed until bool returns true or the given context signalizes Done. `f` should stop if context is canceled.

func WithTimeout

func WithTimeout(body func() bool, msg string, config *TimeoutConfig) error

WithTimeout executes body using the time interval specified in config until the timeout in config is reached. Returns an error if the timeout is exceeded for body to execute successfully.

func WriteOrAppendToFile

func WriteOrAppendToFile(filename string, data []byte, perm os.FileMode) error

WriteOrAppendToFile writes data to a file named by filename. If the file does not exist, WriteFile creates it with permissions perm; otherwise WriteFile appends the data to the file

Types

type BeSuccesfulMatcher

type BeSuccesfulMatcher struct{}

BeSuccesfulMatcher a new Ginkgo matcher for CmdRes struct

func (*BeSuccesfulMatcher) FailureMessage

func (matcher *BeSuccesfulMatcher) FailureMessage(actual interface{}) (message string)

FailureMessage it returns a pretty printed error message in the case of the command was not successful.

func (*BeSuccesfulMatcher) Match

func (matcher *BeSuccesfulMatcher) Match(actual interface{}) (success bool, err error)

Match validates that the given interface will be a `*CmdRes` struct and it was successful. In case of not a valid CmdRes will return an error. If the command was not successful it returns false.

func (*BeSuccesfulMatcher) NegatedFailureMessage

func (matcher *BeSuccesfulMatcher) NegatedFailureMessage(actual interface{}) (message string)

NegatedFailureMessage returns a pretty printed error message in case of the command is tested with a negative

type Buffer

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

A Buffer is a variable-sized buffer of bytes with Read and Write methods. The zero value for Buffer is an empty buffer ready to use.

func (*Buffer) Bytes

func (buf *Buffer) Bytes() []byte

Bytes returns a slice of length b.Len() holding the unread portion of the buffer. The slice is valid for use only until the next buffer modification (that is, only until the next call to a method like Read, Write, Reset, or Truncate). The slice aliases the buffer content at least until the next buffer modification, so immediate changes to the slice will affect the result of future reads.

func (*Buffer) Len

func (buf *Buffer) Len() int

Len returns the number of bytes of the unread portion of the buffer; b.Len() == len(b.Bytes()).

func (*Buffer) Reset

func (buf *Buffer) Reset()

Reset resets the buffer to be empty, but it retains the underlying storage for use by future writes. Reset is the same as Truncate(0).

func (*Buffer) String

func (buf *Buffer) String() string

String returns the contents of the unread portion of the buffer as a string. If the Buffer is a nil pointer, it returns "<nil>".

To build strings more efficiently, see the strings.Builder type.

func (*Buffer) Write

func (buf *Buffer) Write(p []byte) (n int, err error)

Write appends the contents of p to the buffer, growing the buffer as needed. The return value n is the length of p; err is always nil. If the buffer becomes too large, Write will panic with ErrTooLarge.

type CmdRes

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

CmdRes contains a variety of data which results from running a command.

func (*CmdRes) ByLines

func (res *CmdRes) ByLines() []string

ByLines returns res's stdout split by the newline character and, if the stdout contains `\r\n`, it will be split by carriage return and new line characters.

func (*CmdRes) CombineOutput

func (res *CmdRes) CombineOutput() *bytes.Buffer

CombineOutput returns the combined output of stdout and stderr for res.

func (*CmdRes) CountLines

func (res *CmdRes) CountLines() int

CountLines return the number of lines in the stdout of res.

func (*CmdRes) ExpectContains

func (res *CmdRes) ExpectContains(data string, optionalDescription ...interface{}) bool

ExpectContains asserts a string into the stdout of the response of executed command. It accepts an optional parameter that can be used to annotate failure messages.

func (*CmdRes) ExpectDoesNotContain

func (res *CmdRes) ExpectDoesNotContain(data string, optionalDescription ...interface{}) bool

ExpectDoesNotContain asserts that a string is not contained in the stdout of the executed command. It accepts an optional parameter that can be used to annotate failure messages.

func (*CmdRes) ExpectDoesNotMatchRegexp

func (res *CmdRes) ExpectDoesNotMatchRegexp(regexp string, optionalDescription ...interface{}) bool

ExpectDoesNotMatchRegexp asserts that the stdout of the executed command doesn't match the regexp. It accepts an optional parameter that can be used to annotate failure messages.

func (*CmdRes) ExpectEqual

func (res *CmdRes) ExpectEqual(expected string, optionalDescription ...interface{}) bool

ExpectEqual asserts whether cmdRes.Output().String() and expected are equal. It accepts an optional parameter that can be used to annotate failure messages.

func (*CmdRes) ExpectFail

func (res *CmdRes) ExpectFail(optionalDescription ...interface{}) bool

ExpectFail asserts whether res failed to execute. It accepts an optional parameter that can be used to annotate failure messages.

func (*CmdRes) ExpectSuccess

func (res *CmdRes) ExpectSuccess(optionalDescription ...interface{}) bool

ExpectSuccess asserts whether res executed successfully. It accepts an optional parameter that can be used to annotate failure messages.

func (*CmdRes) Filter

func (res *CmdRes) Filter(filter string) (*FilterBuffer, error)

Filter returns the contents of res's stdout filtered using the provided JSONPath filter in a buffer. Returns an error if the unmarshalling of the contents of res's stdout fails.

func (*CmdRes) FindResults

func (res *CmdRes) FindResults(filter string) ([]reflect.Value, error)

FindResults filters res's stdout using the provided JSONPath filter. It returns an array of the values that match the filter, and an error if the unmarshalling of the stdout of res fails. TODO - what exactly is the need for this vs. Filter function below?

func (*CmdRes) GetCmd

func (res *CmdRes) GetCmd() string

GetCmd returns res's cmd.

func (*CmdRes) GetDebugMessage

func (res *CmdRes) GetDebugMessage() string

GetDebugMessage returns executed command and its output

func (*CmdRes) GetErr

func (res *CmdRes) GetErr(context string) error

GetErr returns error created from program output if command is not successful

func (*CmdRes) GetError added in v1.5.5

func (res *CmdRes) GetError() error

GetError returns the error for this CmdRes.

func (*CmdRes) GetExitCode

func (res *CmdRes) GetExitCode() int

GetExitCode returns res's exitcode.

func (*CmdRes) GetStdErr

func (res *CmdRes) GetStdErr() string

GetStdErr returns the contents of the stderr buffer of res as a string.

func (*CmdRes) GetStdOut

func (res *CmdRes) GetStdOut() string

GetStdOut returns the contents of the stdout buffer of res as a string.

func (*CmdRes) IntOutput

func (res *CmdRes) IntOutput() (int, error)

IntOutput returns the stdout of res as an integer

func (*CmdRes) KVOutput

func (res *CmdRes) KVOutput() map[string]string

KVOutput returns a map of the stdout of res split based on the separator '='. For example, the following strings would be split as follows:

a=1
b=2
c=3

func (*CmdRes) Output

func (res *CmdRes) Output() *Buffer

Output returns res's stdout.

func (*CmdRes) OutputPrettyPrint

func (res *CmdRes) OutputPrettyPrint() string

OutputPrettyPrint returns a string with the ExitCode, stdout and stderr in a pretty format.

func (*CmdRes) Reset

func (res *CmdRes) Reset()

Reset resets res's stdout buffer to be empty.

func (*CmdRes) SendToLog

func (res *CmdRes) SendToLog(quietMode bool)

SendToLog writes to `TestLogWriter` the debug message for the running command, if the quietMode argument is true will print only the command and the exitcode.

func (*CmdRes) SingleOut

func (res *CmdRes) SingleOut() string

SingleOut returns res's stdout as a string without any newline characters

func (*CmdRes) Unmarshal

func (res *CmdRes) Unmarshal(data interface{}) error

Unmarshal unmarshalls res's stdout into data. It assumes that the stdout of res is in JSON format. Returns an error if the unmarshalling fails.

func (*CmdRes) WaitUntilFinish

func (res *CmdRes) WaitUntilFinish()

WaitUntilFinish waits until the command context completes correctly

func (*CmdRes) WaitUntilMatch

func (res *CmdRes) WaitUntilMatch(substr string) error

WaitUntilMatch waits until the given substring is present in the `CmdRes.stdout` If the timeout is reached it will return an error.

func (*CmdRes) WaitUntilMatchRegexp

func (res *CmdRes) WaitUntilMatchRegexp(expr string) error

WaitUntilMatchRegexp waits until the `CmdRes.stdout` matches the given regexp. If the timeout is reached it will return an error.

func (*CmdRes) WasSuccessful

func (res *CmdRes) WasSuccessful() bool

WasSuccessful returns true if cmd completed successfully.

type ExecOptions

type ExecOptions struct {
	SkipLog bool
}

ExecOptions options to execute Exec and ExecWithContext

type FilterBuffer

type FilterBuffer struct {
	*bytes.Buffer
}

FilterBuffer structs that extends buffer methods

func (*FilterBuffer) ByLines

func (buf *FilterBuffer) ByLines() []string

ByLines returns buf string plit by the newline characters

func (*FilterBuffer) KVOutput

func (buf *FilterBuffer) KVOutput() map[string]string

KVOutput returns a map of the buff string split based on the separator '='. For example, the following strings would be split as follows:

a=1
b=2
c=3

type Kubectl

type Kubectl struct {
	*SSHMeta
	// contains filtered or unexported fields
}

Kubectl is a wrapper around an SSHMeta. It is used to run Kubernetes-specific commands on the node which is accessible via the SSH metadata stored in its SSHMeta.

func CreateKubectl

func CreateKubectl(vmName string, log *logrus.Entry) *Kubectl

CreateKubectl initializes a Kubectl helper with the provided vmName and log It marks the test as Fail if cannot get the ssh meta information or cannot execute a `ls` on the virtual machine.

func (*Kubectl) Action

func (kub *Kubectl) Action(action ResourceLifeCycleAction, filePath string, namespace ...string) *CmdRes

Action performs the specified ResourceLifeCycleAction on the Kubernetes manifest located at path filepath in the given namespace

func (*Kubectl) Apply

func (kub *Kubectl) Apply(filePath string, namespace ...string) *CmdRes

Apply applies the Kubernetes manifest located at path filepath.

func (*Kubectl) BackgroundReport

func (kub *Kubectl) BackgroundReport(commands ...string) (context.CancelFunc, error)

BackgroundReport dumps the result of the given commands on cilium pods each five seconds.

func (*Kubectl) CepGet

func (kub *Kubectl) CepGet(namespace string, pod string) *cnpv2.EndpointStatus

CepGet returns the endpoint model for the given pod name in the specified namespaces. If the pod is not present it returns nil

func (*Kubectl) CiliumCheckReport

func (kub *Kubectl) CiliumCheckReport(ctx context.Context)

CiliumCheckReport prints a few checks on the Junit output to provide more context to users. The list of checks that prints are the following: - Number of Kubernetes and Cilium policies installed. - Policy enforcement status by endpoint. - Controller, health, kvstore status.

func (*Kubectl) CiliumEndpointWaitReady

func (kub *Kubectl) CiliumEndpointWaitReady() error

CiliumEndpointWaitReady waits until all endpoints managed by all Cilium pod are ready. Returns an error if the Cilium pods cannot be retrieved via Kubernetes, or endpoints are not ready after a specified timeout

func (*Kubectl) CiliumEndpointsList

func (kub *Kubectl) CiliumEndpointsList(ctx context.Context, pod string) *CmdRes

CiliumEndpointsList returns the result of `cilium endpoint list` from the specified pod.

func (*Kubectl) CiliumEndpointsStatus

func (kub *Kubectl) CiliumEndpointsStatus(pod string) map[string]string

CiliumEndpointsStatus returns a mapping of a pod name to it is corresponding endpoint's status

func (*Kubectl) CiliumExec

func (kub *Kubectl) CiliumExec(pod string, cmd string) *CmdRes

CiliumExec runs cmd in the specified Cilium pod. Deprecated: use CiliumExecContext instead

func (*Kubectl) CiliumExecContext

func (kub *Kubectl) CiliumExecContext(ctx context.Context, pod string, cmd string) *CmdRes

CiliumExecContext runs cmd in the specified Cilium pod with the given context.

func (*Kubectl) CiliumExecUntilMatch

func (kub *Kubectl) CiliumExecUntilMatch(pod, cmd, substr string) error

CiliumExecUntilMatch executes the specified command repeatedly for the specified Cilium pod until the given substring is present in stdout. If the timeout is reached it will return an error.

func (*Kubectl) CiliumInstall

func (kub *Kubectl) CiliumInstall(options []string) error

CiliumInstall installs Cilium with the provided Helm options.

func (*Kubectl) CiliumInstallVersion

func (kub *Kubectl) CiliumInstallVersion(dsPatchName, cmPatchName, versionTag string) error

CiliumInstallVersion installs all Cilium descriptors into kubernetes for a given Cilium Version tag. dsPatchName corresponds to the DaemonSet patch that will be applied to the original Cilium DaemonSet descriptor of that given Cilium Version tag. cmPatchName corresponds to the ConfigMap patch that will be applied to the original Cilium ConfigMap descriptor of that given Cilium Version tag. Returns an error if any patch or if any original descriptors files were not found.

func (*Kubectl) CiliumIsPolicyLoaded

func (kub *Kubectl) CiliumIsPolicyLoaded(pod string, policyCmd string) bool

CiliumIsPolicyLoaded returns true if the policy is loaded in the given cilium Pod. it returns false in case that the policy is not in place

func (*Kubectl) CiliumNodesWait

func (kub *Kubectl) CiliumNodesWait() (bool, error)

CiliumNodesWait waits until all nodes in the Kubernetes cluster are annotated with Cilium annotations. Its runtime is bounded by a maximum of `HelperTimeout`. When a node is annotated with said annotations, it indicates that the tunnels in the nodes are set up and that cross-node traffic can be tested. Returns an error if the timeout is exceeded for waiting for the nodes to be annotated.

func (*Kubectl) CiliumPolicyAction

func (kub *Kubectl) CiliumPolicyAction(namespace, filepath string, action ResourceLifeCycleAction, timeout time.Duration) (string, error)

CiliumPolicyAction performs the specified action in Kubernetes for the policy stored in path filepath and waits up until timeout seconds for the policy to be applied in all Cilium endpoints. Returns an error if the policy is not imported before the timeout is exceeded.

func (*Kubectl) CiliumPolicyRevision

func (kub *Kubectl) CiliumPolicyRevision(pod string) (int, error)

CiliumPolicyRevision returns the policy revision in the specified Cilium pod. Returns an error if the policy revision cannot be retrieved.

func (*Kubectl) CiliumPreFlightCheck

func (kub *Kubectl) CiliumPreFlightCheck() error

CiliumPreFlightCheck specify that it checks that various subsystems within Cilium are in a good state. If one of the multiple preflight fails it'll return an error.

func (*Kubectl) CiliumReport

func (kub *Kubectl) CiliumReport(namespace string, commands ...string)

CiliumReport report the cilium pod to the log and appends the logs for the given commands.

func (*Kubectl) CiliumUninstall added in v1.6.0

func (kub *Kubectl) CiliumUninstall(options []string) error

CiliumUninstall uninstalls Cilium with the provided Helm options.

func (*Kubectl) Create

func (kub *Kubectl) Create(filePath string) *CmdRes

Create creates the Kubernetes kanifest located at path filepath.

func (*Kubectl) CreateResource

func (kub *Kubectl) CreateResource(resource, resourceName string) *CmdRes

CreateResource is a wrapper around `kubernetes create <resource> <resourceName>.

func (*Kubectl) Delete

func (kub *Kubectl) Delete(filePath string) *CmdRes

Delete deletes the Kubernetes manifest at path filepath.

func (*Kubectl) DeleteETCDOperator

func (kub *Kubectl) DeleteETCDOperator()

DeleteETCDOperator delete the etcd-operator from the cluster pointed by kub.

func (*Kubectl) DeleteResource

func (kub *Kubectl) DeleteResource(resource, resourceName string) *CmdRes

DeleteResource is a wrapper around `kubernetes delete <resource> resourceName>.

func (*Kubectl) DeployPatch

func (kub *Kubectl) DeployPatch(original, patch string) error

DeployPatch deploys the original kubernetes descriptor with the given patch.

func (*Kubectl) DumpCiliumCommandOutput

func (kub *Kubectl) DumpCiliumCommandOutput(ctx context.Context, namespace string)

DumpCiliumCommandOutput runs a variety of commands (CiliumKubCLICommands) and writes the results to TestResultsPath

func (*Kubectl) EtcdOperatorReport

func (kub *Kubectl) EtcdOperatorReport(ctx context.Context, reportCmds map[string]string)

EtcdOperatorReport dump etcd pods data into the report directory to be able to debug etcd operator status in case of fail test.

func (*Kubectl) ExecKafkaPodCmd

func (kub *Kubectl) ExecKafkaPodCmd(namespace string, pod string, arg string) error

ExecKafkaPodCmd executes shell command with arguments arg in the specified pod residing in the specified namespace. It returns the stdout of the command that was executed. The kafka producer and consumer scripts do not return error if command leads to TopicAuthorizationException or any other error. Hence the function needs to also take into account the stderr messages returned.

func (*Kubectl) ExecPodCmd

func (kub *Kubectl) ExecPodCmd(namespace string, pod string, cmd string, options ...ExecOptions) *CmdRes

ExecPodCmd executes command cmd in the specified pod residing in the specified namespace. It returns a pointer to CmdRes with all the output

func (*Kubectl) ExecPodCmdBackground added in v1.6.0

func (kub *Kubectl) ExecPodCmdBackground(ctx context.Context, namespace string, pod string, cmd string, options ...ExecOptions) *CmdRes

ExecPodCmdBackground executes command cmd in background in the specified pod residing in the specified namespace. It returns a pointer to CmdRes with all the output

To receive the output of this function, the caller must invoke either kub.WaitUntilFinish() or kub.WaitUntilMatch() then subsequently fetch the output out of the result.

func (*Kubectl) ExecPodCmdContext

func (kub *Kubectl) ExecPodCmdContext(ctx context.Context, namespace string, pod string, cmd string, options ...ExecOptions) *CmdRes

ExecPodCmdContext synchronously executes command cmd in the specified pod residing in the specified namespace. It returns a pointer to CmdRes with all the output.

func (*Kubectl) GatherCiliumCoreDumps

func (kub *Kubectl) GatherCiliumCoreDumps(ctx context.Context, ciliumPod string)

GatherCiliumCoreDumps copies core dumps if are present in the /tmp folder into the test report folder for further analysis.

func (*Kubectl) GatherLogs

func (kub *Kubectl) GatherLogs(ctx context.Context)

GatherLogs dumps kubernetes pods, services, DaemonSet to the testResultsPath directory

func (*Kubectl) GeneratePodLogGatheringCommands

func (kub *Kubectl) GeneratePodLogGatheringCommands(ctx context.Context, reportCmds map[string]string)

GeneratePodLogGatheringCommands generates the commands to gather logs for all pods in the Kubernetes cluster, and maps the commands to the filename in which they will be stored in reportCmds.

func (*Kubectl) Get

func (kub *Kubectl) Get(namespace string, command string) *CmdRes

Get retrieves the provided Kubernetes objects from the specified namespace.

func (*Kubectl) GetAllPods

func (kub *Kubectl) GetAllPods(ctx context.Context, options ...ExecOptions) ([]v1.Pod, error)

GetAllPods returns a slice of all pods present in Kubernetes cluster, along with an error if the pods could not be retrieved via `kubectl`, or if the pod objects are unable to be marshaled from JSON.

func (*Kubectl) GetCNP

func (kub *Kubectl) GetCNP(namespace string, cnp string) *cnpv2.CiliumNetworkPolicy

GetCNP retrieves the output of `kubectl get cnp` in the given namespace for the given CNP and return a CNP struct. If the CNP does not exists or cannot unmarshal the Json output will return nil.

func (*Kubectl) GetCiliumPodOnNode

func (kub *Kubectl) GetCiliumPodOnNode(namespace string, node string) (string, error)

GetCiliumPodOnNode returns the name of the Cilium pod that is running on / in the specified node / namespace.

func (*Kubectl) GetCiliumPods

func (kub *Kubectl) GetCiliumPods(namespace string) ([]string, error)

GetCiliumPods returns a list of all Cilium pods in the specified namespace, and an error if the Cilium pods were not able to be retrieved.

func (*Kubectl) GetCiliumPodsContext added in v1.5.5

func (kub *Kubectl) GetCiliumPodsContext(ctx context.Context, namespace string) ([]string, error)

GetCiliumPodsContext returns a list of all Cilium pods in the specified namespace, and an error if the Cilium pods were not able to be retrieved.

func (*Kubectl) GetEndpoints

func (kub *Kubectl) GetEndpoints(namespace string, filter string) *CmdRes

GetEndpoints gets all of the endpoints in the given namespace that match the provided filter.

func (*Kubectl) GetFromAllNS

func (kub *Kubectl) GetFromAllNS(kind string) *CmdRes

GetFromAllNS retrieves provided Kubernetes objects from all namespaces

func (*Kubectl) GetNumNodes

func (kub *Kubectl) GetNumNodes() int

GetNumNodes returns the number of Kubernetes nodes running

func (*Kubectl) GetPodNames

func (kub *Kubectl) GetPodNames(namespace string, label string) ([]string, error)

GetPodNames returns the names of all of the pods that are labeled with label in the specified namespace, along with an error if the pod names cannot be retrieved.

func (*Kubectl) GetPodNamesContext added in v1.5.5

func (kub *Kubectl) GetPodNamesContext(ctx context.Context, namespace string, label string) ([]string, error)

GetPodNamesContext returns the names of all of the pods that are labeled with label in the specified namespace, along with an error if the pod names cannot be retrieved.

func (*Kubectl) GetPods

func (kub *Kubectl) GetPods(namespace string, filter string) *CmdRes

GetPods gets all of the pods in the given namespace that match the provided filter.

func (*Kubectl) GetPodsIPs

func (kub *Kubectl) GetPodsIPs(namespace string, filter string) (map[string]string, error)

GetPodsIPs returns a map with pod name as a key and pod IP name as value. It only gets pods in the given namespace that match the provided filter. It returns an error if pods cannot be retrieved correctly

func (*Kubectl) GetPodsNodes

func (kub *Kubectl) GetPodsNodes(namespace string, filter string) (map[string]string, error)

GetPodsNodes returns a map with pod name as a key and node name as value. It only gets pods in the given namespace that match the provided filter. It returns an error if pods cannot be retrieved correctly

func (*Kubectl) GetServiceHostPort

func (kub *Kubectl) GetServiceHostPort(namespace string, service string) (string, int, error)

GetServiceHostPort returns the host and the first port for the given service name. It will return an error if service cannot be retrieved.

func (*Kubectl) KubeDNSPreFlightCheck

func (kub *Kubectl) KubeDNSPreFlightCheck() error

KubeDNSPreFlightCheck makes sure that kube-dns is plumbed into Cilium.

func (*Kubectl) Logs

func (kub *Kubectl) Logs(namespace string, pod string) *CmdRes

Logs returns a CmdRes with containing the resulting metadata from the execution of `kubectl logs <pod> -n <namespace>`.

func (*Kubectl) MicroscopeStart

func (kub *Kubectl) MicroscopeStart(microscopeOptions ...string) (error, func() error)

MicroscopeStart installs (if it is not installed) a new microscope pod, waits until pod is ready, and runs microscope in background. It returns an error in the case where microscope cannot be installed, or it is not ready after a timeout. It also returns a callback function to stop the monitor and save the output to `helpers.monitorLogFileName` file. Takes an optional list of arguments to pass to mircoscope.

func (*Kubectl) MonitorStart added in v1.5.2

func (kub *Kubectl) MonitorStart(namespace, pod, filename string) func() error

MonitorStart runs cilium monitor in the background and dumps the contents into a log file for later debugging

func (*Kubectl) NamespaceCreate

func (kub *Kubectl) NamespaceCreate(name string) *CmdRes

NamespaceCreate creates a new Kubernetes namespace with the given name

func (*Kubectl) NamespaceDelete

func (kub *Kubectl) NamespaceDelete(name string) *CmdRes

NamespaceDelete deletes a given Kubernetes namespace

func (*Kubectl) NodeCleanMetadata

func (kub *Kubectl) NodeCleanMetadata() error

NodeCleanMetadata annotates each node in the Kubernetes cluster with the annotation.V4CIDRName and annotation.V6CIDRName annotations. It returns an error if the nodes cannot be retrieved via the Kubernetes API.

func (*Kubectl) PprofReport

func (kub *Kubectl) PprofReport()

PprofReport runs pprof on cilium nodes each 5 minutes and saves the data into the test folder saved with pprof suffix.

func (*Kubectl) ValidateNoErrorsInLogs

func (kub *Kubectl) ValidateNoErrorsInLogs(duration time.Duration)

ValidateNoErrorsInLogs checks in cilium logs since the given duration (By default `CurrentGinkgoTestDescription().Duration`) do not contain `panic`, `deadlocks` or `segmentation faults` messages. In case of any of these messages, it'll mark the test as failed.

func (*Kubectl) WaitCleanAllTerminatingPods

func (kub *Kubectl) WaitCleanAllTerminatingPods(timeout time.Duration) error

WaitCleanAllTerminatingPods waits until all nodes that are in `Terminating` state are deleted correctly in the platform. In case of excedding the given timeout (in seconds) it returns an error

func (*Kubectl) WaitForCEPIdentity

func (kub *Kubectl) WaitForCEPIdentity(ns, podName string) error

WaitForCEPIdentity waits for a particular CEP to have an identity present.

func (*Kubectl) WaitForCRDCount

func (kub *Kubectl) WaitForCRDCount(filter string, count int, timeout time.Duration) error

func (*Kubectl) WaitForCiliumInitContainerToFinish

func (kub *Kubectl) WaitForCiliumInitContainerToFinish() error

WaitForCiliumInitContainerToFinish waits for all Cilium init containers to finish

func (*Kubectl) WaitForKubeDNSEntry

func (kub *Kubectl) WaitForKubeDNSEntry(serviceName, serviceNamespace string) error

WaitForKubeDNSEntry waits until the given DNS entry exists in the kube-dns service. If the container is not ready after timeout it returns an error. The name's format query should be `${name}.${namespace}`. If `svc.cluster.local` is not present, it appends to the given name and it checks the service's FQDN.

func (*Kubectl) WaitForServiceEndpoints

func (kub *Kubectl) WaitForServiceEndpoints(namespace string, filter string, service string, timeout time.Duration) error

WaitForServiceEndpoints waits up until timeout seconds have elapsed for all endpoints in the specified namespace that match the provided JSONPath filter. Returns true if all pods achieve the aforementioned desired state within timeout seconds. Returns false and an error if the command failed or the timeout was exceeded.

func (*Kubectl) WaitKubeDNS

func (kub *Kubectl) WaitKubeDNS() error

WaitKubeDNS waits until the kubeDNS pods are ready. In case of exceeding the default timeout it returns an error.

func (*Kubectl) WaitPolicyDeleted

func (kub *Kubectl) WaitPolicyDeleted(pod string, policyName string) error

WaitPolicyDeleted waits for policy policyName to be deleted from the cilium-agent running in pod. Returns an error if policyName was unable to be deleted after some amount of time.

func (*Kubectl) WaitforNPods

func (kub *Kubectl) WaitforNPods(namespace string, filter string, minRequired int, timeout time.Duration) error

WaitforNPods waits up until timeout seconds have elapsed for at least minRequired pods in the specified namespace that match the provided JSONPath filter to have their containterStatuses equal to "ready". Returns no error if minRequired pods achieve the aforementioned desired state within timeout seconds. Returns an error if the command failed or the timeout was exceeded. When minRequired is 0, the function will derive required pod count from number of pods in the cluster for every iteration.

func (*Kubectl) WaitforNPodsRunning added in v1.6.0

func (kub *Kubectl) WaitforNPodsRunning(namespace string, filter string, minRequired int, timeout time.Duration) error

WaitforNPodsRunning waits up until timeout duration has elapsed for at least minRequired pods in the specified namespace that match the provided JSONPath filter to have their containterStatuses equal to "running". Returns no error if minRequired pods achieve the aforementioned desired state within timeout seconds. Returns an error if the command failed or the timeout was exceeded. When minRequired is 0, the function will derive required pod count from number of pods in the cluster for every iteration.

func (*Kubectl) WaitforPods

func (kub *Kubectl) WaitforPods(namespace string, filter string, timeout time.Duration) error

WaitforPods waits up until timeout seconds have elapsed for all pods in the specified namespace that match the provided JSONPath filter to have their containterStatuses equal to "ready". Returns true if all pods achieve the aforementioned desired state within timeout seconds. Returns false and an error if the command failed or the timeout was exceeded.

type ManifestValues

type ManifestValues struct {
	Index int
}

ManifestValues wraps manifest index

type PerfTest

type PerfTest string

PerfTest represents a type of test to run when running `netperf`.

type ResourceLifeCycleAction

type ResourceLifeCycleAction string

ResourceLifeCycleAction represents an action performed upon objects in Kubernetes.

type SSHClient

type SSHClient struct {
	Config *ssh.ClientConfig // ssh client configuration information.
	Host   string            // Ip/Host from the target virtualserver
	Port   int               // Port to connect to the target server
	// contains filtered or unexported fields
}

SSHClient stores the information needed to SSH into a remote location for running tests.

func GetSSHClient

func GetSSHClient(host string, port int, user string) *SSHClient

GetSSHClient initializes an SSHClient for the specified host/port/user combination.

func (*SSHClient) GetHostPort

func (cli *SSHClient) GetHostPort() string

GetHostPort returns the host port representation of the ssh client

func (*SSHClient) RunCommand

func (client *SSHClient) RunCommand(cmd *SSHCommand) error

RunCommand runs a SSHCommand using SSHClient client. The returned error is nil if the command runs, has no problems copying stdin, stdout, and stderr, and exits with a zero exit status.

func (*SSHClient) RunCommandContext

func (client *SSHClient) RunCommandContext(ctx context.Context, cmd *SSHCommand) error

RunCommandContext runs an SSH command in a similar way to RunCommand but with a context. If context is canceled it will return the error of that given context.

func (*SSHClient) RunCommandInBackground

func (client *SSHClient) RunCommandInBackground(ctx context.Context, cmd *SSHCommand) error

RunCommandInBackground runs an SSH command in a similar way to RunCommandContext, but with a context which allows the command to be cancelled at any time. When cancel is called the error of the command is returned instead the context error.

func (*SSHClient) String

func (client *SSHClient) String() string

type SSHCommand

type SSHCommand struct {
	// TODO: path is not a clear name - rename to something more clear.
	Path   string
	Env    []string
	Stdin  io.Reader
	Stdout io.Writer
	Stderr io.Writer
}

SSHCommand stores the data associated with executing a command. TODO: this is poorly named in that it's not related to a command only ran over SSH - rename this.

type SSHConfig

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

SSHConfig contains metadata for an SSH session.

func (*SSHConfig) GetSSHAgent

func (cfg *SSHConfig) GetSSHAgent() ssh.AuthMethod

GetSSHAgent returns the ssh.AuthMethod corresponding to SSHConfig cfg.

func (*SSHConfig) GetSSHClient

func (cfg *SSHConfig) GetSSHClient() *SSHClient

GetSSHClient initializes an SSHClient based on the provided SSHConfig

func (*SSHConfig) String

func (cfg *SSHConfig) String() string

type SSHConfigs

type SSHConfigs map[string]*SSHConfig

SSHConfigs maps the name of a host (VM) to its corresponding SSHConfiguration

func ImportSSHconfig

func ImportSSHconfig(config []byte) (SSHConfigs, error)

ImportSSHconfig imports the SSH configuration stored at the provided path. Returns an error if the SSH configuration could not be instantiated.

type SSHMeta

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

SSHMeta contains metadata to SSH into a remote location to run tests

func CreateSSHMeta

func CreateSSHMeta(host string, port int, user string) *SSHMeta

CreateSSHMeta returns an SSHMeta with the specified host, port, and user, as well as an according SSHClient.

func GetVagrantSSHMeta

func GetVagrantSSHMeta(vmName string) *SSHMeta

GetVagrantSSHMeta returns a SSHMeta initialized based on the provided SSH-config target.

func InitRuntimeHelper

func InitRuntimeHelper(target string, log *logrus.Entry) *SSHMeta

InitRuntimeHelper returns SSHMeta helper for running the runtime tests on the provided VM target and using logger 'log'. It marks the test as Fail if it cannot get the ssh meta information or cannot execute a `ls` on the virtual machine.

func (*SSHMeta) AddIPToLoopbackDevice

func (s *SSHMeta) AddIPToLoopbackDevice(ip string) *CmdRes

AddIPToLoopbackDevice adds the specified IP (assumed to be in form <ip>/<mask>) to the loopback device on s.

func (*SSHMeta) BpfLBList

func (s *SSHMeta) BpfLBList(noDuplicates bool) (map[string][]string, error)

BpfLBList returns the output of `cilium bpf lb list -o json` as a map Key will be the frontend address and the value is an array with all backend addresses

func (*SSHMeta) CloseSSHClient added in v1.5.6

func (s *SSHMeta) CloseSSHClient()

CloseSSHClient closes all of the connections made by the SSH Client for this SSHMeta.

func (*SSHMeta) ContainerCreate

func (s *SSHMeta) ContainerCreate(name, image, net, options string, cmdParams ...string) *CmdRes

ContainerCreate is a wrapper for `docker run`. It runs an instance of the specified Docker image with the provided network, name, options and container startup commands.

func (*SSHMeta) ContainerExec

func (s *SSHMeta) ContainerExec(name string, cmd string, optionalArgs ...string) *CmdRes

ContainerExec executes cmd in the container with the provided name along with any other additional arguments needed.

func (*SSHMeta) ContainerInspect

func (s *SSHMeta) ContainerInspect(name string) *CmdRes

ContainerInspect runs `docker inspect` for the container with the provided name.

func (*SSHMeta) ContainerInspectNet

func (s *SSHMeta) ContainerInspectNet(name string) (map[string]string, error)

ContainerInspectNet returns a map of Docker networking information fields and their associated values for the container of the provided name. An error is returned if the networking information could not be retrieved.

func (*SSHMeta) ContainerRm

func (s *SSHMeta) ContainerRm(name string) *CmdRes

ContainerRm is a wrapper around `docker rm -f`. It forcibly removes the Docker container of the provided name.

func (*SSHMeta) ContainerRun

func (s *SSHMeta) ContainerRun(name, image, net, options string, cmdParams ...string) *CmdRes

ContainerRun is a wrapper to a one execution docker run container. It runs an instance of the specific Docker image with the provided network, name and options.

func (*SSHMeta) DumpCiliumCommandOutput

func (s *SSHMeta) DumpCiliumCommandOutput()

DumpCiliumCommandOutput runs a variety of Cilium CLI commands and dumps their output to files. These files are gathered as part of each Jenkins job for postmortem debugging of build failures.

func (*SSHMeta) EndpointGet

func (s *SSHMeta) EndpointGet(id string) *models.Endpoint

EndpointGet returns the output of `cilium endpoint get` for the provided endpoint ID.

func (*SSHMeta) EndpointSetConfig

func (s *SSHMeta) EndpointSetConfig(id, option, value string) bool

EndpointSetConfig sets the provided configuration option to the provided value for the endpoint with the endpoint ID id. It returns true if the configuration update command returned successfully.

func (*SSHMeta) Exec

func (s *SSHMeta) Exec(cmd string, options ...ExecOptions) *CmdRes

Exec returns the results of executing the provided cmd via SSH.

func (*SSHMeta) ExecCilium

func (s *SSHMeta) ExecCilium(cmd string) *CmdRes

ExecCilium runs a Cilium CLI command and returns the resultant cmdRes.

func (*SSHMeta) ExecContext

func (s *SSHMeta) ExecContext(ctx context.Context, cmd string, options ...ExecOptions) *CmdRes

ExecContext returns the results of executing the provided cmd via SSH.

func (*SSHMeta) ExecContextShort added in v1.5.5

func (s *SSHMeta) ExecContextShort(ctx context.Context, cmd string, options ...ExecOptions) *CmdRes

ExecContextShort is a wrapper around ExecContext which creates a child context with a timeout of ShortCommandTimeout.

func (*SSHMeta) ExecInBackground

func (s *SSHMeta) ExecInBackground(ctx context.Context, cmd string, options ...ExecOptions) *CmdRes

ExecInBackground returns the results of running cmd via SSH in the specified context. The command will be executed in the background until context.Context is canceled or the command has finish its execution.

func (*SSHMeta) ExecMiddle added in v1.5.6

func (s *SSHMeta) ExecMiddle(cmd string, options ...ExecOptions) *CmdRes

ExecMiddle runs command with the provided options. It will take up to MidCommandTimeout seconds to run the command before it times out.

func (*SSHMeta) ExecShort added in v1.5.5

func (s *SSHMeta) ExecShort(cmd string, options ...ExecOptions) *CmdRes

ExecShort runs command with the provided options. It will take up to ShortCommandTimeout seconds to run the command before it times out.

func (*SSHMeta) ExecWithSudo

func (s *SSHMeta) ExecWithSudo(cmd string, options ...ExecOptions) *CmdRes

ExecWithSudo returns the result of executing the provided cmd via SSH using sudo.

func (*SSHMeta) ExecuteContext

func (s *SSHMeta) ExecuteContext(ctx context.Context, cmd string, stdout io.Writer, stderr io.Writer) error

ExecuteContext executes the given `cmd` and writes the cmd's stdout and stderr into the given io.Writers. Returns an error if context Deadline() is reached or if there was an error executing the command.

func (*SSHMeta) FlushGlobalConntrackTable

func (s *SSHMeta) FlushGlobalConntrackTable() *CmdRes

FlushGlobalConntrackTable flushes the global connection tracking table.

func (*SSHMeta) GatherDockerLogs

func (s *SSHMeta) GatherDockerLogs()

GatherDockerLogs dumps docker containers logs output to the directory testResultsPath

func (*SSHMeta) GatherLogs

func (s *SSHMeta) GatherLogs()

GatherLogs dumps Cilium, Cilium Docker, key-value store logs, and gops output to the directory testResultsPath

func (*SSHMeta) GetAllEndpointsIds

func (s *SSHMeta) GetAllEndpointsIds() (map[string]string, error)

GetAllEndpointsIds returns a mapping of all Docker container name to to its corresponding endpoint ID, and an error if the list of endpoints cannot be retrieved via the Cilium CLI.

func (*SSHMeta) GetCopy

func (s *SSHMeta) GetCopy() *SSHMeta

GetCopy returns a copy of SSHMeta, useful for parallel requests

func (*SSHMeta) GetEndpointMutableConfigurationOption

func (s *SSHMeta) GetEndpointMutableConfigurationOption(endpointID, optionName string) (string, error)

GetEndpointMutableConfigurationOption returns the value of the mutable configuration option optionName for the endpoint with ID endpointID, or an error if optionName's corresponding value cannot be retrieved for the endpoint.

func (*SSHMeta) GetEndpointsIDMap

func (s *SSHMeta) GetEndpointsIDMap() (map[string]string, error)

GetEndpointsIDMap returns a mapping of an endpoint ID to Docker container name, and an error if the list of endpoints cannot be retrieved via the Cilium CLI.

func (*SSHMeta) GetEndpointsIdentityIds

func (s *SSHMeta) GetEndpointsIdentityIds() (map[string]string, error)

GetEndpointsIdentityIds returns a mapping of a Docker container name to it's corresponding endpoint's security identity, it will return an error if the list of endpoints cannot be retrieved via the Cilium CLI.

func (*SSHMeta) GetEndpointsIds

func (s *SSHMeta) GetEndpointsIds() (map[string]string, error)

GetEndpointsIds returns a mapping of a Docker container name to to its corresponding endpoint ID, and an error if the list of endpoints cannot be retrieved via the Cilium CLI.

func (*SSHMeta) GetEndpointsNames

func (s *SSHMeta) GetEndpointsNames() ([]string, error)

GetEndpointsNames returns the container-name field of each Cilium endpoint.

func (*SSHMeta) GetFullPath

func (s *SSHMeta) GetFullPath(name string) string

GetFullPath returns the path of file name prepended with the absolute path where manifests (YAMLs containing policies, DaemonSets, etc.) are stored.

func (*SSHMeta) ListEndpoints

func (s *SSHMeta) ListEndpoints() *CmdRes

ListEndpoints returns the CmdRes resulting from executing `cilium endpoint list -o json`.

func (*SSHMeta) ManifestsPath

func (s *SSHMeta) ManifestsPath() string

ManifestsPath returns the path of the directory where manifests (YAMLs containing policies, DaemonSets, etc.) are stored for the runtime tests. TODO: this can just be a constant; there's no need to have a function.

func (*SSHMeta) MonitorStart

func (s *SSHMeta) MonitorStart() func() error

MonitorStart starts the monitor command in background and returns a callback function wich stops the monitor when the user needs. When the callback is called the command will stop and monitor's output is saved on `monitorLogFileName` file.

func (*SSHMeta) NetworkCreate

func (s *SSHMeta) NetworkCreate(name string, subnet string) *CmdRes

NetworkCreate creates a Docker network of the provided name with the specified subnet. It is a wrapper around `docker network create`.

func (*SSHMeta) NetworkDelete

func (s *SSHMeta) NetworkDelete(name string) *CmdRes

NetworkDelete deletes the Docker network of the provided name. It is a wrapper around `docker network rm`.

func (*SSHMeta) NetworkGet

func (s *SSHMeta) NetworkGet(name string) *CmdRes

NetworkGet returns all of the Docker network configuration for the provided network. It is a wrapper around `docker network inspect`.

func (*SSHMeta) PolicyDel

func (s *SSHMeta) PolicyDel(id string) *CmdRes

PolicyDel deletes the policy with the given ID from Cilium.

func (*SSHMeta) PolicyDelAll

func (s *SSHMeta) PolicyDelAll() *CmdRes

PolicyDelAll deletes all policy rules currently imported into Cilium.

func (*SSHMeta) PolicyEndpointsSummary

func (s *SSHMeta) PolicyEndpointsSummary() (map[string]int, error)

PolicyEndpointsSummary returns the count of whether policy enforcement is enabled, disabled, and the total number of endpoints, and an error if the Cilium endpoint metadata cannot be retrieved via the API.

func (*SSHMeta) PolicyGet

func (s *SSHMeta) PolicyGet(id string) *CmdRes

PolicyGet runs `cilium policy get <id>`, where id is the name of a specific policy imported into Cilium. It returns the resultant CmdRes from running the aforementioned command.

func (*SSHMeta) PolicyGetAll

func (s *SSHMeta) PolicyGetAll() *CmdRes

PolicyGetAll gets all policies that are imported in the Cilium agent.

func (*SSHMeta) PolicyGetRevision

func (s *SSHMeta) PolicyGetRevision() (int, error)

PolicyGetRevision retrieves the current policy revision number in the Cilium agent.

func (*SSHMeta) PolicyImport

func (s *SSHMeta) PolicyImport(path string) error

PolicyImport imports a new policy into Cilium.

func (*SSHMeta) PolicyImportAndWait

func (s *SSHMeta) PolicyImportAndWait(path string, timeout time.Duration) (int, error)

PolicyImportAndWait validates and imports a new policy into Cilium and waits until the policy revision number increments. Returns an error if the policy is invalid or could not be imported.

func (*SSHMeta) PolicyRenderAndImport

func (s *SSHMeta) PolicyRenderAndImport(policy string) (int, error)

PolicyRenderAndImport receives an string with a policy, renders it in the test root directory and imports the policy to cilium. It returns the new policy id. Returns an error if the file cannot be created or if the policy cannot be imported

func (*SSHMeta) PolicyWait

func (s *SSHMeta) PolicyWait(revisionNum int) *CmdRes

PolicyWait executes `cilium policy wait`, which waits until all endpoints are updated to the given policy revision.

func (*SSHMeta) PprofReport

func (s *SSHMeta) PprofReport()

PprofReport runs pprof each 5 minutes and saves the data into the test folder saved with pprof suffix.

func (*SSHMeta) RemoveIPFromLoopbackDevice

func (s *SSHMeta) RemoveIPFromLoopbackDevice(ip string) *CmdRes

RemoveIPFromLoopbackDevice removes the specified IP (assumed to be in form <ip>/<mask>) from the loopback device on s.

func (*SSHMeta) ReportFailed

func (s *SSHMeta) ReportFailed(commands ...string)

ReportFailed gathers relevant Cilium runtime data and logs for debugging purposes.

func (*SSHMeta) RestartCilium

func (s *SSHMeta) RestartCilium() error

RestartCilium reloads cilium on this host, then waits for it to become ready again.

func (*SSHMeta) SampleContainersActions

func (s *SSHMeta) SampleContainersActions(mode string, networkName string, createOptions ...string)

SampleContainersActions creates or deletes various containers used for testing Cilium and adds said containers to the provided Docker network.

func (*SSHMeta) ServiceAdd

func (s *SSHMeta) ServiceAdd(id int, frontend string, backends []string) *CmdRes

ServiceAdd creates a new Cilium service with the provided ID, frontend, backends. Returns the result of creating said service.

func (*SSHMeta) ServiceDel

func (s *SSHMeta) ServiceDel(id int) *CmdRes

ServiceDel is a wrapper around `cilium service delete <id>`. It returns the result of deleting said service.

func (*SSHMeta) ServiceDelAll

func (s *SSHMeta) ServiceDelAll() *CmdRes

ServiceDelAll is a wrapper around `cilium service delete --all`. It returns the result of the command.

func (*SSHMeta) ServiceGet

func (s *SSHMeta) ServiceGet(id int) *CmdRes

ServiceGet is a wrapper around `cilium service get <id>`. It returns the result of retrieving said service.

func (*SSHMeta) ServiceGetFrontendAddress

func (s *SSHMeta) ServiceGetFrontendAddress(id int) (string, error)

ServiceGetFrontendAddress returns a string with the frontend address and port. It returns an error if the ID cannot be retrieved.

func (*SSHMeta) ServiceGetIds

func (s *SSHMeta) ServiceGetIds() ([]string, error)

ServiceGetIds returns an array with the IDs of all Cilium services. Returns an error if the IDs cannot be retrieved

func (*SSHMeta) ServiceIsSynced

func (s *SSHMeta) ServiceIsSynced(id int) (bool, error)

ServiceIsSynced checks that the Cilium service with the specified id has its metadata match that of the load balancer BPF maps

func (*SSHMeta) ServiceList

func (s *SSHMeta) ServiceList() *CmdRes

ServiceList returns the output of `cilium service list`

func (*SSHMeta) SetAndWaitForEndpointConfiguration

func (s *SSHMeta) SetAndWaitForEndpointConfiguration(endpointID, optionName, expectedValue string) error

SetAndWaitForEndpointConfiguration waits for the endpoint configuration to become a certain value

func (*SSHMeta) SetPolicyEnforcement

func (s *SSHMeta) SetPolicyEnforcement(status string) *CmdRes

SetPolicyEnforcement sets the PolicyEnforcement configuration value for the Cilium agent to the provided status.

func (*SSHMeta) SetPolicyEnforcementAndWait

func (s *SSHMeta) SetPolicyEnforcementAndWait(status string) bool

SetPolicyEnforcementAndWait and wait sets the PolicyEnforcement configuration value for the Cilium agent to the provided status, and then waits for all endpoints running in s to be ready. Returns whether setting of the configuration value was unsuccessful / if the endpoints go into ready state.

func (*SSHMeta) SetUpCilium

func (s *SSHMeta) SetUpCilium() error

SetUpCilium sets up Cilium as a systemd service with a hardcoded set of options. It returns an error if any of the operations needed to start Cilium fails.

func (*SSHMeta) SetUpCiliumInIpvlanMode

func (s *SSHMeta) SetUpCiliumInIpvlanMode(ipvlanMasterDevice string) error

SetUpCiliumInIpvlanMode starts cilium-agent in the ipvlan mode

func (*SSHMeta) SetUpCiliumWithOptions

func (s *SSHMeta) SetUpCiliumWithOptions(ciliumOpts string) error

SetUpCiliumWithOptions sets up Cilium as a systemd service with a given set of options. It returns an error if any of the operations needed to start Cilium fail.

func (*SSHMeta) SetUpCiliumWithSockops

func (s *SSHMeta) SetUpCiliumWithSockops() error

func (*SSHMeta) String

func (s *SSHMeta) String() string

func (*SSHMeta) ValidateEndpointsAreCorrect added in v1.6.0

func (s *SSHMeta) ValidateEndpointsAreCorrect(dockerNetwork string) error

ValidateEndpointsAreCorrect is a function that validates that all Docker container that are in the given docker network are correct as cilium endpoints.

func (*SSHMeta) ValidateNoErrorsInLogs

func (s *SSHMeta) ValidateNoErrorsInLogs(duration time.Duration)

ValidateNoErrorsInLogs checks in cilium logs since the given duration (By default `CurrentGinkgoTestDescription().Duration`) do not contain `panic`, `deadlocks` or `segmentation faults` messages . In case of any of these messages, it'll mark the test as failed.

func (*SSHMeta) WaitEndpointsDeleted

func (s *SSHMeta) WaitEndpointsDeleted() bool

WaitEndpointsDeleted waits up until timeout reached for all endpoints to be deleted. Returns true if all endpoints have been deleted before HelperTimeout is exceeded, false otherwise.

func (*SSHMeta) WaitEndpointsReady

func (s *SSHMeta) WaitEndpointsReady() bool

WaitEndpointsReady waits up until timeout reached for all endpoints to not be in any regenerating or waiting-for-identity state. Returns true if all endpoints regenerate before HelperTimeout is exceeded, false otherwise.

func (*SSHMeta) WaitUntilReady

func (s *SSHMeta) WaitUntilReady(timeout time.Duration) error

WaitUntilReady waits until the output of `cilium status` returns with code zero. Returns an error if the output of `cilium status` returns a nonzero return code after the specified timeout duration has elapsed.

type SSHMetaError

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

SSHMetaError is a custom error that executes a callback function when its Error() function is invoked

func NewSSHMetaError

func NewSSHMetaError(errorString string, callback func() string) *SSHMetaError

NewSSHMetaError returns a new SSHMetaError with the given string and a callback function

func (*SSHMetaError) Error

func (e *SSHMetaError) Error() string

func (*SSHMetaError) String

func (e *SSHMetaError) String() string

type TimeoutConfig

type TimeoutConfig struct {
	Ticker  time.Duration // Check interval
	Timeout time.Duration // Limit for how long to spend in the command
}

TimeoutConfig represents the configuration for the timeout of a command.

func (*TimeoutConfig) Validate added in v1.6.0

func (c *TimeoutConfig) Validate() error

Validate ensuires that the parameters for the TimeoutConfig are reasonable for running in tests.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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