framework

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2020 License: Apache-2.0 Imports: 60 Imported by: 0

Documentation

Index

Constants

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

	// OsmControllerAppLabel is the OSM Controller deployment app label
	OsmControllerAppLabel = "osm-controller"
	// 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 (
	// StatusCodeWord is an identifier used on curl commands to print and parse REST Status codes
	StatusCodeWord = "StatusCode"
)

Variables

This section is empty.

Functions

func OSMDescribe

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

OSMDescribe givens the description of an e2e test

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 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 Grafana

type Grafana struct {
	Schema   string
	Hostname string
	Port     uint16
	User     string
	Password string
}

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.

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

	VaultHost     string
	VaultProtocol string
	VaultToken    string
	VaultRole     string

	CertmanagerIssuerGroup string
	CertmanagerIssuerKind  string
	CertmanagerIssuerName  string

	EgressEnabled        bool
	EnablePermissiveMode bool
	EnvoyLogLevel        string
	EnableDebugServer    bool
}

InstallOSMOpts describes install options 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"
)

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
}

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      GinkgoTInterface // for common test logging
	TestID uint64           // uint randomized for every test. GinkgoRandomSeed can't be used as is per-suite.

	CleanupTest    bool // Cleanup test-related resources once finished
	WaitForCleanup bool // Forces test to wait for effective deletion of resources upon cleanup

	// OSM install-time variables
	InstType          InstallType // Install type.
	OsmNamespace      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

	// Cluster handles and rest config
	Env             *cli.EnvSettings
	RestConfig      *rest.Config
	Client          *kubernetes.Clientset
	SmiClients      *smiClients
	ClusterProvider *cluster.Provider // provider, used when kindCluster is used
}

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(sidecardInject bool, ns ...string) error

AddNsToMesh Adds monitored namespaces to the OSM mesh

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 resorces once the test is done

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 Route Group

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

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) CreateSimpleTrafficSplit

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

CreateSimpleTrafficSplit Creates an SMI TrafficTarget

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) GetConfigMap

func (td *OsmTestData) GetConfigMap(name, namespace string) (*corev1.ConfigMap, error)

GetConfigMap is a wrapper to get a config map by name in a particular namespace

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) GetMutatingWebhook

func (td *OsmTestData) GetMutatingWebhook(mwhcName string) (*v1beta1.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() InstallOSMOpts

GetOSMInstallOpts initializes install options for OSM

func (*OsmTestData) GetOSMPrometheusaHandle

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

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

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) GetTestFile

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

GetTestFile prefixes a filename with current test folder (based on current test ID calling this API) and creates the test folder for current test if it doesn't exists. Only if some part of a test calls this function the test folder will be created, otherwise nothing is created to avoid extra clutter.

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) 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 Gingkgo BeforeEach

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) 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) 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 creates returns a set of k8s typed definitions for a pod-based k8s definition. Includes Pod, Service and ServiceAccount types

func (*OsmTestData) UpdateOSMConfig

func (td *OsmTestData) UpdateOSMConfig(key, value string) error

UpdateOSMConfig updates OSM configmap

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) WaitForPodsRunningReady

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

WaitForPodsRunningReady waits for a <n> number of pods on an NS to be running and ready

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.

type Prometheus

type Prometheus struct {
	Client api.Client
	API    v1.API
}

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, minutesBucket int) (float64, error)

GetCPULoadAvgforContainer returns CPU load average value for the time bucket passed as parametres, in minutes

func (*Prometheus) GetCPULoadsForContainer

func (p *Prometheus) GetCPULoadsForContainer(ns string, podName string, containerName string) (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) (float64, error)

GetMemRSSforContainer returns RSS memory footprint for a given NS/podname/containerName

func (*Prometheus) GetNumEnvoysInMesh

func (p *Prometheus) GetNumEnvoysInMesh() (float64, error)

GetNumEnvoysInMesh Gets the Number of in-mesh pods (or envoys) in the mesh as seen by 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

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
	Name         string
	Image        string
	ReplicaCount int32
	Command      []string
	Args         []string
	Ports        []int
}

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

type SimplePodAppDef

type SimplePodAppDef struct {
	Namespace string
	Name      string
	Image     string
	Command   []string
	Args      []string
	Ports     []int
}

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 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