framework

package
v0.0.0-...-e8d3b3d Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2024 License: Apache-2.0 Imports: 54 Imported by: 1

Documentation

Index

Constants

View Source
const (
	PollNodesReadyTimeout   = 10 * time.Minute
	ClusterKey              = "machine.openshift.io/cluster-api-cluster"
	MachineSetKey           = "machine.openshift.io/cluster-api-machineset"
	MachineAPINamespace     = "openshift-machine-api"
	GlobalInfrastuctureName = "cluster"
	WorkerNodeRoleLabel     = "node-role.kubernetes.io/worker"
	RetryShort              = 1 * time.Second
	RetryMedium             = 5 * time.Second
	// DefaultMachineSetReplicas is the default number of replicas of a machineset
	// if MachineSet.Spec.Replicas field is set to nil.
	DefaultMachineSetReplicas  = 0
	MachinePhaseRunning        = "Running"
	MachinePhaseFailed         = "Failed"
	MachineRoleLabel           = "machine.openshift.io/cluster-api-machine-role"
	MachineTypeLabel           = "machine.openshift.io/cluster-api-machine-type"
	MachineAnnotationKey       = "machine.openshift.io/machine"
	ClusterAPIActuatorPkgTaint = "cluster-api-actuator-pkg"
)

Various constants used by E2E tests.

View Source
const (
	Amd64     = "amd64"
	ArchLabel = "e2e.openshift.io/arch"
)

Variables

View Source
var (
	WaitShort      = 1 * time.Minute
	WaitMedium     = 3 * time.Minute
	WaitOverMedium = 5 * time.Minute
	WaitLong       = 15 * time.Minute
	WaitOverLong   = 30 * time.Minute
)
View Source
var (
	LabelDisruptive            = ginkgo.Label("disruptive")
	LabelAutoscaler            = ginkgo.Label("autoscaler")
	LabelOperators             = ginkgo.Label("operators")
	LabelPeriodic              = ginkgo.Label("periodic")
	LabelSpot                  = ginkgo.Label("spot-instances")
	LabelMachines              = ginkgo.Label("machines")
	LabelMachineHealthChecks   = ginkgo.Label("machine-health-checks")
	LabelCloudProviderSpecific = ginkgo.Label("cloud-provider-specific")
	LabelProviderAWS           = ginkgo.Label("AWS")
)
View Source
var DefaultMutatingWebhookConfiguration = webhooks.NewMachineMutatingWebhookConfiguration()

DefaultMutatingWebhookConfiguration is a default mutating webhook configuration resource provided by MAO.

View Source
var DefaultValidatingWebhookConfiguration = webhooks.NewMachineValidatingWebhookConfiguration()

DefaultValidatingWebhookConfiguration is a default validating webhook configuration resource provided by MAO.

View Source
var (
	// ErrMachineNotProvisionedInsufficientCloudCapacity is used when we detect that the machine is not being provisioned due to insufficient provider capacity.
	ErrMachineNotProvisionedInsufficientCloudCapacity = errors.New("machine creation failed due to insufficient cloud provider capacity")
)

Functions

func AddNodeCondition

func AddNodeCondition(c runtimeclient.Client, node *corev1.Node, cond corev1.NodeCondition) error

AddNodeCondition adds a condition in the given Node's status.

func ConfigureClusterWideProxy

func ConfigureClusterWideProxy(c client.Client, gomegaArgs ...interface{})

ConfigureClusterWideProxy configures the Cluster-Wide Proxy to use the MITM Proxy.

func CreateMHC

CreateMHC creates a new MachineHealthCheck resource.

func CreateMachineSet

func CreateMachineSet(c runtimeclient.Client, params MachineSetParams) (*machinev1.MachineSet, error)

CreateMachineSet creates a new MachineSet resource.

func DeleteDaemonset

func DeleteDaemonset(ctx context.Context, c client.Client, deployment *kappsapi.DaemonSet) error

DeleteDaemonset deletes the specified deployment.

func DeleteDeployment

func DeleteDeployment(ctx context.Context, c client.Client, deployment *kappsapi.Deployment) error

DeleteDeployment deletes the specified deployment.

func DeleteMachineSets

func DeleteMachineSets(client runtimeclient.Client, machineSets ...*machinev1.MachineSet) error

DeleteMachineSets deletes the specified machinesets and returns an error on failure.

func DeleteMachines

func DeleteMachines(ctx context.Context, client runtimeclient.Client, machines ...*machinev1.Machine) error

DeleteMachines deletes the specified machines and returns an error on failure.

func DeleteMutatingWebhookConfiguration

func DeleteMutatingWebhookConfiguration(ctx context.Context, c client.Client, webhookConfiguraiton *admissionregistrationv1.MutatingWebhookConfiguration) error

DeleteMutatingWebhookConfiguration deletes the specified MutatingWebhookConfiguration object.

func DeleteProxy

func DeleteProxy(c client.Client, gomegaArgs ...interface{})

DeleteProxy delete the MITM Proxy from the cluster.

func DeleteValidatingWebhookConfiguration

func DeleteValidatingWebhookConfiguration(ctx context.Context, c client.Client, webhookConfiguraiton *admissionregistrationv1.ValidatingWebhookConfiguration) error

DeleteValidatingWebhookConfiguration deletes the specified ValidatingWebhookConfiguration object.

func DeployProxy

func DeployProxy(c client.Client, gomegaArgs ...interface{})

DeployProxy deploys a MITM Proxy to the cluster.

func DeploymentHasContainer

func DeploymentHasContainer(deployment *kappsapi.Deployment, containerName string) bool

DeploymentHasContainer returns true if the deployment has container with the specified name.

func FilterMachines

func FilterMachines(machines []*machinev1.Machine, phase string) []*machinev1.Machine

FilterMachines returns a slice of only those Machines in the input that are in the requested phase.

func FilterReadyNodes

func FilterReadyNodes(nodes []corev1.Node) []corev1.Node

FilterReadyNodes filters the list of nodes and returns a list with ready nodes.

func FilterRunningMachines

func FilterRunningMachines(machines []*machinev1.Machine) []*machinev1.Machine

FilterRunningMachines returns a slice of only those Machines in the input that are in the "Running" phase.

func FilterSchedulableNodes

func FilterSchedulableNodes(nodes []corev1.Node) []corev1.Node

FilterSchedulableNodes filters the list of nodes and returns a list with schedulable nodes.

func GetClusterAutoscaler

func GetClusterAutoscaler(client runtimeclient.Client, name string) (*caov1.ClusterAutoscaler, error)

GetClusterAutoscaler gets a ClusterAutoscaler by its name from the default machine API namespace.

func GetContext

func GetContext() context.Context

GetContext returns a context.

func GetDaemonset

func GetDaemonset(ctx context.Context, c client.Client, name, namespace string) (*kappsapi.DaemonSet, error)

GetDaemonset gets deployment object by name and namespace.

func GetDeployment

func GetDeployment(ctx context.Context, c client.Client, name, namespace string) (*kappsapi.Deployment, error)

GetDeployment gets deployment object by name and namespace.

func GetInfrastructure

func GetInfrastructure(ctx context.Context, c runtimeclient.Client) (*configv1.Infrastructure, error)

GetInfrastructure fetches the global cluster infrastructure object.

func GetMachine

func GetMachine(c runtimeclient.Client, name string) (*machinev1.Machine, error)

GetMachine get a machine by its name from the default machine API namespace.

func GetMachineFromNode

func GetMachineFromNode(client runtimeclient.Client, node *corev1.Node) (*machinev1.Machine, error)

GetMachineFromNode returns the Machine associated with the given node.

func GetMachineSet

func GetMachineSet(ctx context.Context, client runtimeclient.Client, name string) (*machinev1.MachineSet, error)

GetMachineSet gets a machineset by its name from the default machine API namespace.

func GetMachineSets

func GetMachineSets(client runtimeclient.Client, selectors ...*metav1.LabelSelector) ([]*machinev1.MachineSet, error)

GetMachineSets gets a list of machinesets from the default machine API namespace. Optionaly, labels may be used to constrain listed machinesets.

func GetMachines

func GetMachines(ctx context.Context, client runtimeclient.Client, selectors ...*metav1.LabelSelector) ([]*machinev1.Machine, error)

GetMachines gets a list of machinesets from the default machine API namespace. Optionaly, labels may be used to constrain listed machinesets.

func GetMachinesFromMachineSet

func GetMachinesFromMachineSet(ctx context.Context, client runtimeclient.Client, machineSet *machinev1.MachineSet) ([]*machinev1.Machine, error)

GetMachinesFromMachineSet returns an array of machines owned by a given machineSet.

func GetMutatingWebhookConfiguration

func GetMutatingWebhookConfiguration(ctx context.Context, c client.Client, name string) (*admissionregistrationv1.MutatingWebhookConfiguration, error)

GetMutatingWebhookConfiguration gets MutatingWebhookConfiguration object by name.

func GetNodeForMachine

func GetNodeForMachine(ctx context.Context, c runtimeclient.Client, m *machinev1.Machine) (*corev1.Node, error)

GetNodeForMachine retrieves the node backing the given Machine.

func GetNodes

func GetNodes(c runtimeclient.Client, selectors ...*metav1.LabelSelector) ([]corev1.Node, error)

GetNodes gets a list of nodes from a running cluster Optionaly, labels may be used to constrain listed nodes.

func GetNodesFromMachineSet

func GetNodesFromMachineSet(ctx context.Context, client runtimeclient.Client, machineSet *machinev1.MachineSet) ([]*corev1.Node, error)

GetNodesFromMachineSet returns an array of nodes backed by machines owned by a given machineSet.

func GetPlatform

GetPlatform fetches the PlatformType from the infrastructure object. Caches value after first successful retrieval.

func GetPods

func GetPods(client runtimeclient.Client, selector map[string]string) (*corev1.PodList, error)

GetPods returns a list of pods matching the provided selector.

func GetReadyAndSchedulableNodes

func GetReadyAndSchedulableNodes(c runtimeclient.Client) ([]corev1.Node, error)

GetReadyAndSchedulableNodes returns all the nodes that have the Ready condition and can schedule workloads.

func GetService

func GetService(ctx context.Context, c runtimeclient.Client, name, namespace string) (*corev1.Service, error)

GetService gets service object by name and namespace.

func GetServices

func GetServices(ctx context.Context, client runtimeclient.Client, selector map[string]string) (*corev1.ServiceList, error)

GetServices returns a list of services matching the provided selector.

func GetValidatingWebhookConfiguration

func GetValidatingWebhookConfiguration(ctx context.Context, c client.Client, name string) (*admissionregistrationv1.ValidatingWebhookConfiguration, error)

GetValidatingWebhookConfiguration gets ValidatingWebhookConfiguration object by name.

func GetWorkerMachineSets

func GetWorkerMachineSets(ctx context.Context, client runtimeclient.Client) ([]*machinev1.MachineSet, error)

GetWorkerMachineSets returns the MachineSets that label their Machines with the "worker" role.

func GetWorkerNodes

func GetWorkerNodes(c runtimeclient.Client) ([]corev1.Node, error)

GetWorkerNodes returns all nodes with the nodeWorkerRoleLabel label.

func IsDaemonsetAvailable

func IsDaemonsetAvailable(ctx context.Context, c client.Client, name, namespace string) bool

IsDaemonsetAvailable returns true if the deployment has one or more available replicas.

func IsDeploymentAvailable

func IsDeploymentAvailable(ctx context.Context, c client.Client, name, namespace string) bool

IsDeploymentAvailable returns true if the deployment has one or more available replicas.

func IsDeploymentSynced

func IsDeploymentSynced(ctx context.Context, c client.Client, dep *kappsapi.Deployment, name, namespace string) bool

IsDeploymentSynced returns true if provided deployment spec matched one found on cluster.

func IsMutatingWebhookConfigurationSynced

func IsMutatingWebhookConfigurationSynced(ctx context.Context, c client.Client) bool

IsMutatingWebhookConfigurationSynced expects a matching MutatingWebhookConfiguration to be present in the cluster.

func IsNodeReady

func IsNodeReady(node *corev1.Node) bool

IsNodeReady returns true if the given node is ready.

func IsNodeSchedulable

func IsNodeSchedulable(node *corev1.Node) bool

IsNodeSchedulable returns true is the given node can schedule workloads.

func IsServiceAvailable

func IsServiceAvailable(ctx context.Context, c runtimeclient.Client, name, namespace string) bool

IsServiceAvailable returns true if the service exists.

func IsValidatingWebhookConfigurationSynced

func IsValidatingWebhookConfigurationSynced(ctx context.Context, c client.Client) bool

IsValidatingWebhookConfigurationSynced expects a matching MutatingWebhookConfiguration to be present in the cluster.

func LoadClient

func LoadClient() (runtimeclient.Client, error)

LoadClient returns a new controller-runtime client.

func LoadClientset

func LoadClientset() (*kubernetes.Clientset, error)

LoadClientset returns a new Kubernetes Clientset.

func MachinesPresent

func MachinesPresent(existingMachines []*machinev1.Machine, machines ...*machinev1.Machine) bool

MachinesPresent search for each provided machine in `machines` argument in the predefined `existingMachines` list and returns true when all of them were found.

func NewCLI

func NewCLI() (*gatherer.CLI, error)

NewCLI initializes oc binary wrapper helper. Output and oc executable path configure depending on the environment. If Openshift CI is detected, respective parameters are set up.

func NewGatherer

func NewGatherer() (*gatherer.StateGatherer, error)

NewGatherer initializes StateGatherer - helper for collection of MAPI-related resources and pod logs in tests.

func NewMachineSet

func NewMachineSet(
	clusterName, namespace, name string,
	selectorLabels map[string]string,
	templateLabels map[string]string,
	providerSpec *machinev1.ProviderSpec,
	replicas int32,
) *machinev1.MachineSet

NewMachineSet returns a new MachineSet object.

func NewWorkLoad

func NewWorkLoad(njobs int32, memoryRequest resource.Quantity, workloadJobName string,
	testLabel string, podLabel string, nodeSelectorReqs ...corev1.NodeSelectorRequirement) *batchv1.Job

func NodesAreReady

func NodesAreReady(nodes []*corev1.Node) bool

NodesAreReady returns true if an array of nodes are all ready.

func RunCheckUntil

func RunCheckUntil(ctx context.Context, check, condition func(context.Context, GomegaAssertions) bool) bool

RunCheckUntil runs the check function until the condition succeeds or the context is cancelled. If the check fails before the condition succeeds, the test will fail. The check and condition functions must use the passed Gomega for any assertions so that we can handle failures within the functions appropriately.

func RunPodOnNode

func RunPodOnNode(clientset *kubernetes.Clientset, node *corev1.Node, namespace string, podSpec corev1.PodSpec) (*corev1.Pod, PodLastLogFunc, PodCleanupFunc, error)

RunPodOnNode runs a pod according passed spec on particular node. returns created pod object, function for retrieve last logs, cleanup function and error if occurred.

func ScaleMachineSet

func ScaleMachineSet(name string, replicas int) error

ScaleMachineSet scales a machineSet with a given name to the given number of replicas.

func UnconfigureClusterWideProxy

func UnconfigureClusterWideProxy(c client.Client, gomegaArgs ...interface{})

UnconfigureClusterWideProxy configures the Cluster-Wide Proxy to stop using the MITM Proxy.

func UpdateDaemonset

func UpdateDaemonset(ctx context.Context, c client.Client, name, namespace string, updated *kappsapi.DaemonSet) error

UpdateDaemonset updates the specified deployment.

func UpdateDeployment

func UpdateDeployment(ctx context.Context, c client.Client, name, namespace string, updated *kappsapi.Deployment) error

UpdateDeployment updates the specified deployment.

func UpdateMutatingWebhookConfiguration

func UpdateMutatingWebhookConfiguration(ctx context.Context, c client.Client, updated *admissionregistrationv1.MutatingWebhookConfiguration) error

UpdateMutatingWebhookConfiguration updates the specified mutating webhook configuration.

func UpdateValidatingWebhookConfiguration

func UpdateValidatingWebhookConfiguration(ctx context.Context, c client.Client, updated *admissionregistrationv1.ValidatingWebhookConfiguration) error

UpdateValidatingWebhookConfiguration updates the specified mutating webhook configuration.

func VerifyNodeDraining

func VerifyNodeDraining(ctx context.Context, client runtimeclient.Client, targetMachine *machinev1.Machine, rc *corev1.ReplicationController) (string, error)

func WaitForEvent

func WaitForEvent(ctx context.Context, c runtimeclient.Client, kind, name, reason string) error

WaitForEvent expects to find the given event.

func WaitForMachineSet

func WaitForMachineSet(ctx context.Context, c runtimeclient.Client, name string)

WaitForMachineSet waits for the all Machines belonging to the named MachineSet to enter the "Running" phase, and for all nodes belonging to those Machines to be ready. If a Machine is detected in "Failed" phase, the test will exit early.

func WaitForMachineSetsDeleted

func WaitForMachineSetsDeleted(ctx context.Context, c runtimeclient.Client, machineSets ...*machinev1.MachineSet)

WaitForMachineSetsDeleted polls until the given MachineSets are not found, and there are zero Machines found matching the MachineSet's label selector.

func WaitForMachinesDeleted

func WaitForMachinesDeleted(c runtimeclient.Client, machines ...*machinev1.Machine)

WaitForMachinesDeleted polls until the given Machines are not found.

func WaitForSpotMachineSet

func WaitForSpotMachineSet(ctx context.Context, c runtimeclient.Client, name string) error

WaitForSpotMachineSet waits for all Machines belonging to the machineSet to be running and their nodes to be ready. Unlike WaitForMachineSet, this function does not fail the test when machine cannoct be provisioned due to insufficient spot capacity.

func WaitForStatusAvailableMedium

func WaitForStatusAvailableMedium(ctx context.Context, client runtimeclient.Client, name string) bool

func WaitForStatusAvailableOverLong

func WaitForStatusAvailableOverLong(ctx context.Context, client runtimeclient.Client, name string) bool

func WaitForStatusAvailableShort

func WaitForStatusAvailableShort(ctx context.Context, client runtimeclient.Client, name string) bool

func WaitForValidatingWebhook

func WaitForValidatingWebhook(ctx context.Context, client runtimeclient.Client, name string) bool

func WaitUntilAllNodesAreReady

func WaitUntilAllNodesAreReady(ctx context.Context, client runtimeclient.Client) error

WaitUntilAllNodesAreReady lists all nodes and waits until they are ready.

func WaitUntilAllRCPodsAreReady

func WaitUntilAllRCPodsAreReady(ctx context.Context, client runtimeclient.Client, rc *corev1.ReplicationController) error

func WaitUntilNodeDoesNotExists

func WaitUntilNodeDoesNotExists(ctx context.Context, client runtimeclient.Client, nodeName string) error

Types

type GomegaAssertions

type GomegaAssertions interface {
	Ω(actual interface{}, extra ...interface{}) gomega.Assertion //nolint:asciicheck
	Expect(actual interface{}, extra ...interface{}) gomega.Assertion
	ExpectWithOffset(offset int, actual interface{}, extra ...interface{}) gomega.Assertion
}

GomegaAssertions is a subset of the gomega.Gomega interface. It is the set allowed for checks and conditions in the RunCheckUntil helper function.

type MachineHealthCheckParams

type MachineHealthCheckParams struct {
	Name         string
	Labels       map[string]string
	Conditions   []machinev1.UnhealthyCondition
	MaxUnhealthy *int
}

MachineHealthCheckParams represents the parameters for creating a new MachineHealthCheck resource for use in tests.

type MachineSetParams

type MachineSetParams struct {
	Name         string
	Replicas     int32
	Labels       map[string]string
	Taints       []corev1.Taint
	ProviderSpec *machinev1.ProviderSpec
}

MachineSetParams represents the parameters for creating a new MachineSet resource for use in tests.

func BuildAlternativeMachineSetParams

func BuildAlternativeMachineSetParams(machineSetParams MachineSetParams, platform configv1.PlatformType) ([]MachineSetParams, error)

BuildMachineSetParamsList creates a list of MachineSetParams based on the given machineSetParams with modified instance type.

func BuildMachineSetParams

func BuildMachineSetParams(ctx context.Context, client runtimeclient.Client, replicas int) MachineSetParams

BuildMachineSetParams builds a MachineSetParams object from the first worker MachineSet retrieved from the cluster.

func BuildPerArchMachineSetParamsList

func BuildPerArchMachineSetParamsList(ctx context.Context, client runtimeclient.Client, replicas int) []MachineSetParams

BuildPerArchMachineSetParamsList builds a list of MachineSetParams for each architecture in the cluster. Given a cluster with N machinesets, and M <= N total different architectures, this function will return M MachineSetParams.

type PodCleanupFunc

type PodCleanupFunc func() error

type PodLastLogFunc

type PodLastLogFunc func(container string, lines int, previous bool) (string, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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