framework

package
v1.48.1 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2022 License: Apache-2.0, BSD-2-Clause, MIT, + 1 more Imports: 65 Imported by: 19

Documentation

Index

Constants

View Source
const (

	// KubeconfigSecretKeyName ist the name of the key in a secret that holds the kubeconfig of a shoot
	KubeconfigSecretKeyName = "kubeconfig"

	// IntegrationTestPrefix is the default prefix that will be used for test shoots if none other is specified
	IntegrationTestPrefix = "itest-"

	// WorkerNamePrefix is the default prefix that will be used for Shoot workers
	WorkerNamePrefix = "worker-"

	// TestMachineryKubeconfigsPathEnvVarName is the name of the environment variable that holds the path to the
	// testmachinery provided kubeconfigs.
	TestMachineryKubeconfigsPathEnvVarName = "TM_KUBECONFIG_PATH"

	// TestMachineryTestRunIDEnvVarName is the name of the environment variable that holds the testrun ID.
	TestMachineryTestRunIDEnvVarName = "TM_TESTRUN_ID"

	// SeedTaintTestRun is the taint used to limit shoots that can be scheduled on a seed to shoots created by the same testrun.
	SeedTaintTestRun = "test.gardener.cloud/test-run"
)

Variables

View Source
var (
	// ErrNoRepositoriesFound no repositories found in repository file
	ErrNoRepositoriesFound = errors.New("no repositories found in repository file")

	// ErrNoInternalIPsForNodeWasFound no internal IPs were found for node
	ErrNoInternalIPsForNodeWasFound = errors.New("no internal IPs were found for node")

	// ErrNoRunningPodsFound no running pods were found
	ErrNoRunningPodsFound = errors.New("no running pods were found")
)

Functions

func AddWorker

func AddWorker(shoot *gardencorev1beta1.Shoot, cloudProfile *gardencorev1beta1.CloudProfile, machineImage gardencorev1beta1.MachineImage, workerZone string) error

AddWorker adds a valid default worker to the shoot for the given machineImage and CloudProfile.

func ApplyFilters

func ApplyFilters(event corev1.Event, filters ...EventFilterFunc) bool

ApplyFilters checks if one of the EventFilters filters the current event

func BuildSeedSpecForTestrun added in v1.20.0

func BuildSeedSpecForTestrun(name string, backupProvider *string) *gardencorev1beta1.SeedSpec

BuildSeedSpecForTestrun builds a minimal seed spec to be used during testing

func CAfterEach

func CAfterEach(body func(context.Context), timeout time.Duration)

CAfterEach contextifies Gingko's AfterEach

func CAfterSuite

func CAfterSuite(body func(context.Context), timeout time.Duration)

CAfterSuite contextifies Gingko's FIt

func CBeforeEach

func CBeforeEach(body func(ctx context.Context), timeout time.Duration)

CBeforeEach contextifies Gingko's BeforeEach

func CBeforeSuite

func CBeforeSuite(body func(context.Context), timeout time.Duration)

CBeforeSuite contextifies Gingko's FIt

func CIt

func CIt(text string, body func(context.Context), timeout time.Duration)

CIt contextifies Gingko's It

func CJustBeforeEach

func CJustBeforeEach(body func(ctx context.Context), timeout time.Duration)

CJustBeforeEach contextifies Gingko's JustBeforeEach

func CommonAfterSuite

func CommonAfterSuite()

CommonAfterSuite performs necessary common steps after all tests of a suite a run

func ComputeTechnicalID added in v1.13.0

func ComputeTechnicalID(projectName string, shoot *gardencorev1beta1.Shoot) string

ComputeTechnicalID computes the technical ID of a shoot

func CreateShootTestArtifacts

func CreateShootTestArtifacts(cfg *ShootCreationConfig, projectNamespace string, clearDNS bool, clearExtensions bool) (string, *gardencorev1beta1.Shoot, error)

CreateShootTestArtifacts creates a shoot object from the given path and sets common attributes (test-individual settings like workers have to be handled by each test).

func DeleteAndWaitForResource added in v1.4.0

func DeleteAndWaitForResource(ctx context.Context, k8sClient kubernetes.Interface, resource client.Object, timeout time.Duration) error

DeleteAndWaitForResource deletes a kubernetes resource and waits for its deletion

func DeployRootPod added in v1.3.0

func DeployRootPod(ctx context.Context, c client.Client, namespace string, nodename *string) (*corev1.Pod, error)

DeployRootPod deploys a pod with root permissions for testing purposes.

func DownloadKubeconfig

func DownloadKubeconfig(ctx context.Context, client kubernetes.Interface, namespace, name, downloadPath string) error

DownloadKubeconfig downloads the shoot Kubeconfig

func EnsureRepositoryDirectories

func EnsureRepositoryDirectories(helm Helm) error

EnsureRepositoryDirectories creates the repository directory which holds the repositories.yaml config file

func Exists

func Exists(path string) (bool, error)

Exists checks if a path exists

func ExpectNoError

func ExpectNoError(actual interface{}, extra ...interface{})

ExpectNoError checks if an error has occurred

func FCIt

func FCIt(text string, body func(context.Context), timeout time.Duration)

FCIt contextifies Gingko's FIt

func FileExists

func FileExists(kc string) bool

FileExists Checks if a file path exists and fail otherwise

func GetAllNodes added in v1.2.0

func GetAllNodes(ctx context.Context, c kubernetes.Interface) (*corev1.NodeList, error)

GetAllNodes fetches all nodes

func GetAllNodesInWorkerPool added in v1.2.0

func GetAllNodesInWorkerPool(ctx context.Context, c kubernetes.Interface, workerGroup *string) (*corev1.NodeList, error)

GetAllNodesInWorkerPool fetches all nodes of a specific worker group

func GetDeploymentReplicas added in v1.4.0

func GetDeploymentReplicas(ctx context.Context, client client.Client, namespace, name string) (*int32, error)

GetDeploymentReplicas gets the spec.Replicas count from a deployment

func GetFirstRunningPodWithLabels

func GetFirstRunningPodWithLabels(ctx context.Context, labelsMap labels.Selector, namespace string, client kubernetes.Interface) (*corev1.Pod, error)

GetFirstRunningPodWithLabels fetches the first running pod with the desired set of labels <labelsMap>

func GetObjectFromSecret

func GetObjectFromSecret(ctx context.Context, k8sClient kubernetes.Interface, namespace, secretName, objectKey string) (string, error)

GetObjectFromSecret returns object from secret

func GetPodsByLabels

func GetPodsByLabels(ctx context.Context, labelsSelector labels.Selector, c kubernetes.Interface, namespace string) (*corev1.PodList, error)

GetPodsByLabels fetches all pods with the desired set of labels <labelsMap>

func GetTestRunID added in v1.18.0

func GetTestRunID() string

GetTestRunID returns the current testmachinery testrun ID.

func HTTPGet

func HTTPGet(ctx context.Context, url string) (*http.Response, error)

HTTPGet performs an HTTP GET request with context

func Must

func Must(err error)

Must errors with `GinkgoT().Fatal` if the error is non-nil.

func NewClientFromServiceAccount

func NewClientFromServiceAccount(ctx context.Context, k8sClient kubernetes.Interface, account *corev1.ServiceAccount) (kubernetes.Interface, error)

NewClientFromServiceAccount returns a kubernetes client for a service account.

func ParseFileAsProviderConfig

func ParseFileAsProviderConfig(filepath string) (*apimachineryRuntime.RawExtension, error)

ParseFileAsProviderConfig parses a file as a ProviderConfig

func ParseFileAsWorkers

func ParseFileAsWorkers(filepath string) ([]gardencorev1beta1.Worker, error)

ParseFileAsWorkers parses a file as a Worker configuration

func PatchSecret added in v1.26.0

func PatchSecret(ctx context.Context, c client.Client, secret *corev1.Secret) error

PatchSecret patches the Secret.

func PodExecByLabel

func PodExecByLabel(ctx context.Context, podLabels labels.Selector, podContainer, command, namespace string, client kubernetes.Interface) (io.Reader, error)

PodExecByLabel executes a command inside pods filtered by label

func PrettyPrintObject added in v1.2.0

func PrettyPrintObject(obj runtime.Object) error

PrettyPrintObject prints a object as pretty printed yaml to stdout

func ReadObject

func ReadObject(file string, into apimachineryRuntime.Object) error

ReadObject loads the contents of file and decodes it as an object.

func RemoveCleanupAction added in v1.5.0

func RemoveCleanupAction(p CleanupActionHandle)

RemoveCleanupAction removes a function that was installed by AddCleanupAction.

func RevertableSet

func RevertableSet(dst, src interface{}) (revert func())

RevertableSet sets the element of dst to src and returns a function that can revert back to the original values.

func RunCleanupActions added in v1.5.0

func RunCleanupActions()

RunCleanupActions runs all functions installed by AddCleanupAction. It does not remove them (see RemoveCleanupAction) but it does run unlocked, so they may remove themselves.

func ScaleDeployment added in v1.4.0

func ScaleDeployment(ctx context.Context, client client.Client, desiredReplicas *int32, name, namespace string) (*int32, error)

ScaleDeployment scales a deployment and waits until it is scaled

func Set

func Set(dst, src interface{})

Set sets the pointer dst to the value of src.

dst has to be a pointer, src has to be assignable to the element type of dst.

func SetProviderConfigsFromFilepath

func SetProviderConfigsFromFilepath(shoot *gardencorev1beta1.Shoot, infrastructureConfigPath, controlPlaneConfigPath, networkingConfigPath string) error

SetProviderConfigsFromFilepath parses the infrastructure, controlPlane and networking provider-configs and sets them on the shoot

func SetupShootWorker

func SetupShootWorker(shoot *gardencorev1beta1.Shoot, cloudProfile *gardencorev1beta1.CloudProfile, workerZone string) error

SetupShootWorker prepares the Shoot with one worker with provider specific volume. Clears the currently configured workers.

func ShootCreationCompleted

func ShootCreationCompleted(newShoot *gardencorev1beta1.Shoot) (bool, string)

ShootCreationCompleted checks if a shoot is successfully reconciled. In case it is not, it also returns a descriptive message stating the reason.

func StringSet

func StringSet(s string) bool

StringSet checks if a string is set

func TestHTTPEndpointWithBasicAuth

func TestHTTPEndpointWithBasicAuth(ctx context.Context, url, userName, password string) error

TestHTTPEndpointWithBasicAuth validates that a http endpoint can be accessed using basic authentication

func TestHTTPEndpointWithToken

func TestHTTPEndpointWithToken(ctx context.Context, url, token string) error

TestHTTPEndpointWithToken validates that a http endpoint can be accessed using a bearer token

func WaitForNNodesToBeHealthy added in v1.2.0

func WaitForNNodesToBeHealthy(ctx context.Context, k8sClient kubernetes.Interface, n int, timeout time.Duration) error

WaitForNNodesToBeHealthy waits for exactly <n> Nodes to be healthy within a given timeout

func WaitForNNodesToBeHealthyInWorkerPool added in v1.2.0

func WaitForNNodesToBeHealthyInWorkerPool(ctx context.Context, k8sClient kubernetes.Interface, n int, workerGroup *string, timeout time.Duration) error

WaitForNNodesToBeHealthyInWorkerPool waits for exactly <n> Nodes in a given worker pool to be healthy within a given timeout

func WaitUntilDeploymentScaled added in v1.4.0

func WaitUntilDeploymentScaled(ctx context.Context, client client.Client, namespace, name string, desiredReplicas int32) error

WaitUntilDeploymentScaled waits until the deployment has the desired replica count in the status

func WaitUntilPodIsRunning added in v1.4.0

func WaitUntilPodIsRunning(ctx context.Context, log *logrus.Logger, podName, podNamespace string, c kubernetes.Interface) error

WaitUntilPodIsRunning waits until the pod with <podName> is running

Types

type Chart

type Chart struct {
	Name        string
	ReleaseName string
	Namespace   string
	Version     string
}

Chart represents a external helm chart with a specific version and namespace

type CleanupActionHandle added in v1.5.0

type CleanupActionHandle *int

CleanupActionHandle is an integer pointer type for handling cleanup action

func AddCleanupAction added in v1.5.0

func AddCleanupAction(fn func()) CleanupActionHandle

AddCleanupAction installs a function that will be called in the event of the whole test being terminated. This allows arbitrary pieces of the overall test to hook into SynchronizedAfterSuite(). The hooks are called in last-in-first-out order.

type CommonConfig

type CommonConfig struct {
	LogLevel         string
	DisableStateDump bool
	ResourceDir      string
	ChartDir         string
}

CommonConfig is the configuration for a common framework

func RegisterCommonFrameworkFlags

func RegisterCommonFrameworkFlags() *CommonConfig

RegisterCommonFrameworkFlags adds all flags that are needed to configure a common framework to the provided flagset.

type CommonFramework

type CommonFramework struct {
	Config           *CommonConfig
	Logger           *logrus.Logger
	DisableStateDump bool

	// ResourcesDir is the absolute path to the resources directory
	ResourcesDir string

	// TemplatesDir is the absolute path to the templates directory
	TemplatesDir string

	// Chart is the absolute path to the helm chart directory
	ChartDir string
}

CommonFramework represents the common gardener test framework that consolidates all shared features of the specific test frameworks (system, garderner, shoot)

func NewCommonFramework

func NewCommonFramework(cfg *CommonConfig) *CommonFramework

NewCommonFramework creates a new common framework and registers its ginkgo BeforeEach setup

func NewCommonFrameworkFromConfig added in v1.5.0

func NewCommonFrameworkFromConfig(cfg *CommonConfig) *CommonFramework

NewCommonFrameworkFromConfig creates a new common framework and registers its ginkgo BeforeEach setup

func (*CommonFramework) BeforeEach

func (f *CommonFramework) BeforeEach()

BeforeEach should be called in ginkgo's BeforeEach. It sets up the common framework.

func (*CommonFramework) DeployChart

func (f *CommonFramework) DeployChart(ctx context.Context, k8sClient kubernetes.Interface, namespace, chartRepoDestination, chartNameToDeploy string, values map[string]interface{}) error

DeployChart deploys it on the test cluster

func (*CommonFramework) DownloadChartArtifacts

func (f *CommonFramework) DownloadChartArtifacts(ctx context.Context, helm Helm, chartRepoDestination, chartNameToDownload, chartVersionToDownload string) error

DownloadChartArtifacts downloads a helm chart from helm stable repo url available in resources/repositories

func (*CommonFramework) DumpDefaultResourcesInAllNamespaces added in v1.4.0

func (f *CommonFramework) DumpDefaultResourcesInAllNamespaces(ctx context.Context, ctxIdentifier string, k8sClient kubernetes.Interface) error

DumpDefaultResourcesInAllNamespaces dumps all default k8s resources of a namespace

func (*CommonFramework) DumpDefaultResourcesInNamespace added in v1.4.0

func (f *CommonFramework) DumpDefaultResourcesInNamespace(ctx context.Context, ctxIdentifier string, k8sClient kubernetes.Interface, namespace string) error

DumpDefaultResourcesInNamespace dumps all default K8s resources of a namespace.

func (*CommonFramework) DumpLogsForPodInNamespace added in v1.6.0

func (f *CommonFramework) DumpLogsForPodInNamespace(ctx context.Context, ctxIdentifier string, k8sClient kubernetes.Interface, podNamespace, podName string) error

DumpLogsForPodInNamespace prints the logs of the pod with the given namespace and name.

func (*CommonFramework) DumpLogsForPodsWithLabelsInNamespace added in v1.6.0

func (f *CommonFramework) DumpLogsForPodsWithLabelsInNamespace(ctx context.Context, ctxIdentifier string, k8sClient kubernetes.Interface, namespace string, opts ...client.ListOption) error

DumpLogsForPodsWithLabelsInNamespace prints the logs of pods in the given namespace selected by the given list options.

func (*CommonFramework) RenderAndDeployChart

func (f *CommonFramework) RenderAndDeployChart(ctx context.Context, k8sClient kubernetes.Interface, c Chart, values map[string]interface{}) error

RenderAndDeployChart downloads a helm chart from helm stable repo url available in resources/repositories and deploys it on the test cluster

func (*CommonFramework) RenderAndDeployTemplate

func (f *CommonFramework) RenderAndDeployTemplate(ctx context.Context, k8sClient kubernetes.Interface, templateName string, values interface{}) error

RenderAndDeployTemplate renders a template from the resource template directory and deploys it to the cluster

func (*CommonFramework) WaitUntilDaemonSetIsRunning

func (f *CommonFramework) WaitUntilDaemonSetIsRunning(ctx context.Context, k8sClient client.Client, daemonSetName, daemonSetNamespace string) error

WaitUntilDaemonSetIsRunning waits until the daemon set with <daemonSetName> is running

func (*CommonFramework) WaitUntilDeploymentIsReady added in v1.2.0

func (f *CommonFramework) WaitUntilDeploymentIsReady(ctx context.Context, name string, namespace string, k8sClient kubernetes.Interface) error

WaitUntilDeploymentIsReady waits until the given deployment is ready

func (*CommonFramework) WaitUntilDeploymentsWithLabelsIsReady

func (f *CommonFramework) WaitUntilDeploymentsWithLabelsIsReady(ctx context.Context, deploymentLabels labels.Selector, namespace string, k8sClient kubernetes.Interface) error

WaitUntilDeploymentsWithLabelsIsReady wait until pod with labels <podLabels> is running

func (*CommonFramework) WaitUntilNamespaceIsDeleted

func (f *CommonFramework) WaitUntilNamespaceIsDeleted(ctx context.Context, k8sClient kubernetes.Interface, ns string) error

WaitUntilNamespaceIsDeleted waits until a namespace has been deleted

func (*CommonFramework) WaitUntilPodIsRunningWithLabels added in v1.5.0

func (f *CommonFramework) WaitUntilPodIsRunningWithLabels(ctx context.Context, labels labels.Selector, podNamespace string, c kubernetes.Interface) error

WaitUntilPodIsRunningWithLabels waits until the pod with <podLabels> is running

func (*CommonFramework) WaitUntilStatefulSetIsRunning

func (f *CommonFramework) WaitUntilStatefulSetIsRunning(ctx context.Context, statefulSetName, statefulSetNamespace string, c kubernetes.Interface) error

WaitUntilStatefulSetIsRunning waits until the stateful set with <statefulSetName> is running

type EventFilterFunc

type EventFilterFunc func(event corev1.Event) bool

EventFilterFunc is a function to filter events

type GardenerConfig

type GardenerConfig struct {
	CommonConfig       *CommonConfig
	GardenerKubeconfig string
	ProjectNamespace   string
	SkipAccessingShoot bool
}

GardenerConfig is the configuration for a gardener framework

func RegisterGardenerFrameworkFlags

func RegisterGardenerFrameworkFlags() *GardenerConfig

RegisterGardenerFrameworkFlags adds all flags that are needed to configure a gardener framework to the provided flagset.

type GardenerFramework

type GardenerFramework struct {
	*CommonFramework
	TestDescription
	GardenClient kubernetes.Interface

	ProjectNamespace        string
	GardenerFrameworkConfig *GardenerConfig
}

GardenerFramework is the gardener test framework that includes functions for working with a gardener instance

func NewGardenerFramework

func NewGardenerFramework(cfg *GardenerConfig) *GardenerFramework

NewGardenerFramework creates a new gardener test framework. All needed flags are parsed during before each suite.

func NewGardenerFrameworkFromConfig

func NewGardenerFrameworkFromConfig(cfg *GardenerConfig) *GardenerFramework

NewGardenerFrameworkFromConfig creates a new gardener test framework without registering ginkgo specific functions

func (*GardenerFramework) AnnotateShoot

func (f *GardenerFramework) AnnotateShoot(ctx context.Context, shoot *gardencorev1beta1.Shoot, annotations map[string]string) error

AnnotateShoot adds shoot annotation(s)

func (*GardenerFramework) BeforeEach

func (f *GardenerFramework) BeforeEach()

BeforeEach should be called in ginkgo's BeforeEach. It sets up the gardener framework.

func (*GardenerFramework) CreateManagedSeed added in v1.18.0

func (f *GardenerFramework) CreateManagedSeed(ctx context.Context, managedSeed *seedmanagementv1alpha1.ManagedSeed) error

CreateManagedSeed creates a new managed seed and waits for it to be created and successfully reconciled.

func (*GardenerFramework) CreatePlant

func (f *GardenerFramework) CreatePlant(ctx context.Context, plant *gardencorev1beta1.Plant) error

CreatePlant Creates a plant from a plant Object

func (*GardenerFramework) CreatePlantSecret

func (f *GardenerFramework) CreatePlantSecret(ctx context.Context, namespace string, kubeConfigContent []byte) (*corev1.Secret, error)

CreatePlantSecret creates a new Secret for the Plant

func (*GardenerFramework) CreateSeed added in v1.12.0

func (f *GardenerFramework) CreateSeed(ctx context.Context, seed *gardencorev1beta1.Seed) error

CreateSeed creates a seed from a seed Object and waits until it is successfully reconciled

func (*GardenerFramework) CreateShoot

func (f *GardenerFramework) CreateShoot(ctx context.Context, shoot *gardencorev1beta1.Shoot) error

CreateShoot Creates a shoot from a shoot Object and waits until it is successfully reconciled

func (*GardenerFramework) DeleteManagedSeed added in v1.18.0

func (f *GardenerFramework) DeleteManagedSeed(ctx context.Context, managedSeed *seedmanagementv1alpha1.ManagedSeed) error

DeleteManagedSeed deletes the given managed seed and waits for it to be deleted.

func (*GardenerFramework) DeletePlant

func (f *GardenerFramework) DeletePlant(ctx context.Context, plant *gardencorev1beta1.Plant) error

DeletePlant deletes the test plant

func (*GardenerFramework) DeleteSeed added in v1.12.0

func (f *GardenerFramework) DeleteSeed(ctx context.Context, seed *gardencorev1beta1.Seed) error

DeleteSeed deletes the test seed

func (*GardenerFramework) DeleteSeedAndWaitForDeletion added in v1.12.0

func (f *GardenerFramework) DeleteSeedAndWaitForDeletion(ctx context.Context, seed *gardencorev1beta1.Seed) error

DeleteSeedAndWaitForDeletion deletes the test seed and waits until it cannot be found any more

func (*GardenerFramework) DeleteShoot

func (f *GardenerFramework) DeleteShoot(ctx context.Context, shoot *gardencorev1beta1.Shoot) error

DeleteShoot deletes the test shoot

func (*GardenerFramework) DeleteShootAndWaitForDeletion

func (f *GardenerFramework) DeleteShootAndWaitForDeletion(ctx context.Context, shoot *gardencorev1beta1.Shoot) (rErr error)

DeleteShootAndWaitForDeletion deletes the test shoot and waits until it cannot be found any more

func (*GardenerFramework) DumpState

func (f *GardenerFramework) DumpState(ctx context.Context)

DumpState greps all necessary logs and state of the cluster if the test failed TODO: dump extension controller namespaces TODO: dump logs of gardener extension controllers and other system components

func (*GardenerFramework) GetCloudProfile

func (f *GardenerFramework) GetCloudProfile(ctx context.Context, name string) (*gardencorev1beta1.CloudProfile, error)

GetCloudProfile returns the cloudprofile from gardener with the give name

func (*GardenerFramework) GetSeed

GetSeed returns the seed and its k8s client

func (*GardenerFramework) GetSeeds added in v1.5.0

GetSeeds returns all registered seeds

func (*GardenerFramework) GetShoot

func (f *GardenerFramework) GetShoot(ctx context.Context, shoot *gardencorev1beta1.Shoot) error

GetShoot gets the test shoot

func (*GardenerFramework) GetShootProject

func (f *GardenerFramework) GetShootProject(ctx context.Context, shootNamespace string) (*gardencorev1beta1.Project, error)

GetShootProject returns the project of a shoot

func (*GardenerFramework) HibernateShoot

func (f *GardenerFramework) HibernateShoot(ctx context.Context, shoot *gardencorev1beta1.Shoot) error

HibernateShoot hibernates the test shoot

func (*GardenerFramework) MigrateShoot added in v1.13.0

func (f *GardenerFramework) MigrateShoot(ctx context.Context, shoot *gardencorev1beta1.Shoot, seed *gardencorev1beta1.Seed, prerequisites func(shoot *gardencorev1beta1.Shoot) error) error

MigrateShoot changes the spec.Seed.Name of a shoot and waits for it to be migrated

func (*GardenerFramework) NewShootFramework

func (f *GardenerFramework) NewShootFramework(ctx context.Context, shoot *gardencorev1beta1.Shoot) (*ShootFramework, error)

NewShootFramework creates a new shoot framework with the current gardener framework and a shoot

func (*GardenerFramework) RemoveShootAnnotation

func (f *GardenerFramework) RemoveShootAnnotation(ctx context.Context, shoot *gardencorev1beta1.Shoot, annotationKey string) error

RemoveShootAnnotation removes an annotation with key <annotationKey> from a shoot object

func (*GardenerFramework) ScheduleShoot added in v1.5.0

func (f *GardenerFramework) ScheduleShoot(ctx context.Context, shoot *gardencorev1beta1.Shoot, seed *gardencorev1beta1.Seed) error

ScheduleShoot set the Spec.Cloud.Seed of a shoot to the specified seed. This is the request the Gardener Scheduler executes after a scheduling decision.

func (*GardenerFramework) UpdateShoot

func (f *GardenerFramework) UpdateShoot(ctx context.Context, shoot *gardencorev1beta1.Shoot, update func(shoot *gardencorev1beta1.Shoot) error) error

UpdateShoot Updates a shoot from a shoot Object and waits for its reconciliation

func (*GardenerFramework) WaitForManagedSeedToBeCreated added in v1.18.0

func (f *GardenerFramework) WaitForManagedSeedToBeCreated(ctx context.Context, managedSeed *seedmanagementv1alpha1.ManagedSeed) error

WaitForManagedSeedToBeCreated waits for the given managed seed to be created and successfully reconciled.

func (*GardenerFramework) WaitForManagedSeedToBeDeleted added in v1.18.0

func (f *GardenerFramework) WaitForManagedSeedToBeDeleted(ctx context.Context, managedSeed *seedmanagementv1alpha1.ManagedSeed) error

WaitForManagedSeedToBeDeleted waits for the given managed seed to be deleted.

func (*GardenerFramework) WaitForPlantToBeCreated

func (f *GardenerFramework) WaitForPlantToBeCreated(ctx context.Context, plant *gardencorev1beta1.Plant) error

WaitForPlantToBeCreated waits for the plant to be created

func (*GardenerFramework) WaitForPlantToBeDeleted

func (f *GardenerFramework) WaitForPlantToBeDeleted(ctx context.Context, plant *gardencorev1beta1.Plant) error

WaitForPlantToBeDeleted waits for the plant to be deleted

func (*GardenerFramework) WaitForPlantToBeReconciledSuccessfully

func (f *GardenerFramework) WaitForPlantToBeReconciledSuccessfully(ctx context.Context, plant *gardencorev1beta1.Plant) error

WaitForPlantToBeReconciledSuccessfully waits for the plant to be reconciled with a status indicating success

func (*GardenerFramework) WaitForPlantToBeReconciledWithUnknownStatus

func (f *GardenerFramework) WaitForPlantToBeReconciledWithUnknownStatus(ctx context.Context, plant *gardencorev1beta1.Plant) error

WaitForPlantToBeReconciledWithUnknownStatus waits for the plant to be reconciled, setting the expected status 'unknown'

func (*GardenerFramework) WaitForSeedToBeCreated added in v1.12.0

func (f *GardenerFramework) WaitForSeedToBeCreated(ctx context.Context, seed *gardencorev1beta1.Seed) error

WaitForSeedToBeCreated waits for the seed to be created

func (*GardenerFramework) WaitForSeedToBeDeleted added in v1.12.0

func (f *GardenerFramework) WaitForSeedToBeDeleted(ctx context.Context, seed *gardencorev1beta1.Seed) error

WaitForSeedToBeDeleted waits for the seed to be deleted

func (*GardenerFramework) WaitForShootToBeCreated

func (f *GardenerFramework) WaitForShootToBeCreated(ctx context.Context, shoot *gardencorev1beta1.Shoot) error

WaitForShootToBeCreated waits for the shoot to be created

func (*GardenerFramework) WaitForShootToBeDeleted

func (f *GardenerFramework) WaitForShootToBeDeleted(ctx context.Context, shoot *gardencorev1beta1.Shoot) error

WaitForShootToBeDeleted waits for the shoot to be deleted

func (*GardenerFramework) WaitForShootToBeReconciled

func (f *GardenerFramework) WaitForShootToBeReconciled(ctx context.Context, shoot *gardencorev1beta1.Shoot) error

WaitForShootToBeReconciled waits for the shoot to be successfully reconciled

func (*GardenerFramework) WakeUpShoot

func (f *GardenerFramework) WakeUpShoot(ctx context.Context, shoot *gardencorev1beta1.Shoot) error

WakeUpShoot wakes up the test shoot from hibernation

type Helm

type Helm string

Helm is the home for the HELM repo

func (Helm) CacheIndex

func (h Helm) CacheIndex(name string) string

CacheIndex returns the path to an index for the given named repository.

func (Helm) Path

func (h Helm) Path(elem ...string) string

Path returns Helm path with elements appended.

func (Helm) Repository

func (h Helm) Repository() string

Repository returns the path to the local repository.

func (Helm) RepositoryFile

func (h Helm) RepositoryFile() string

RepositoryFile returns the path to the repositories.yaml file.

func (Helm) String

func (h Helm) String(elem ...string) string

Path returns the home for the helm repo with.

type HelmAccess

type HelmAccess struct {
	HelmPath Helm
}

HelmAccess is a struct that holds the helm home

type ManagedSeedConfig added in v1.18.0

type ManagedSeedConfig struct {
	GardenerConfig  *GardenerConfig
	ManagedSeedName string
	ShootName       string
	DeployGardenlet bool
	BackupProvider  string
}

ManagedSeedConfig is a managed seed framework configuration.

func RegisterManagedSeedFrameworkFlags added in v1.18.0

func RegisterManagedSeedFrameworkFlags() *ManagedSeedConfig

RegisterManagedSeedFrameworkFlags adds all flags that are needed to configure a managed seed framework.

type ManagedSeedFramework added in v1.18.0

type ManagedSeedFramework struct {
	*GardenerFramework
	TestDescription
	Config *ManagedSeedConfig

	ManagedSeed *seedmanagementv1alpha1.ManagedSeed
}

ManagedSeedFramework is a test framework for testing managed seed creation and deletion.

func NewManagedSeedFramework added in v1.18.0

func NewManagedSeedFramework(cfg *ManagedSeedConfig) *ManagedSeedFramework

NewManagedSeedFramework creates a new managed seed framework.

func (*ManagedSeedFramework) AfterEach added in v1.18.0

func (f *ManagedSeedFramework) AfterEach(ctx context.Context)

AfterEach should be called in ginkgo's AfterEach. It dumps the managed seed framework state if the test failed.

func (*ManagedSeedFramework) BeforeEach added in v1.18.0

func (f *ManagedSeedFramework) BeforeEach(ctx context.Context)

BeforeEach should be called in ginkgo's BeforeEach. It merges and validates the managed seed framework configuration.

func (*ManagedSeedFramework) CreateManagedSeed added in v1.18.0

func (f *ManagedSeedFramework) CreateManagedSeed(ctx context.Context) error

CreateManagedSeed creates a new managed seed according to the managed seed framework configuration.

type PodExecutor added in v1.4.0

type PodExecutor interface {
	Execute(ctx context.Context, namespace, name, containerName, command string) (io.Reader, error)
}

PodExecutor is the pod executor interface

func NewPodExecutor added in v1.4.0

func NewPodExecutor(client kubernetes.Interface) PodExecutor

NewPodExecutor returns a podExecutor

type RootPodExecutor added in v1.4.0

type RootPodExecutor interface {
	Execute(ctx context.Context, command string) ([]byte, error)
	Clean(ctx context.Context) error
}

RootPodExecutor enables the execution of command on the operating system of a node. The executor deploys a pod with root privileged on a specified node. This pod is then used to execute commands on the host operating system.

func NewRootPodExecutor added in v1.4.0

func NewRootPodExecutor(logger *logrus.Logger, c kubernetes.Interface, nodeName *string, namespace string) RootPodExecutor

NewRootPodExecutor creates a new root pod executor to run commands on a node.

type SearchResponse

type SearchResponse struct {
	Data struct {
		Result []struct {
			Value []interface{} `json:"value"`
		} `json:"result"`
	} `json:"data"`
}

SearchResponse represents the response from a search query to loki

type ShootComparisonElements added in v1.13.0

type ShootComparisonElements struct {
	MachineNames []string
	MachineNodes []string
	NodeNames    []string
	SecretsMap   map[string]corev1.Secret
}

ShootComparisonElements contains details about Machines and Nodes that will be compared during the tests

type ShootConfig

type ShootConfig struct {
	GardenerConfig *GardenerConfig
	ShootName      string
	Fenced         bool
	SeedScheme     *runtime.Scheme

	CreateTestNamespace         bool
	DisableTestNamespaceCleanup bool
	SkipSeedInitialization      bool
}

ShootConfig is the configuration for a shoot framework

func RegisterShootFrameworkFlags

func RegisterShootFrameworkFlags() *ShootConfig

RegisterShootFrameworkFlags adds all flags that are needed to configure a shoot framework to the provided flagset.

type ShootCreationConfig added in v1.3.0

type ShootCreationConfig struct {
	GardenerConfig *GardenerConfig
	// contains filtered or unexported fields
}

ShootCreationConfig is the configuration for a shoot creation framework

func RegisterShootCreationFrameworkFlags added in v1.3.0

func RegisterShootCreationFrameworkFlags() *ShootCreationConfig

RegisterShootCreationFrameworkFlags adds all flags that are needed to configure a shoot creation framework to the provided flagset.

type ShootCreationFramework added in v1.3.0

type ShootCreationFramework struct {
	*GardenerFramework
	TestDescription
	Config *ShootCreationConfig

	Shoot *gardencorev1beta1.Shoot

	// ShootFramework is initialized once the shoot has been created successfully
	ShootFramework *ShootFramework
}

ShootCreationFramework represents the shoot test framework that includes test functions that can be executed ona specific shoot

func NewShootCreationFramework added in v1.3.0

func NewShootCreationFramework(cfg *ShootCreationConfig) *ShootCreationFramework

NewShootCreationFramework creates a new simple Shoot creation framework

func (*ShootCreationFramework) AfterEach added in v1.3.0

func (f *ShootCreationFramework) AfterEach(ctx context.Context)

AfterEach should be called in ginkgo's AfterEach. Cleans up resources and dumps the shoot state if the test failed

func (*ShootCreationFramework) BeforeEach added in v1.3.0

func (f *ShootCreationFramework) BeforeEach()

BeforeEach should be called in ginkgo's BeforeEach. It sets up the shoot creation framework.

func (*ShootCreationFramework) CreateShootAndWaitForCreation added in v1.40.0

func (f *ShootCreationFramework) CreateShootAndWaitForCreation(ctx context.Context, initializeShootWithFlags bool) error

CreateShootAndWaitForCreation creates a shoot using this framework's configuration and waits for successful creation.

func (*ShootCreationFramework) InitializeShootWithFlags added in v1.5.0

func (f *ShootCreationFramework) InitializeShootWithFlags(ctx context.Context) error

InitializeShootWithFlags initializes a shoot to be created by this framework.

func (*ShootCreationFramework) Verify added in v1.40.0

func (f *ShootCreationFramework) Verify()

Verify asserts that the shoot creation was successful.

type ShootFramework

type ShootFramework struct {
	*GardenerFramework
	TestDescription
	Config *ShootConfig

	SeedClient  kubernetes.Interface
	ShootClient kubernetes.Interface

	Seed         *gardencorev1beta1.Seed
	CloudProfile *gardencorev1beta1.CloudProfile
	Shoot        *gardencorev1beta1.Shoot
	Project      *gardencorev1beta1.Project

	Namespace string
}

ShootFramework represents the shoot test framework that includes test functions that can be executed on a specific shoot

func NewShootFramework

func NewShootFramework(cfg *ShootConfig) *ShootFramework

NewShootFramework creates a new simple Shoot framework

func NewShootFrameworkFromConfig

func NewShootFrameworkFromConfig(ctx context.Context, cfg *ShootConfig) (*ShootFramework, error)

NewShootFrameworkFromConfig creates a new Shoot framework from a shoot configuration without registering ginkgo specific functions

func (*ShootFramework) AddShoot

func (f *ShootFramework) AddShoot(ctx context.Context, shootName, shootNamespace string) error

AddShoot sets the shoot and its seed for the GardenerOperation.

func (*ShootFramework) AfterEach

func (f *ShootFramework) AfterEach(ctx context.Context)

AfterEach should be called in ginkgo's AfterEach. Cleans up resources and dumps the shoot state if the test failed

func (*ShootFramework) BeforeEach

func (f *ShootFramework) BeforeEach(ctx context.Context)

BeforeEach should be called in ginkgo's BeforeEach. It sets up the shoot framework.

func (*ShootFramework) CreateNewNamespace

func (f *ShootFramework) CreateNewNamespace(ctx context.Context) (string, error)

CreateNewNamespace creates a new namespace with a generated name prefixed with "gardener-e2e-". The created namespace is automatically cleaned up when the test is finished.

func (*ShootFramework) DumpState

func (f *ShootFramework) DumpState(ctx context.Context)

DumpState dumps the state of a shoot The state includes all k8s components running in the shoot itself as well as the controlplane

func (*ShootFramework) GetCloudProfile

func (f *ShootFramework) GetCloudProfile(ctx context.Context) (*gardencorev1beta1.CloudProfile, error)

GetCloudProfile returns the cloudprofile of the shoot

func (*ShootFramework) GetLokiLogs added in v1.8.0

func (f *ShootFramework) GetLokiLogs(ctx context.Context, lokiLabels map[string]string, tenant, lokiNamespace, key, value string, client kubernetes.Interface) (*SearchResponse, error)

GetLokiLogs gets logs from the last 1 hour for <key>, <value> from the loki instance in <lokiNamespace>

func (*ShootFramework) HibernateShoot

func (f *ShootFramework) HibernateShoot(ctx context.Context) error

HibernateShoot hibernates the shoot of the framework

func (*ShootFramework) IsAPIServerRunning added in v1.7.0

func (f *ShootFramework) IsAPIServerRunning(ctx context.Context) (bool, error)

IsAPIServerRunning checks, if the Shoot's API server deployment is present, not yet deleted and has at least one available replica.

func (*ShootFramework) ShootKubeconfigSecretName

func (f *ShootFramework) ShootKubeconfigSecretName() string

ShootKubeconfigSecretName gets the name of the secret with the kubeconfig of the shoot

func (*ShootFramework) ShootSeedNamespace

func (f *ShootFramework) ShootSeedNamespace() string

ShootSeedNamespace gets the shoot namespace in the seed

func (*ShootFramework) UpdateShoot

func (f *ShootFramework) UpdateShoot(ctx context.Context, update func(shoot *gardencorev1beta1.Shoot) error) error

UpdateShoot Updates a shoot from a shoot Object and waits for its reconciliation

func (*ShootFramework) WaitForShootCondition added in v1.2.0

func (f *ShootFramework) WaitForShootCondition(ctx context.Context, interval, timeout time.Duration, conditionType gardencorev1beta1.ConditionType, conditionStatus gardencorev1beta1.ConditionStatus) error

WaitForShootCondition waits for the shoot to contain the specified condition

func (*ShootFramework) WakeUpShoot

func (f *ShootFramework) WakeUpShoot(ctx context.Context) error

WakeUpShoot wakes up the hibernated shoot of the framework

type ShootMigrationConfig added in v1.13.0

type ShootMigrationConfig struct {
	TargetSeedName  string
	SourceSeedName  string
	ShootName       string
	ShootNamespace  string
	AddTestRunTaint string
}

ShootMigrationConfig is the configuration for a shoot migration test that will be filled with user provided data

type ShootMigrationTest added in v1.13.0

type ShootMigrationTest struct {
	GardenerFramework                 *GardenerFramework
	Config                            *ShootMigrationConfig
	TargetSeedClient                  kubernetes.Interface
	SourceSeedClient                  kubernetes.Interface
	ShootClient                       kubernetes.Interface
	TargetSeed                        *gardencorev1beta1.Seed
	SourceSeed                        *gardencorev1beta1.Seed
	ComparisonElementsBeforeMigration ShootComparisonElements
	ComparisonElementsAfterMigration  ShootComparisonElements
	Shoot                             gardencorev1beta1.Shoot
	SeedShootNamespace                string
	MigrationTime                     metav1.Time
}

ShootMigrationTest represents a shoot migration test. It can be used to test the migration of shoots between various seeds.

func NewShootMigrationTest added in v1.13.0

func NewShootMigrationTest(f *GardenerFramework, cfg *ShootMigrationConfig) *ShootMigrationTest

NewShootMigrationTest creates a new simple shoot migration test

func (*ShootMigrationTest) CheckForOrphanedNonNamespacedResources added in v1.18.0

func (t *ShootMigrationTest) CheckForOrphanedNonNamespacedResources(ctx context.Context) error

CheckForOrphanedNonNamespacedResources checks if there are orphaned resources left on the target seed after the shoot migration. The function checks for Cluster, DNSOwner, BackupEntry, ClusterRoleBinding, ClusterRole and PersistentVolume

func (*ShootMigrationTest) CheckObjectsTimestamp added in v1.13.0

func (t *ShootMigrationTest) CheckObjectsTimestamp(ctx context.Context, mrExcludeList, resourcesWithGeneratedName []string) error

CheckObjectsTimestamp checks the timestamp of all objects that the resource-manager creates in the Shoot cluster. The timestamp should not be after ShootMigrationTest.MigrationTime.

func (*ShootMigrationTest) CompareElementsAfterMigration added in v1.13.0

func (t *ShootMigrationTest) CompareElementsAfterMigration() error

CompareElementsAfterMigration compares the Machine details, Node names and Pod statuses before and after migration and returns error if there are differences.

func (*ShootMigrationTest) GetMachineDetails added in v1.13.0

func (t *ShootMigrationTest) GetMachineDetails(ctx context.Context, seedClient kubernetes.Interface) (machineNames, machineNodes []string, err error)

GetMachineDetails uses the seedClient to fetch all Machine names and the names of their corresponding Nodes

func (*ShootMigrationTest) GetNodeNames added in v1.13.0

func (t *ShootMigrationTest) GetNodeNames(ctx context.Context, shootClient kubernetes.Interface) (nodeNames []string, err error)

GetNodeNames uses the shootClient to fetch all Node names from the Shoot

func (*ShootMigrationTest) GetPersistedSecrets added in v1.44.1

func (t *ShootMigrationTest) GetPersistedSecrets(ctx context.Context, seedClient kubernetes.Interface) (map[string]corev1.Secret, error)

GetPersistedSecrets uses the seedClient to fetch the data of all Secrets that have the `persist` label key set to true from the Shoot's control plane namespace

func (*ShootMigrationTest) MigrateShoot added in v1.13.0

func (t *ShootMigrationTest) MigrateShoot(ctx context.Context) error

MigrateShoot triggers shoot migration by changing the value of "shoot.Spec.SeedName" to the value of "ShootMigrationConfig.TargetSeedName"

func (*ShootMigrationTest) PopulateAfterMigrationComparisonElements added in v1.13.0

func (t *ShootMigrationTest) PopulateAfterMigrationComparisonElements(ctx context.Context) (err error)

PopulateAfterMigrationComparisonElements fills the ShootMigrationTest.ComparisonElementsAfterMigration with the necessary Machine details and Node names

func (*ShootMigrationTest) PopulateBeforeMigrationComparisonElements added in v1.13.0

func (t *ShootMigrationTest) PopulateBeforeMigrationComparisonElements(ctx context.Context) (err error)

PopulateBeforeMigrationComparisonElements fills the ShootMigrationTest.ComparisonElementsBeforeMigration with the necessary Machine details and Node names

type TestDescription

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

TestDescription labels tests according to the provided labels in the expected order.

func NewTestDescription

func NewTestDescription(baseLabel string) TestDescription

NewTestDescription creates a new test description

func (TestDescription) Beta

Beta labels a test as beta test

func (TestDescription) CIt

func (t TestDescription) CIt(text string, body func(context.Context), timeout time.Duration, opts ...TestOption)

CIt defines a contextified ginkgo It block and enhances the test description with the provided labels

func (TestDescription) Default

func (t TestDescription) Default() TestDescription

Default labels a test as default test

func (TestDescription) Disruptive

func (t TestDescription) Disruptive() TestDescription

Disruptive labels a test as disruptive. This kind of test should run with care.

func (TestDescription) FCIt

func (t TestDescription) FCIt(text string, body func(context.Context), timeout time.Duration, opts ...TestOption)

FCIt defines a contextified ginkgo FIt block and enhances the test description with the provided labels

func (TestDescription) FIt

func (t TestDescription) FIt(text string, body func(), opts ...TestOption)

FIt defines a ginkgo FIt block and enhances the test description with the provided labels

func (TestDescription) It

func (t TestDescription) It(text string, body func(), opts ...TestOption)

It defines a ginkgo It block and enhances the test description with the provided labels

func (TestDescription) Release

func (t TestDescription) Release() TestDescription

Release labels a test as release relevant test

func (TestDescription) Serial

func (t TestDescription) Serial() TestDescription

Serial labels a test to be run as serial step

func (TestDescription) String

func (t TestDescription) String() string

String returns the test description labels

type TestOption added in v1.5.0

type TestOption interface {
	// ApplyToTestOptions applies this configuration to the given test options.
	ApplyToTestOptions(*TestOptions)
}

TestOption is some configuration that modifies options for testcase.

func WithAfterTests added in v1.5.0

func WithAfterTests(funcs ...func()) TestOption

WithAfterTests adds functions to the current test that are called when the test has finished

func WithCAfterTest added in v1.5.0

func WithCAfterTest(body func(ctx context.Context), timeout time.Duration) TestOption

WithCAfterTest adds contextified functions to the current test that are called when the test has finished

type TestOptions added in v1.5.0

type TestOptions struct {
	// afterTests holds a list of all registered AfterTest functions
	// that are executed when the test has finished.
	AfterTests afterTests

	// CAfterTests holds a list of all registered contextified AfterTest functions
	// that are executed when the test has finished.
	CAfterTests []cAfterTestOption
}

TestOptions contains options to add additional functionality or cleanup handlers to a testcase.

func (*TestOptions) ApplyOptions added in v1.5.0

func (o *TestOptions) ApplyOptions(opts []TestOption) *TestOptions

ApplyOptions applies the given test options on these options.

func (*TestOptions) Complete added in v1.5.0

func (o *TestOptions) Complete(it func())

Complete registers all test options that are configured. it should be a function that configures a ginkgo test case This should get called when all options are applied.

type TextValidation added in v1.4.0

type TextValidation map[string]string

TextValidation is a map of regular expression to description that is used to validate texts based on allowed or denied regexps.

func (*TextValidation) ValidateAsAllowlist added in v1.16.0

func (v *TextValidation) ValidateAsAllowlist(text []byte) error

ValidateAsAllowlist validates that all allowed regular expressions are in the given text.

func (*TextValidation) ValidateAsDenylist added in v1.16.0

func (v *TextValidation) ValidateAsDenylist(text []byte) error

ValidateAsDenylist validates that no denied regular expressions are in the given text.

Directories

Path Synopsis
resources

Jump to

Keyboard shortcuts

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