framework

package
v0.0.0-...-42228d0 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2019 License: Apache-2.0 Imports: 42 Imported by: 0

Documentation

Index

Constants

View Source
const (
	WorkerNodeRoleLabel = "node-role.kubernetes.io/worker"
	WaitShort           = 1 * time.Minute
	WaitMedium          = 3 * time.Minute
	WaitLong            = 10 * time.Minute
	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
)
View Source
const (
	// Default timeout for pools
	PoolTimeout = 5 * time.Minute
	// Default waiting interval for pools
	PollInterval = 5 * time.Second
	// Node waiting internal
	PollNodeInterval = 5 * time.Second
	// Pool timeout for cluster API deployment
	PoolClusterAPIDeploymentTimeout = 10 * time.Minute
	PoolDeletionTimeout             = 1 * time.Minute
	// Pool timeout for kubeconfig
	PoolKubeConfigTimeout = 10 * time.Minute
	PoolNodesReadyTimeout = 10 * time.Minute
	// Instances are running timeout
	TimeoutPoolMachineRunningInterval = 10 * time.Minute
)
View Source
const (
	// KubeletKillerPodName contains the name of the pod that stops kubelet process
	KubeletKillerPodName = "kubelet-killer"
	// MachineHealthCheckName contains the name of the machinehealthcheck used for tests
	MachineHealthCheckName = "workers-check"
)

Variables

View Source
var ClusterID string

ClusterID set by -cluster-id flag

Functions

func CreateMachineHealthCheck

func CreateMachineHealthCheck(labels map[string]string) error

CreateMachineHealthCheck will create MachineHealthCheck CR with the relevant selector

func CreateUnhealthyConditionsConfigMap

func CreateUnhealthyConditionsConfigMap(unhealthyConditions *conditions.UnhealthyConditions) error

CreateUnhealthyConditionsConfigMap creates node-unhealthy-conditions configmap with relevant conditions

func DeleteObjectsByLabels

func DeleteObjectsByLabels(ctx context.Context, client runtimeclient.Client, labels map[string]string, list runtime.Object) error

DeleteObjectsByLabels list all objects of a given kind by labels and deletes them. Currently supported kinds: - caov1beta1.MachineAutoscalerList - caov1.ClusterAutoscalerList - batchv1.JobList

func DeleteUnhealthyConditionsConfigMap

func DeleteUnhealthyConditionsConfigMap() error

DeleteUnhealthyConditionsConfigMap deletes node-unhealthy-conditions configmap

func FilterReadyNodes

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

FilterReadyNodes fileter the list of nodes and returns the list with ready nodes

func GetMachine

func GetMachine(ctx context.Context, client runtimeclient.Client, machineName string) (*mapiv1beta1.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) (*mapiv1beta1.Machine, error)

GetMachineFromNode returns the machine referenced by the "controllernode.MachineAnnotationKey" annotation in the given node

func GetMachineSet

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

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

func GetMachineSets

func GetMachineSets(ctx context.Context, client runtimeclient.Client, labels ...map[string]string) ([]mapiv1beta1.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, labels ...map[string]string) ([]mapiv1beta1.Machine, error)

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

func GetNodes

func GetNodes(client runtimeclient.Client, labels ...map[string]string) ([]corev1.Node, error)

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

func GetWorkerNodes

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

GetWorkerNodes returns all nodes with the nodeWorkerRoleLabel label

func IsKubemarkProvider

func IsKubemarkProvider(client runtimeclient.Client) (bool, error)

func IsNodeReady

func IsNodeReady(node *corev1.Node) bool

func LoadClient

func LoadClient() (runtimeclient.Client, error)

LoadClient builds controller runtime client that accepts any registered type

func LoadClientset

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

func LoadConfig

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

LoadConfig builds config from kubernetes config

func LoadPrivateKey

func LoadPrivateKey(prkey string) (ssh.Signer, error)

func ReadKubeconfigFromServer

func ReadKubeconfigFromServer(sshConfig *SSHConfig) (string, error)

func RestclientConfig

func RestclientConfig() (*clientcmdapi.Config, error)

RestclientConfig builds a REST client config

func SigKubeDescribe

func SigKubeDescribe(text string, body func()) bool

SigKubeDescribe is a wrapper function for ginkgo describe. Adds namespacing.

func StopKubelet

func StopKubelet(nodeName string) error

StopKubelet creates pod in the node PID namespace that stops kubelet process

func WaitUntilAllNodesAreReady

func WaitUntilAllNodesAreReady(client runtimeclient.Client) error

func WaitUntilCreated

func WaitUntilCreated(createFnc func() error, getFnc func() error) error

func WaitUntilDeleted

func WaitUntilDeleted(delFnc func() error, getFnc func() error) error

Types

type ByFnc

type ByFnc func(string)

type ErrNotExpectedFnc

type ErrNotExpectedFnc func(error)

type Framework

type Framework struct {
	KubeClient           *kubernetes.Clientset
	CAPIClient           *clientset.Clientset
	APIExtensionClient   *apiextensionsclientset.Clientset
	HealthCheckingClient *healthcheckingclient.Clientset

	// APIRegistrationClient *apiregistrationclientset.Clientset
	Kubeconfig string
	RestConfig *rest.Config

	SSH *SSHConfig

	LibvirtURI string
	LibvirtPK  string

	MachineControllerImage  string
	MachineManagerImage     string
	NodelinkControllerImage string

	ErrNotExpected ErrNotExpectedFnc
	By             ByFnc
}

Framework supports common operations used by tests

func NewFramework

func NewFramework() (*Framework, error)

NewFramework setups a new framework

func NewFrameworkFromConfig

func NewFrameworkFromConfig(config *rest.Config, sshConfig *SSHConfig) (*Framework, error)

func (*Framework) BeforeEach

func (f *Framework) BeforeEach()

BeforeEach to be run before each spec responsible for building various clientsets

func (*Framework) CreateClusterAndWait

func (f *Framework) CreateClusterAndWait(cluster *clusterv1alpha1.Cluster)

func (*Framework) CreateMachineAndWait

func (f *Framework) CreateMachineAndWait(machine *machinev1beta1.Machine, client types.CloudProviderClient)

func (*Framework) CreateMachineSetAndWait

func (f *Framework) CreateMachineSetAndWait(machineset *machinev1beta1.MachineSet, client types.CloudProviderClient)

func (*Framework) DefaultBy

func (f *Framework) DefaultBy(msg string)

func (*Framework) DefaultErrNotExpected

func (f *Framework) DefaultErrNotExpected(err error)

func (*Framework) DeleteMachineAndWait

func (f *Framework) DeleteMachineAndWait(machine *machinev1beta1.Machine, client types.CloudProviderClient)

func (*Framework) DeleteMachineSetAndWait

func (f *Framework) DeleteMachineSetAndWait(machineset *machinev1beta1.MachineSet, client types.CloudProviderClient) error

func (*Framework) DeployClusterAPIStack

func (f *Framework) DeployClusterAPIStack(clusterAPINamespace, actuatorPrivateKey string)

func (*Framework) DestroyClusterAPIStack

func (f *Framework) DestroyClusterAPIStack(clusterAPINamespace, actuatorPrivateKey string)

func (*Framework) GetMasterMachineRestConfig

func (f *Framework) GetMasterMachineRestConfig(masterMachine *machinev1beta1.Machine, client types.CloudProviderClient) (*rest.Config, error)

func (*Framework) IgnoreNotFoundErr

func (f *Framework) IgnoreNotFoundErr(err error)

IgnoreNotFoundErr ignores not found errors in case resource that does not exist is to be deleted

func (*Framework) ScaleDeploymentDownToZero

func (f *Framework) ScaleDeploymentDownToZero(deployment *appsv1beta2.Deployment) error

func (*Framework) ScaleSatefulSetDownToZero

func (f *Framework) ScaleSatefulSetDownToZero(statefulset *appsv1beta2.StatefulSet) error

func (*Framework) UploadDockerImageToInstance

func (f *Framework) UploadDockerImageToInstance(image, targetMachine string) error

func (*Framework) WaitForNodesToGetReady

func (f *Framework) WaitForNodesToGetReady(count int) error

type MachinesToDelete

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

func InitMachinesToDelete

func InitMachinesToDelete() *MachinesToDelete

func (*MachinesToDelete) AddMachine

func (m *MachinesToDelete) AddMachine(machine *machinev1beta1.Machine, framework *Framework, client types.CloudProviderClient)

func (*MachinesToDelete) AddMachineSet

func (m *MachinesToDelete) AddMachineSet(machineset *machinev1beta1.MachineSet, framework *Framework, client types.CloudProviderClient)

func (*MachinesToDelete) Delete

func (m *MachinesToDelete) Delete()

type SSHConfig

type SSHConfig struct {
	Key  string
	User string
	Host string
}

func DefaultSSHConfig

func DefaultSSHConfig() (*SSHConfig, error)

type TestContextType

type TestContextType struct {
	KubeConfig          string
	MachineApiNamespace string
	Host                string
}
var TestContext TestContextType

Jump to

Keyboard shortcuts

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