framework

package
v1.2.4 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2023 License: Apache-2.0 Imports: 73 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultOsmGrafanaPort is the default Grafana port
	DefaultOsmGrafanaPort = 3000
	// DefaultOsmPrometheusPort default OSM prometheus port
	DefaultOsmPrometheusPort = 7070

	// OsmGrafanaAppLabel is the OSM Grafana deployment app label
	OsmGrafanaAppLabel = "osm-grafana"
	// OsmPrometheusAppLabel is the OSM Prometheus deployment app label
	OsmPrometheusAppLabel = "osm-prometheus"

	// MeshDetails is dashboard uuid and name as we have them load in Grafana
	MeshDetails string = "PLyKJcHGz/mesh-and-envoy-details"

	// MemRSSPanel is the ID of the MemRSS panel on OSM's MeshDetails dashboard
	MemRSSPanel int = 13

	// CPUPanel is the ID of the CPU panel on OSM's MeshDetails dashboard
	CPUPanel int = 14
)
View Source
const (
	// EnvoyOSMWindowsImage is Envoy Windows image used for testing.
	// On Windows until Windows Server 2022 is publicly available we have to rely on this testing images.
	EnvoyOSMWindowsImage = "openservicemesh/envoy-windows-nanoserver@sha256:94590d10bc8a46c60cd3a3858d80f3d6577d4e9a191fa05c0077f8b3d6002e22"

	// WindowsNanoserverDockerImage is the base Windows image that is compatible with the test cluster.
	WindowsNanoserverDockerImage = "mcr.microsoft.com/powershell:lts-nanoserver-ltsc2022"

	// HttpbinOSMWindowsImage is the Windows based httpbin image used for testing.
	HttpbinOSMWindowsImage = "openservicemesh/go-http-win@sha256:dd81377aa0ff749a5a9a7a1a25786a710f77991c94b3015f674163e32d7fe5f8"
)

Windows Specific container images

View Source
const (
	// DefaultUpstreamServicePort is the default port on which the server apps listen for connections from client apps.
	// Note: Port 80 should not be used because it does not work on OpenShift.
	DefaultUpstreamServicePort = 14001
)
View Source
const OSCrossPlatform string = "Cross-platform"

OSCrossPlatform indicates that a test can run on all operating systems.

View Source
const (
	// StatusCodeWord is an identifier used on curl commands to print and parse REST Status codes
	StatusCodeWord = "StatusCode"
)

Variables

View Source
var (
	// OsmCtlLabels is the list of app labels for OSM CTL
	OsmCtlLabels = []string{constants.OSMControllerName, OsmGrafanaAppLabel, OsmPrometheusAppLabel, constants.OSMInjectorName, constants.OSMBootstrapName}

	// NginxIngressSvc is the namespaced name of the nginx ingress service
	NginxIngressSvc = types.NamespacedName{Namespace: "ingress-ns", Name: "ingress-nginx-controller"}
)
View Source
var HttpbinCmd = []string{"gunicorn", "-b", fmt.Sprintf("0.0.0.0:%d", DefaultUpstreamServicePort), "httpbin:app", "-k", "gevent"}

HttpbinCmd is the command to be used for httpbin applications in e2es

View Source
var PodCommandDefault = []string{}

PodCommandDefault is the default pod command (nothing)

Functions

func OSMDescribe

func OSMDescribe(name string, opts OSMDescribeInfo, body func()) bool

OSMDescribe givens the description of an e2e test

func RandomNameWithPrefix added in v0.11.0

func RandomNameWithPrefix(prefix string) string

RandomNameWithPrefix generates a random string with the given prefix.

If the prefix is empty, the default prefix "test" will be used

Types

type CleanupType

type CleanupType string

CleanupType identifies what triggered the cleanup

const (
	// Test is to mark after-test cleanup
	Test CleanupType = "test"

	//Suite is to mark after-suite cleanup
	Suite CleanupType = "suite"
)

type CollectLogsType added in v0.8.1

type CollectLogsType string

CollectLogsType defines if/when to collect logs

const (
	// CollectLogs is used to force log collection
	CollectLogs CollectLogsType = "yes"

	// CollectLogsIfErrorOnly will collect logs only when test errors out
	CollectLogsIfErrorOnly CollectLogsType = "ifError"

	// NoCollectLogs will not collect logs
	NoCollectLogs CollectLogsType = "no"

	// ControlPlaneOnly will collect logs only for control plane processes
	ControlPlaneOnly CollectLogsType = "controlPlaneOnly"
)

type DataHandle added in v0.7.0

type DataHandle struct {
	// Test start time
	TestStartTime time.Time

	// Prometheus and Grafana handles
	PromHandle *Prometheus
	GrafHandle *Grafana

	// Result output files, allows setting multiple descriptors to write results
	ResultsOut []*os.File

	// Defines the resources to keep track across iterations
	TrackAppLabels []TrackedLabel
	// Defines the panels to save upon WrapUp invocation
	GrafanaPanelsToSave []GrafanaPanel

	// Set of names to track exact resources that were observed at any point in time
	// during the test
	SeenResources map[Resource]bool

	// Scale iterations data
	Iterations  int
	ItStartTime []time.Time
	ItEndTime   []time.Time
}

DataHandle is the handle to specific resource information during a test

func NewDataHandle added in v0.7.0

func NewDataHandle(pHandle *Prometheus, gHandle *Grafana, trackResources []TrackedLabel, saveDashboards []GrafanaPanel) *DataHandle

NewDataHandle Returns an initialized scale data

func (*DataHandle) Iterate added in v0.7.0

func (sd *DataHandle) Iterate(f func())

Iterate wrapper to loop and track various resources across iterations (time, mem consumption, iteration num, etc.)

func (*DataHandle) IterateTrackedPods added in v0.7.0

func (sd *DataHandle) IterateTrackedPods(f func(pod *corev1.Pod))

IterateTrackedPods is a Helper to iterate pods selected by the Tracked labels

func (*DataHandle) OutputIteration added in v0.7.0

func (sd *DataHandle) OutputIteration(iterNumber int, f *os.File)

OutputIteration prints on file <f> the results of iteration <iterNumber> The CpuAvg is taken from the duration of the iteration itself, and uses prometheus `rate` which has extrapolation of both sides of the bucket. Mem RSS is simply the Mem RSS value at the end of the iteration.

func (*DataHandle) OutputIterationTable added in v0.7.0

func (sd *DataHandle) OutputIterationTable(f *os.File)

OutputIterationTable Print all iteration statistics in table format. For Duration and Memory values, relative distance to previous iteration is computed. For CPU, the CPU load average over the iteration time is computed (using prometheus rate).

func (*DataHandle) OutputMemPerPod added in v0.7.0

func (sd *DataHandle) OutputMemPerPod(f *os.File)

OutputMemPerPod outputs the per-pod mem delta for the tracked resources over the test and outputs it in table format, example: The output requires at least 2 iterations to compare, as the MemRSS initial value is taken from the end of the first iteration, to avoid counting overhead of the application itself.

func (*DataHandle) OutputTestResults added in v0.7.0

func (sd *DataHandle) OutputTestResults(f *os.File)

OutputTestResults Print all available results

func (*DataHandle) WrapUp added in v0.7.0

func (sd *DataHandle) WrapUp()

WrapUp is a callback to execute after the test is done. Will output all iteration results, compute some relative usages between iterations and save grafana dashboards if any are to be saved

type DockerConfig

type DockerConfig map[string]DockerConfigEntry

DockerConfig and other configs are docker-specific container registry secret structures. Most of it is taken or referenced from kubectl source itself

type DockerConfigEntry

type DockerConfigEntry struct {
	Username string `json:"username,omitempty"`
	Password string `json:"password,omitempty"`
	Email    string `json:"email,omitempty"`
	Auth     string `json:"auth,omitempty"`
}

DockerConfigEntry is a struct for docker-specific container registry secret structures

type DockerConfigJSON

type DockerConfigJSON struct {
	Auths       DockerConfig      `json:"auths"`
	HTTPHeaders map[string]string `json:"HttpHeaders,omitempty"`
}

DockerConfigJSON is a struct for docker-specific config

type FortioGRPCLoadTestDef added in v1.2.0

type FortioGRPCLoadTestDef struct {
	GRPCRequestDef
	FortioLoadTestSpec
}

FortioGRPCLoadTestDef defines a Fortio GRPC load test intent

type FortioHTTPLoadTestDef added in v1.2.0

type FortioHTTPLoadTestDef struct {
	HTTPRequestDef
	FortioLoadTestSpec
}

FortioHTTPLoadTestDef defines a Fortio HTTP load test intent

type FortioLoadResult added in v1.2.0

type FortioLoadResult struct {
	ReturnCodes   map[string]FortioReturnCodeEntry
	DurationHist  map[float64]float64
	TotalRequests int32

	Err error
}

FortioLoadResult represents Fortio load test result

func (*FortioLoadResult) AllReturnCodes added in v1.2.0

func (result *FortioLoadResult) AllReturnCodes() []string

AllReturnCodes returns all the load test return codes as an array of strings.

func (*FortioLoadResult) HasFailedHTTPRequests added in v1.2.0

func (result *FortioLoadResult) HasFailedHTTPRequests() bool

HasFailedHTTPRequests checks if there is return code not smaller than 400. Non-numeric return code will be skipped. This is suitable for checking the result of Fortio HTTP load test.

type FortioLoadTestSpec added in v1.2.0

type FortioLoadTestSpec struct {
	// QPS is the number of requests per second. Negative number means no wait maximum rate. The default is 8
	QPS int

	// Connections is the number of connections/goroutines. The default is 4
	Connections int

	// Calls is the number of requests. Default is 0, which uses duration.
	Calls int

	// Duration is the duration of the test. Default is 5 seconds.
	Duration string
}

FortioLoadTestSpec defines the Fortio load test specification. Request definition is not included.

type FortioReturnCodeEntry added in v1.2.0

type FortioReturnCodeEntry struct {
	ReturnCode string
	Count      int
	Percentage float64
}

FortioReturnCodeEntry is a data entry for a single Fortio load test return code with related stats.

type FortioTCPLoadTestDef added in v1.2.0

type FortioTCPLoadTestDef struct {
	TCPRequestDef
	FortioLoadTestSpec
}

FortioTCPLoadTestDef defines a Fortio TCP load test intent

type GRPCRequestDef added in v0.7.0

type GRPCRequestDef struct {
	// Source pod where to run the HTTP request from
	SourceNs        string
	SourcePod       string
	SourceContainer string

	// The entire destination URL processed by curl, including host name and
	// optionally protocol, port, and path
	Destination string

	// JSONRequest is the JSON request body
	JSONRequest string

	// Symbol is the fully qualified grpc service name, ex. hello.HelloService/SayHello
	Symbol string

	// UseTLS indicates if the request should be encrypted with TLS
	UseTLS bool
}

GRPCRequestDef defines a remote GRPC request intent

type GRPCRequestResult added in v0.7.0

type GRPCRequestResult struct {
	Response string
	Err      error
}

GRPCRequestResult represents the result of a GRPCRequest call

type Grafana

type Grafana struct {
	Schema   string
	Hostname string
	Port     uint16
	User     string
	Password string
	// contains filtered or unexported fields
}

Grafana is a simple handler to represent a target Grafana endpoint to run queries against

func (*Grafana) PanelPNGSnapshot

func (g *Grafana) PanelPNGSnapshot(dashboard string, panelID int, fromMinutes int, saveFilepath string) error

PanelPNGSnapshot takes a snapshot from a Grafana dashboard or panel and saves it in local in <filename> in png format, using it's remote rendering HTTP API.

func (*Grafana) Stop added in v0.7.0

func (g *Grafana) Stop()

Stop gracefully stops the port forwarding to Grafana

type GrafanaPanel added in v0.7.0

type GrafanaPanel struct {
	Filename  string
	Dashboard string
	Panel     int
}

GrafanaPanel identifies a target Panel to be saved at the end of the test

type HTTPMultipleRequest

type HTTPMultipleRequest struct {
	// Request
	Sources []HTTPRequestDef
}

HTTPMultipleRequest takes multiple HTTP request defs to issue them concurrently

type HTTPMultipleResults

type HTTPMultipleResults map[string]map[string]HTTPRequestResult

HTTPMultipleResults represents results from a multiple HTTP request call results come back as a map["srcNs/srcPod"]["dstNs/dstPod"] -> HTTPResults

type HTTPRequestDef

type HTTPRequestDef struct {
	// Source pod where to run the HTTP request from
	SourceNs        string
	SourcePod       string
	SourceContainer string

	// The entire destination URL processed by curl, including host name and
	// optionally protocol, port, and path
	Destination string
}

HTTPRequestDef defines a remote HTTP request intent

type HTTPRequestResult

type HTTPRequestResult struct {
	StatusCode int
	Headers    map[string]string
	Err        error
}

HTTPRequestResult represents results of an HTTPRequest call

type InstallOSMOpts

type InstallOSMOpts struct {
	ControlPlaneNS          string
	CertManager             string
	ContainerRegistryLoc    string
	ContainerRegistrySecret string
	OsmImagetag             string
	DeployGrafana           bool
	DeployPrometheus        bool
	DeployJaeger            bool
	DeployFluentbit         bool
	EnableReconciler        bool

	VaultHost            string
	VaultProtocol        string
	VaultPort            int
	VaultToken           string
	VaultRole            string
	VaultTokenSecretName string
	VaultTokenSecretKey  string

	CertmanagerIssuerGroup string
	CertmanagerIssuerKind  string
	CertmanagerIssuerName  string
	CertKeyBitSize         int
	CertValidtyDuration    time.Duration

	EgressEnabled        bool
	EnablePermissiveMode bool
	OSMLogLevel          string
	EnvoyLogLevel        string
	LocalProxyMode       configv1alpha2.LocalProxyMode
	EnableDebugServer    bool

	SetOverrides []string

	EnablePrivilegedInitContainer bool
	EnableIngressBackendPolicy    bool
	EnableRetryPolicy             bool
}

InstallOSMOpts describes install options for OSM

type InstallOsmOpt added in v1.1.1

type InstallOsmOpt func(*InstallOSMOpts)

InstallOsmOpt is a function type for setting install options

func WithLocalProxyMode added in v1.1.1

func WithLocalProxyMode(mode configv1alpha2.LocalProxyMode) InstallOsmOpt

WithLocalProxyMode sets the LocalProxyMode for OSM

type InstallType

type InstallType string

InstallType defines several OSM test deployment scenarios

const (
	// SelfInstall uses current kube cluster, installs OSM using CLI
	SelfInstall InstallType = "SelfInstall"

	// KindCluster Creates Kind cluster on docker and uses it as cluster, OSM installs through CLI
	KindCluster InstallType = "KindCluster"

	// NoInstall uses current kube cluster, assumes an OSM is present in `OsmNamespace`
	NoInstall InstallType = "NoInstall"

	// RegistrySecretName is the default name for the container registry secret
	RegistrySecretName = "acr-creds"
)

type OSMDescribeInfo

type OSMDescribeInfo struct {
	// Tier represents the priority of the test. Lower value indicates higher priority.
	Tier int

	// Bucket indicates in which test Bucket the test will run in for CI. Each
	// Bucket is run in parallel while tests in the same Bucket run sequentially.
	Bucket int

	// OS indicates which OS the test can run on.
	OS string
}

OSMDescribeInfo is a struct to represent the Tier and Bucket of a given e2e test

func (OSMDescribeInfo) String

func (o OSMDescribeInfo) String() string

type OsmTestData

type OsmTestData struct {
	T           ginkgo.GinkgoTInterface // for common test logging
	TestID      uint64                  // uint randomized for every test. GinkgoRandomSeed can't be used as is per-suite.
	TestDirBase string                  // Test directory base, default "/tmp", can be variable overridden
	TestDirName string                  // Autogenerated, based on test ID

	CleanupTest          bool            // Cleanup test-related resources once finished
	WaitForCleanup       bool            // Forces test to wait for effective deletion of resources upon cleanup
	IgnoreRestarts       bool            // Ignore control plane processes restarts, if any
	InstType             InstallType     // Install type
	CollectLogs          CollectLogsType // Collect logs type
	InitialRestartValues map[string]int  // Captures properly if an OSM instance have restarted during a NoInstall test

	OsmNamespace      string
	OsmMeshConfigName string
	OsmImageTag       string
	EnableNsMetricTag bool

	// Container registry related vars
	CtrRegistryUser     string // registry login
	CtrRegistryPassword string // registry password, if any
	CtrRegistryServer   string // server name. Has to be network reachable

	// Kind cluster related vars
	ClusterName                    string // Kind cluster name (used if kindCluster)
	CleanupKindClusterBetweenTests bool   // Clean and re-create kind cluster between tests
	CleanupKindCluster             bool   // Cleanup kind cluster upon test finish
	ClusterVersion                 string // Kind cluster version, ex. v1.20.2

	ClusterOS string // The operating system of the working nodes in the cluster. Mixed OS traffic is not supported.

	ReqSuccessTimeout    time.Duration // ReqSuccessTimeout timeout duration that the test expects for all requests from the client to server to succeed.
	PodDeploymentTimeout time.Duration // PodDeploymentTimeout timeout duration that the test expects for all pods to be in ready state after they are deployed.

	// Cluster handles and rest config
	Env             *cli.EnvSettings
	RestConfig      *rest.Config
	Client          *kubernetes.Clientset
	APIServerClient *clientset.Clientset

	SmiClients *smiClients

	// OSM's API clients
	PolicyClient *versioned.Clientset
	ConfigClient *versioned2.Clientset

	ClusterProvider *cluster.Provider // provider, used when kindCluster is used

	DeployOnOpenShift      bool // Determines whether to configure tests for OpenShift
	DeployOnWindowsWorkers bool // Determines whether to configure tests to run on Windows workers

	RetryAppPodCreation bool // Whether to retry app pod creation due to issue #3973
}

OsmTestData stores common state, variables and flags for the test at hand

var Td OsmTestData

Td the global context for test.

func (*OsmTestData) AddNsToMesh

func (td *OsmTestData) AddNsToMesh(enableSidecarInjection bool, ns ...string) error

AddNsToMesh Adds monitored namespaces to the OSM mesh

func (*OsmTestData) AddOpenShiftSCC added in v0.9.0

func (td *OsmTestData) AddOpenShiftSCC(scc, serviceAccount, namespace string) error

AddOpenShiftSCC adds the specified SecurityContextConstraint to the given service account

func (*OsmTestData) AreRegistryCredsPresent

func (td *OsmTestData) AreRegistryCredsPresent() bool

AreRegistryCredsPresent checks if Registry Credentials are present It's usually used to factor if a docker registry secret and ImagePullSecret should be installed when creating namespaces and application templates

func (*OsmTestData) Cleanup

func (td *OsmTestData) Cleanup(ct CleanupType)

Cleanup is Used to cleanup resources once the test is done Cyclomatic complexity is disabled in cleanup, as it check a large number of conditions nolint:gocyclo

func (*OsmTestData) CreateDeployment

func (td *OsmTestData) CreateDeployment(ns string, deployment appsv1.Deployment) (*appsv1.Deployment, error)

CreateDeployment is a wrapper to create a deployment

func (*OsmTestData) CreateDockerRegistrySecret

func (td *OsmTestData) CreateDockerRegistrySecret(ns string)

CreateDockerRegistrySecret creates a secret named `RegistrySecretName` in namespace <ns>, based on ctrRegistry variables

func (*OsmTestData) CreateHTTPRouteGroup

func (td *OsmTestData) CreateHTTPRouteGroup(ns string, rg smiSpecs.HTTPRouteGroup) (*smiSpecs.HTTPRouteGroup, error)

CreateHTTPRouteGroup Creates an SMI HTTPRouteGroup

func (*OsmTestData) CreateMultipleNs

func (td *OsmTestData) CreateMultipleNs(nsName ...string) error

CreateMultipleNs simple CreateNs for multiple NS creation

func (*OsmTestData) CreateMutatingWebhook

CreateMutatingWebhook is a wrapper to create a mutating webhook configuration

func (*OsmTestData) CreateNs

func (td *OsmTestData) CreateNs(nsName string, labels map[string]string) error

CreateNs creates a Namespace. Will automatically add Docker registry creds if provided

func (*OsmTestData) CreatePod

func (td *OsmTestData) CreatePod(ns string, pod corev1.Pod) (*corev1.Pod, error)

CreatePod is a wrapper to create a pod

func (*OsmTestData) CreateService

func (td *OsmTestData) CreateService(ns string, svc corev1.Service) (*corev1.Service, error)

CreateService is a wrapper to create a service

func (*OsmTestData) CreateServiceAccount

func (td *OsmTestData) CreateServiceAccount(ns string, svcAccount *corev1.ServiceAccount) (*corev1.ServiceAccount, error)

CreateServiceAccount is a wrapper to create a service account If creating on OpenShift, add privileged SCC

func (*OsmTestData) CreateSimpleAllowPolicy

func (td *OsmTestData) CreateSimpleAllowPolicy(def SimpleAllowPolicy) (smiSpecs.HTTPRouteGroup, smiAccess.TrafficTarget)

CreateSimpleAllowPolicy returns basic allow policy from source to destination, on a HTTP all-wildcard fashion

func (*OsmTestData) CreateSimpleTCPAllowPolicy added in v0.7.0

func (td *OsmTestData) CreateSimpleTCPAllowPolicy(def SimpleAllowPolicy, port int) (smiSpecs.TCPRoute, smiAccess.TrafficTarget)

CreateSimpleTCPAllowPolicy returns an allow policy to allow all TCP traffic from source to destination

func (*OsmTestData) CreateSimpleTrafficSplit

func (td *OsmTestData) CreateSimpleTrafficSplit(def TrafficSplitDef) (smiSplit.TrafficSplit, error)

CreateSimpleTrafficSplit Creates an SMI TrafficTarget

func (*OsmTestData) CreateTCPRoute added in v0.7.0

func (td *OsmTestData) CreateTCPRoute(ns string, route smiSpecs.TCPRoute) (*smiSpecs.TCPRoute, error)

CreateTCPRoute Creates an SMI TCPRoute

func (*OsmTestData) CreateTrafficSplit

func (td *OsmTestData) CreateTrafficSplit(ns string, tar smiSplit.TrafficSplit) (*smiSplit.TrafficSplit, error)

CreateTrafficSplit Creates an SMI TrafficSplit

func (*OsmTestData) CreateTrafficTarget

func (td *OsmTestData) CreateTrafficTarget(ns string, tar smiAccess.TrafficTarget) (*smiAccess.TrafficTarget, error)

CreateTrafficTarget Creates an SMI TrafficTarget

func (*OsmTestData) DeleteHelmRelease

func (td *OsmTestData) DeleteHelmRelease(name, namespace string) error

DeleteHelmRelease uninstalls a particular helm release

func (*OsmTestData) DeleteNs

func (td *OsmTestData) DeleteNs(nsName string) error

DeleteNs deletes a test NS

func (*OsmTestData) FortioGRPCLoadTest added in v1.2.0

func (td *OsmTestData) FortioGRPCLoadTest(req FortioGRPCLoadTestDef) FortioLoadResult

FortioGRPCLoadTest runs a Fortio load test with GRPC protocol according to given FortioGRPCLoadTestDef and returns a FortioLoadResult

func (*OsmTestData) FortioHTTPLoadTest added in v1.2.0

func (td *OsmTestData) FortioHTTPLoadTest(ht FortioHTTPLoadTestDef) FortioLoadResult

FortioHTTPLoadTest runs a Fortio load test with HTTP protocol according to given FortioHTTPLoadTestDef and returns a FortioLoadResult

func (*OsmTestData) FortioTCPLoadTest added in v1.2.0

func (td *OsmTestData) FortioTCPLoadTest(req FortioTCPLoadTestDef) FortioLoadResult

FortioTCPLoadTest runs a Fortio load test with TCP protocol according to given FortioTCPLoadTestDef and returns a FortioLoadResult

func (*OsmTestData) GRPCRequest added in v0.7.0

func (td *OsmTestData) GRPCRequest(req GRPCRequestDef) GRPCRequestResult

GRPCRequest runs a GRPC request to run the GRPCRequestDef and return a GRPCRequestResult

func (*OsmTestData) GetBugReport added in v1.1.0

func (td *OsmTestData) GetBugReport() error

GetBugReport runs the "osm support bug-report" command

func (*OsmTestData) GetGrafanaPodHandle

func (td *OsmTestData) GetGrafanaPodHandle(ns string, grafanaPodName string, port uint16) (*Grafana, error)

GetGrafanaPodHandle generic func to forward a grafana pod and returns a handler pointing to the locally forwarded resource

func (*OsmTestData) GetMeshConfig added in v0.9.0

func (td *OsmTestData) GetMeshConfig(namespace string) (*configv1alpha2.MeshConfig, error)

GetMeshConfig is a wrapper to get a MeshConfig by name in a particular namespace

func (*OsmTestData) GetMutatingWebhook

func (td *OsmTestData) GetMutatingWebhook(mwhcName string) (*admissionregv1.MutatingWebhookConfiguration, error)

GetMutatingWebhook is a wrapper to get a mutating webhook configuration

func (*OsmTestData) GetOSMGrafanaHandle

func (td *OsmTestData) GetOSMGrafanaHandle() (*Grafana, error)

GetOSMGrafanaHandle convenience wrapper, will get the Grafana instance regularly deployed by OSM installation in test <OsmNamespace>

func (*OsmTestData) GetOSMInstallOpts

func (td *OsmTestData) GetOSMInstallOpts(options ...InstallOsmOpt) InstallOSMOpts

GetOSMInstallOpts initializes install options for OSM

func (*OsmTestData) GetOSMPrometheusHandle added in v0.7.0

func (td *OsmTestData) GetOSMPrometheusHandle() (*Prometheus, error)

GetOSMPrometheusHandle convenience wrapper, will get the Prometheus instance regularly deployed by OSM installation in test <OsmNamespace>

func (*OsmTestData) GetOSSpecificHTTPBinPod added in v0.11.0

func (td *OsmTestData) GetOSSpecificHTTPBinPod(podName string, namespace string, customCommand ...string) (corev1.ServiceAccount, corev1.Pod, corev1.Service, error)

GetOSSpecificHTTPBinPod returns a OS pod that runs httpbin.

func (*OsmTestData) GetOSSpecificSleepPod added in v0.10.0

func (td *OsmTestData) GetOSSpecificSleepPod(sourceNs string) (corev1.ServiceAccount, corev1.Pod, corev1.Service, error)

GetOSSpecificSleepPod returns a simple OS specific busy loop pod.

func (*OsmTestData) GetOSSpecificTCPEchoPod added in v0.11.0

func (td *OsmTestData) GetOSSpecificTCPEchoPod(podName string, namespace string, destinationPort int) (corev1.ServiceAccount, corev1.Pod, corev1.Service, error)

GetOSSpecificTCPEchoPod returns a simple OS specific tcp-echo pod.

func (*OsmTestData) GetOsmCtlComponentRestarts added in v0.8.1

func (td *OsmTestData) GetOsmCtlComponentRestarts() map[string]int

GetOsmCtlComponentRestarts gets the number of restarts of OSM CTL processes back in a map

func (*OsmTestData) GetPodsForLabel

func (td *OsmTestData) GetPodsForLabel(ns string, labelSel metav1.LabelSelector) ([]corev1.Pod, error)

GetPodsForLabel returns the Pods matching a specific `appLabel`

func (*OsmTestData) GetPrometheusPodHandle

func (td *OsmTestData) GetPrometheusPodHandle(ns string, prometheusPodName string, port uint16) (*Prometheus, error)

GetPrometheusPodHandle generic func to forward a prometheus pod and returns a handler pointing to the locally forwarded resource

func (*OsmTestData) GetTestDirPath added in v0.8.1

func (td *OsmTestData) GetTestDirPath() string

GetTestDirPath Returns absolute TestDirPath

func (*OsmTestData) GetTestFilePath added in v0.8.1

func (td *OsmTestData) GetTestFilePath(filename string) string

GetTestFilePath Returns absolute filepath for a filename. Will ensure TestFolder already exists. Convenience function used to get a proper filepath when creating a file in TestDir

func (*OsmTestData) GetTestNamespaceSelectorMap

func (td *OsmTestData) GetTestNamespaceSelectorMap() map[string]string

GetTestNamespaceSelectorMap returns a string-based selector used to refer/select all namespace resources for this test

func (*OsmTestData) GrabLogs added in v0.8.1

func (td *OsmTestData) GrabLogs() error

GrabLogs Collects logs on test folder for td.OsmNamespace

func (*OsmTestData) HTTPRequest

func (td *OsmTestData) HTTPRequest(ht HTTPRequestDef) HTTPRequestResult

HTTPRequest runs a synchronous call to run the HTTPRequestDef and return a HTTPRequestResult

func (*OsmTestData) HelmInstallOSM

func (td *OsmTestData) HelmInstallOSM(release, namespace string) error

HelmInstallOSM installs an osm control plane using the osm chart which lives in charts/osm

func (*OsmTestData) InitSMIClients

func (td *OsmTestData) InitSMIClients() error

InitSMIClients initializes SMI clients on OsmTestData structure

func (*OsmTestData) InitTestData

func (td *OsmTestData) InitTestData(t GinkgoTInterface) error

InitTestData Initializes the test structures Called by Ginkgo BeforeEach

func (*OsmTestData) InstallNginxIngress added in v0.10.0

func (td *OsmTestData) InstallNginxIngress() (string, error)

InstallNginxIngress installs the k8s Nginx Ingress controller and returns the IP address that clients can send traffic to for ingress

func (*OsmTestData) InstallOSM

func (td *OsmTestData) InstallOSM(instOpts InstallOSMOpts) error

InstallOSM installs OSM. The behavior of this function is dependant on installType and instOpts

func (*OsmTestData) LoadImagesToKind added in v0.7.0

func (td *OsmTestData) LoadImagesToKind(imageNames []string) error

LoadImagesToKind loads the list of images to the node for Kind clusters

func (*OsmTestData) LoadOSMImagesIntoKind added in v0.8.0

func (td *OsmTestData) LoadOSMImagesIntoKind() error

LoadOSMImagesIntoKind loads the OSM images to the node for Kind clusters

func (*OsmTestData) MultipleHTTPRequest

func (td *OsmTestData) MultipleHTTPRequest(requests *HTTPMultipleRequest) HTTPMultipleResults

MultipleHTTPRequest will issue a list of requests concurrently and return results when all requests have returned

func (*OsmTestData) PrettyPrintHTTPResults

func (td *OsmTestData) PrettyPrintHTTPResults(results *HTTPMultipleResults)

PrettyPrintHTTPResults prints pod results per namespace

func (*OsmTestData) RestartOSMController added in v0.7.0

func (td *OsmTestData) RestartOSMController(instOpts InstallOSMOpts) error

RestartOSMController restarts the osm-controller pod in the installed controller's namespace

func (*OsmTestData) RetryFuncOnError added in v0.8.0

func (td *OsmTestData) RetryFuncOnError(f RetryOnErrorFunc, retryTimes int, sleepBetweenRetries time.Duration) error

RetryFuncOnError runs the given function and retries for the given number of times if an error is encountered

func (*OsmTestData) RunLocal

func (td *OsmTestData) RunLocal(path string, args ...string) (*bytes.Buffer, *bytes.Buffer, error)

RunLocal Executes command on local

func (*OsmTestData) RunRemote

func (td *OsmTestData) RunRemote(
	ns string, podName string, containerName string,
	command []string) (string, string, error)

RunRemote runs command in remote container

func (*OsmTestData) SimpleDeploymentApp

SimpleDeploymentApp creates returns a set of k8s typed definitions for a deployment-based k8s definition. Includes Deployment, Service and ServiceAccount types

func (*OsmTestData) SimplePodApp

SimplePodApp returns a set of k8s typed definitions for a pod-based k8s definition. Includes Pod, Service and ServiceAccount types

func (*OsmTestData) SimpleServiceAccount added in v0.9.2

func (td *OsmTestData) SimpleServiceAccount(name string, namespace string) corev1.ServiceAccount

SimpleServiceAccount returns a k8s typed definition for a service account.

func (*OsmTestData) TCPRequest added in v0.7.0

func (td *OsmTestData) TCPRequest(req TCPRequestDef) TCPRequestResult

TCPRequest runs a synchronous TCP request to run the TCPRequestDef and return a TCPRequestResult

func (*OsmTestData) UpdateOSMConfig

func (td *OsmTestData) UpdateOSMConfig(meshConfig *configv1alpha2.MeshConfig) (*configv1alpha2.MeshConfig, error)

UpdateOSMConfig updates OSM MeshConfig

func (*OsmTestData) ValidateStringParams added in v0.8.1

func (td *OsmTestData) ValidateStringParams() error

ValidateStringParams validates input string parameters are valid

func (*OsmTestData) VerifyRestarts added in v0.8.1

func (td *OsmTestData) VerifyRestarts() bool

VerifyRestarts ensure no crashes on osm-namespace instances for OSM CTL processes

func (*OsmTestData) WaitForNamespacesDeleted

func (td *OsmTestData) WaitForNamespacesDeleted(namespaces []string, timeout time.Duration) error

WaitForNamespacesDeleted waits for the namespaces to be deleted. Reference impl taken from https://github.com/kubernetes/kubernetes/blob/master/test/e2e/framework/util.go#L258

func (*OsmTestData) WaitForPodsDeleted added in v0.9.0

func (td *OsmTestData) WaitForPodsDeleted(pods *corev1.PodList, namespace string, timeout time.Duration) error

WaitForPodsDeleted waits for the pods to be deleted.

func (*OsmTestData) WaitForPodsRunningReady

func (td *OsmTestData) WaitForPodsRunningReady(ns string, timeout time.Duration, nExpectedRunningPods int, labelSelector *metav1.LabelSelector) error

WaitForPodsRunningReady waits for a <n> number of pods on an NS to be running and ready `labelSelector` can be optionally passed to further select the pods to wait for

func (*OsmTestData) WaitForRepeatedSuccess

func (td *OsmTestData) WaitForRepeatedSuccess(f SuccessFunction, minItForSuccess int, maxWaitTime time.Duration) bool

WaitForRepeatedSuccess runs and expects a certain result for a certain operation a set number of consecutive times over a set amount of time.

func (*OsmTestData) WaitForSuccessAfterInitialFailure added in v0.11.0

func (td *OsmTestData) WaitForSuccessAfterInitialFailure(f SuccessFunction, minItForSuccess int, maxWaitTime time.Duration) bool

WaitForSuccessAfterInitialFailure runs and expects a certain result for a certain operation a set number of consecutive times but requires only success after the first success.

type PodCommand added in v1.1.1

type PodCommand []string

PodCommand describes a command for a pod

type Prometheus

type Prometheus struct {
	Client api.Client
	API    v1.API
	// contains filtered or unexported fields
}

Prometheus is a simple handler to represent a target Prometheus endpoint to run queries against

func (*Prometheus) GetCPULoadAvgforContainer

func (p *Prometheus) GetCPULoadAvgforContainer(ns string, podName string, containerName string,
	period time.Duration, t time.Time) (float64, error)

GetCPULoadAvgforContainer returns CPU load average for a period <duration> just before time <t>

func (*Prometheus) GetCPULoadsForContainer

func (p *Prometheus) GetCPULoadsForContainer(ns string, podName string, containerName string, t time.Time) (float64, float64, float64, error)

GetCPULoadsForContainer convenience wrapper to get 1m, 5m and 15m cpu loads for a resource

func (*Prometheus) GetMemRSSforContainer

func (p *Prometheus) GetMemRSSforContainer(ns string, podName string, containerName string, t time.Time) (float64, error)

GetMemRSSforContainer returns RSS memory footprint for a given NS/podname/containerName at a certain point in time

func (*Prometheus) GetNumEnvoysInMesh

func (p *Prometheus) GetNumEnvoysInMesh(t time.Time) (int, error)

GetNumEnvoysInMesh Gets the Number of in-mesh pods (or envoys) in the mesh as seen by prometheus at a certain point in time.

func (*Prometheus) Stop added in v0.7.0

func (p *Prometheus) Stop()

Stop gracefully stops the port forwarding to Prometheus

func (*Prometheus) VectorQuery

func (p *Prometheus) VectorQuery(query string, t time.Time) (float64, error)

VectorQuery runs a query at time <t>, expects single vector type and single result. Returns expected first and only <SampleValue> as a float64 Returns 0 and err<Empty result from prometheus>, if no values are seen on prometheus (but query did succeed)

type Resource added in v0.7.0

type Resource struct {
	Namespace     string
	PodName       string
	ContainerName string
}

Resource is used to store seen tracked resources during the test

type RetryOnErrorFunc added in v0.8.0

type RetryOnErrorFunc func() error

RetryOnErrorFunc is a function type passed to RetryFuncOnError() to execute

type SimpleAllowPolicy

type SimpleAllowPolicy struct {
	RouteGroupName string

	TrafficTargetName string

	SourceSVCAccountName string
	SourceNamespace      string

	DestinationSvcAccountName string
	DestinationNamespace      string
}

SimpleAllowPolicy is a simplified struct to later get basic SMI allow policy

type SimpleDeploymentAppDef

type SimpleDeploymentAppDef struct {
	Namespace          string
	DeploymentName     string
	ServiceName        string
	ContainerName      string
	ServiceAccountName string
	Image              string
	ReplicaCount       int32
	Command            PodCommand
	Args               []string
	Ports              []int
	AppProtocol        string
	OS                 string
	Labels             map[string]string
}

SimpleDeploymentAppDef defines some parametrization to create a deployment-based application from template

type SimplePodAppDef

type SimplePodAppDef struct {
	Namespace          string
	PodName            string
	ServiceName        string
	ServiceAccountName string
	ContainerName      string
	Image              string
	Command            []string
	Args               []string
	Ports              []int
	AppProtocol        string
	OS                 string
	Labels             map[string]string
}

SimplePodAppDef defines some parametrization to create a pod-based application from template

type SuccessFunction

type SuccessFunction func() bool

SuccessFunction is a simple definition for a success function. True as success, false otherwise

type TCPRequestDef added in v0.7.0

type TCPRequestDef struct {
	// Source pod where to run the HTTP request from
	SourceNs        string
	SourcePod       string
	SourceContainer string

	// The destination server host (FQDN or IP address) and port the request is directed to
	DestinationHost string
	DestinationPort int

	// Message to send as a part of the request
	Message string
}

TCPRequestDef defines a remote TCP request intent

type TCPRequestResult added in v0.7.0

type TCPRequestResult struct {
	Response string
	Err      error
}

TCPRequestResult represents the result of a TCPRequest call

type TrackedLabel added in v0.7.0

type TrackedLabel struct {
	Namespace string
	Label     metav1.LabelSelector
}

TrackedLabel defines resources to track and monitor during the test

type TrafficSplitBackend

type TrafficSplitBackend struct {
	Name   string
	Weight int
}

TrafficSplitBackend is a simple define to refer to a TrafficSplit backend

type TrafficSplitDef

type TrafficSplitDef struct {
	Name      string
	Namespace string

	TrafficSplitServiceName string
	Backends                []TrafficSplitBackend
}

TrafficSplitDef is a simplified struct to get a TrafficSplit typed definition

Jump to

Keyboard shortcuts

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