framework

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2024 License: Apache-2.0 Imports: 32 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// PrometheusLabelKey provides the label to indicate prometheus metrics are available in the pods.
	PrometheusLabelKey = "prometheus.aaq.kubevirt.io"
	// PrometheusLabelValue provides the label value which shouldn't be empty to avoid a prometheus WIP issue.
	PrometheusLabelValue = "true"
	// HonorWaitForFirstConsumer - if enabled will not schedule worker pods on a storage with WaitForFirstConsumer binding mode
	HonorWaitForFirstConsumer = "HonorWaitForFirstConsumer"

	//NsPrefixLabel provides a aaq prefix label to identify the test namespace
	NsPrefixLabel = "aaq-e2e"
)

Variables

View Source
var (
	ClientsInstance = &Clients{}
)

run-time flags

Functions

func DeleteNS

func DeleteNS(c *kubernetes.Clientset, ns string) error

DeleteNS provides a function to delete the specified namespace from the test cluster

func GetKubeClientFromRESTConfig

func GetKubeClientFromRESTConfig(config *rest.Config) (*kubernetes.Clientset, error)

GetKubeClientFromRESTConfig provides a function to get a K8s client using hte REST config

func IsOpenshift

func IsOpenshift(client kubernetes.Interface) bool

IsOpenshift checks if we are on OpenShift platform

Types

type Clients

type Clients struct {
	KubectlPath  string
	OcPath       string
	AAQInstallNs string
	KubeConfig   string
	KubeURL      string
	GoCLIPath    string
	DockerPrefix string
	DockerTag    string

	//  k8sClient provides our k8s client pointer
	K8sClient *kubernetes.Clientset
	// AaqClient provides our AAQ client pointer
	AaqClient *aaqclientset.Clientset
	// CrClient is a controller runtime client
	CrClient crclient.Client
	// RestConfig provides a pointer to our REST client config.
	RestConfig *rest.Config
	// DynamicClient performs generic operations on arbitrary k8s API objects.
	DynamicClient dynamic.Interface
}

Clients is the struct containing the client-go kubernetes clients

func (*Clients) GetAaqClient

func (c *Clients) GetAaqClient() (*clientset.Clientset, error)

GetMtqClient gets an instance of a kubernetes client that includes all the MTQ extensions.

func (*Clients) GetCrClient

func (c *Clients) GetCrClient() (crclient.Client, error)

GetCrClient returns a controller runtime client

func (*Clients) GetDynamicClient

func (c *Clients) GetDynamicClient() (dynamic.Interface, error)

GetDynamicClient gets an instance of a dynamic client that performs generic operations on arbitrary k8s API objects.

func (*Clients) GetKubeClient

func (c *Clients) GetKubeClient() (*kubernetes.Clientset, error)

GetKubeClient returns a Kubernetes rest client

func (*Clients) GetVirtClient

func (c *Clients) GetVirtClient() (*virtclientset.Clientset, error)

func (*Clients) LoadConfig

func (c *Clients) LoadConfig() (*rest.Config, error)

LoadConfig loads our specified kubeconfig

type Config

type Config struct {
	// SkipNamespaceCreation sets whether to skip creating a namespace. Use this ONLY for tests that do not require
	// a namespace at all, like basic sanity or other global tests.
	SkipNamespaceCreation bool

	// FeatureGates may be overridden for a framework
	FeatureGates []string
}

Config provides some basic test config options

type Framework

type Framework struct {
	Config
	// NsPrefix is a prefix for generated namespace
	NsPrefix string
	// Namespace provides a namespace for each test generated/unique ns per test
	Namespace *v1.Namespace

	*Clients
	// contains filtered or unexported fields
}

Framework supports common operations used by functional/e2e tests. It holds the k8s and AAQ clients, a generated unique namespace, run-time flags, and more fields will be added over time as AAQ e2e evolves. Global BeforeEach and AfterEach are called in the Framework constructor.

func NewFramework

func NewFramework(prefix string, config ...Config) *Framework

NewFramework calls NewFramework and handles errors by calling Fail. Config is optional, but if passed there can only be one. To understand the order in which things are run, read http://onsi.github.io/ginkgo/#understanding-ginkgos-lifecycle flag parsing happens AFTER ginkgo has constructed the entire testing tree. So anything that uses information from flags cannot work when called during test tree construction.

func (*Framework) AddNamespaceToDelete

func (f *Framework) AddNamespaceToDelete(ns *v1.Namespace)

AddNamespaceToDelete provides a wrapper around the go append function

func (*Framework) AfterEach

func (f *Framework) AfterEach()

AfterEach provides a set of operations to run after each test

func (*Framework) BeforeEach

func (f *Framework) BeforeEach()

BeforeEach provides a set of operations to run before each test

func (*Framework) CreateKubectlCommand

func (f *Framework) CreateKubectlCommand(args ...string) *exec.Cmd

CreateKubectlCommand returns the Cmd to execute kubectl

func (*Framework) CreateNamespace

func (f *Framework) CreateNamespace(prefix string, labels map[string]string) (*v1.Namespace, error)

CreateNamespace instantiates a new namespace object with a unique name and the passed-in label(s).

func (*Framework) CreatePrometheusServiceInNs

func (f *Framework) CreatePrometheusServiceInNs(namespace string) (*v1.Service, error)

CreatePrometheusServiceInNs creates a service for prometheus in the specified namespace. This allows us to test for prometheus end points using the service to connect to the endpoints.

func (*Framework) ExpectEvent

func (f *Framework) ExpectEvent(ns string) gomega.AsyncAssertion

ExpectEvent polls and fetches events during a defined period of time

func (*Framework) GetNodePlacementValuesWithRandomNodeAffinity

func (f *Framework) GetNodePlacementValuesWithRandomNodeAffinity(nodeSelectorTestValue map[string]string, tolerationTestValue []v1.Toleration) sdkapi.NodePlacement

func (*Framework) GetRESTConfig

func (f *Framework) GetRESTConfig(namespace, name string) (*rest.Config, error)

GetRESTConfig returns a RESTConfig

func (*Framework) GetToken

func (f *Framework) GetToken(namespace, name string) (string, error)

GetToken returns a token for a given SA

func (*Framework) PodSpecHasTestNodePlacementValues

func (f *Framework) PodSpecHasTestNodePlacementValues(podSpec v1.PodSpec, nodePlacement sdkapi.NodePlacement) error

PodSpecHasTestNodePlacementValues compares if the pod spec has the set of node placement values defined for testing purposes

func (*Framework) RunKubectlCommand

func (f *Framework) RunKubectlCommand(args ...string) (string, error)

RunKubectlCommand runs a kubectl Cmd and returns output and err

type KubernetesReporter

type KubernetesReporter struct {
	FailureCount int
	// contains filtered or unexported fields
}

KubernetesReporter is the struct that holds the report info.

func NewKubernetesReporter

func NewKubernetesReporter() *KubernetesReporter

NewKubernetesReporter creates a new instance of the reporter.

func (*KubernetesReporter) Cleanup

func (r *KubernetesReporter) Cleanup()

Cleanup cleans up the current content of the artifactsDir

func (*KubernetesReporter) Dump

func (r *KubernetesReporter) Dump(kubeCli *kubernetes.Clientset, since time.Duration)

Dump dumps the current state of the cluster. The relevant logs are collected starting from the since parameter.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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