framework

package
v0.0.0-...-44ba42e Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2019 License: Apache-2.0, BSD-2-Clause, MIT, + 1 more Imports: 45 Imported by: 0

Documentation

Index

Constants

View Source
const (

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

Variables

View Source
var (
	// ErrNoRepositoriesFound no repositories found in repoitories file
	ErrNoRepositoriesFound = errors.New("no repositories found in repoitories 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")
)
View Source
var (

	// TemplateDir relative path for helm templates dir
	TemplateDir = filepath.Join("..", "..", "resources", "templates")
)

Functions

func ChooseRegionAndZoneWithNoSeed

func ChooseRegionAndZoneWithNoSeed(cloudProvider gardenv1beta1.CloudProvider, allAvailableZones []gardenv1beta1.Zone, cloudProfile *gardenv1beta1.CloudProfile, seeds []gardenv1beta1.Seed) (*string, []string, error)

ChooseRegionAndZoneWithNoSeed chooses a region within the cloud provider of the shoot were no seed is deployed and that is allowed by the cloud profile

func CreatePlantTestArtifacts

func CreatePlantTestArtifacts(plantTestYamlPath string) (*gardencorev1alpha1.Plant, error)

CreatePlantTestArtifacts creates a plant object which is read from the resources directory

func CreateShootTestArtifacts

func CreateShootTestArtifacts(shootTestYamlPath, prefix string, clearDNS bool) (string, *v1beta1.Shoot, error)

CreateShootTestArtifacts creates the necessary artifacts for a shoot tests including a random integration test name and a shoot object which is read from the resources directory

func EnsureDirectories

func EnsureDirectories(helm Helm) error

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

func GetAllAzureRegions(domainCounts []gardenv1beta1.AzureDomainCount) []string

GetAllAzureRegions extract the regions as a string slice from AzureDomainCounts

func GetObjectFromSecret

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

GetObjectFromSecret returns object from secret

func ReadObject

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

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

Types

type GardenerTestOperation

type GardenerTestOperation struct {
	Logger       logrus.FieldLogger
	GardenClient kubernetes.Interface
	SeedClient   kubernetes.Interface
	ShootClient  kubernetes.Interface

	Seed             *v1beta1.Seed
	SeedCloudProfile *v1beta1.CloudProfile
	Shoot            *v1beta1.Shoot
	Project          *v1beta1.Project
}

GardenerTestOperation holds all required instances for doing a test operation

func NewGardenTestOperation

func NewGardenTestOperation(ctx context.Context, k8sGardenClient kubernetes.Interface, logger logrus.FieldLogger, shoot *v1beta1.Shoot) (*GardenerTestOperation, error)

NewGardenTestOperation initializes a new test operation from created shoot Objects that can be used to issue commands against seeds and shoots

func (*GardenerTestOperation) DashboardAvailable

func (o *GardenerTestOperation) DashboardAvailable(ctx context.Context) error

DashboardAvailable checks if the kubernetes dashboard is available

func (*GardenerTestOperation) DeployChart

func (o *GardenerTestOperation) DeployChart(ctx context.Context, namespace, chartRepoDestination, chartNameToDeploy string, values map[string]interface{}) error

DeployChart deploys it on the test shoot

func (*GardenerTestOperation) DownloadChartArtifacts

func (o *GardenerTestOperation) 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 (*GardenerTestOperation) DownloadKubeconfig

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

DownloadKubeconfig downloads the shoot Kubeconfig

func (*GardenerTestOperation) GetCloudProvider

func (o *GardenerTestOperation) GetCloudProvider() (v1beta1.CloudProvider, error)

GetCloudProvider returns the cloud provider for the shoot

func (*GardenerTestOperation) GetDashboardPodIP

func (o *GardenerTestOperation) GetDashboardPodIP(ctx context.Context) (string, error)

GetDashboardPodIP gets the dashboard IP

func (*GardenerTestOperation) GetElasticsearchLogs

func (o *GardenerTestOperation) GetElasticsearchLogs(ctx context.Context, elasticsearchNamespace, podName string, client kubernetes.Interface) (*SearchResponse, error)

GetElasticsearchLogs gets logs for <podName> from the elasticsearch instance in <elasticsearchNamespace>

func (*GardenerTestOperation) GetFirstRunningPodWithLabels

func (o *GardenerTestOperation) 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 (*GardenerTestOperation) GetPodsByLabels

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

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

func (*GardenerTestOperation) HTTPGet

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

HTTPGet performs an HTTP GET request with context

func (*GardenerTestOperation) KibanaDashboardAvailable

func (o *GardenerTestOperation) KibanaDashboardAvailable(ctx context.Context) error

KibanaDashboardAvailable checks if Kibana instance in shoot seed namespace is available

func (*GardenerTestOperation) PodExecByLabel

func (o *GardenerTestOperation) 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 (*GardenerTestOperation) SeedCloudProvider

func (o *GardenerTestOperation) SeedCloudProvider() (v1beta1.CloudProvider, error)

SeedCloudProvider gets the Seed cluster's CloudProvider

func (*GardenerTestOperation) ShootSeedNamespace

func (o *GardenerTestOperation) ShootSeedNamespace() string

ShootSeedNamespace gets the shoot namespace in the seed

func (*GardenerTestOperation) WaitUntilDeploymentIsRunning

func (o *GardenerTestOperation) WaitUntilDeploymentIsRunning(ctx context.Context, deploymentName, deploymentNamespace string, c kubernetes.Interface) error

WaitUntilDeploymentIsRunning waits until the deployment with <deploymentName> is running

func (*GardenerTestOperation) WaitUntilDeploymentsWithLabelsIsReady

func (o *GardenerTestOperation) WaitUntilDeploymentsWithLabelsIsReady(ctx context.Context, deploymentLabels labels.Selector, namespace string, client kubernetes.Interface) error

WaitUntilDeploymentsWithLabelsIsReady wait until pod with labels <podLabels> is running

func (*GardenerTestOperation) WaitUntilElasticsearchReceivesLogs

func (o *GardenerTestOperation) WaitUntilElasticsearchReceivesLogs(ctx context.Context, elasticsearchNamespace, podName string, expected uint64, client kubernetes.Interface) error

WaitUntilElasticsearchReceivesLogs waits until the elasticsearch instance in <elasticsearchNamespace> receives <expected> logs from <podName>

func (*GardenerTestOperation) WaitUntilGuestbookAppIsAvailable

func (o *GardenerTestOperation) WaitUntilGuestbookAppIsAvailable(ctx context.Context, guestbookAppUrls []string) error

WaitUntilGuestbookAppIsAvailable waits until the guestbook app is available and ready to serve requests

func (*GardenerTestOperation) WaitUntilPodIsRunning

func (o *GardenerTestOperation) WaitUntilPodIsRunning(ctx context.Context, podName, podNamespace string, c kubernetes.Interface) error

WaitUntilPodIsRunning waits until the pod with <podName> is running

func (*GardenerTestOperation) WaitUntilPodIsRunningWithLabels

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

WaitUntilPodIsRunningWithLabels waits until the pod with <podLabels> is running

func (*GardenerTestOperation) WaitUntilStatefulSetIsRunning

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

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

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 PlantTest

type PlantTest struct {
	GardenClient kubernetes.Interface
	Plant        *gardencorev1alpha1.Plant

	//PlantSecret                   *v1.Secret
	Logger *logrus.Logger
	// contains filtered or unexported fields
}

PlantTest represents an instance of shoot tests which entails all necessary data

func NewPlantTest

func NewPlantTest(kubeconfig string, kubeconfigPathExternalCluster string, plant *gardencorev1alpha1.Plant, logger *logrus.Logger) (*PlantTest, error)

NewPlantTest creates a new plantGardenerTest object, given an already created plant (created after parsing a plant YAML) and a path to a kubeconfig of an external cluster

func (*PlantTest) CreatePlant

func (s *PlantTest) CreatePlant(ctx context.Context, secret *v1.Secret) error

CreatePlant Creates a plant from a plant Object

func (*PlantTest) CreatePlantSecret

func (s *PlantTest) CreatePlantSecret(ctx context.Context, kubeConfigContent []byte) (*v1.Secret, error)

CreatePlantSecret creates a new Secret for the Plant

func (*PlantTest) DeletePlant

func (s *PlantTest) DeletePlant(ctx context.Context) error

DeletePlant deletes the test plant

func (*PlantTest) GetPlant

func (s *PlantTest) GetPlant(ctx context.Context) (*gardencorev1alpha1.Plant, error)

GetPlant gets the test plant

func (*PlantTest) GetPlantSecret

func (s *PlantTest) GetPlantSecret(ctx context.Context) (*v1.Secret, error)

GetPlantSecret retrieves the Secret of the Plant. Returns the Secret.

func (*PlantTest) UpdatePlantSecret

func (s *PlantTest) UpdatePlantSecret(ctx context.Context, updatedPlantSecret *v1.Secret) error

UpdatePlantSecret updates the Secret of the Plant

func (*PlantTest) WaitForPlantToBeCreated

func (s *PlantTest) WaitForPlantToBeCreated(ctx context.Context) error

WaitForPlantToBeCreated waits for the plant to be created

func (*PlantTest) WaitForPlantToBeDeleted

func (s *PlantTest) WaitForPlantToBeDeleted(ctx context.Context) error

WaitForPlantToBeDeleted waits for the plant to be deleted

func (*PlantTest) WaitForPlantToBeReconciledSuccessfully

func (s *PlantTest) WaitForPlantToBeReconciledSuccessfully(ctx context.Context) error

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

func (*PlantTest) WaitForPlantToBeReconciledWithUnknownStatus

func (s *PlantTest) WaitForPlantToBeReconciledWithUnknownStatus(ctx context.Context) error

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

type SchedulerGardenerTest

type SchedulerGardenerTest struct {
	ShootGardenerTest      *ShootGardenerTest
	CloudProfile           *v1beta1.CloudProfile
	SchedulerConfiguration *config.SchedulerConfiguration
	Seeds                  []v1beta1.Seed
}

SchedulerGardenerTest represents an instance of scheduler tests which contains a shoot test & adds the scheduler configuration

func NewGardenSchedulerTest

func NewGardenSchedulerTest(ctx context.Context, shootGardenTest *ShootGardenerTest) (*SchedulerGardenerTest, error)

NewGardenSchedulerTest creates a new SchedulerGardenerTest by retrieving the ConfigMap containing the Scheduler Configuration & parsing the Scheduler Configuration

func (*SchedulerGardenerTest) ChooseRegionAndZoneWithNoSeed

func (s *SchedulerGardenerTest) ChooseRegionAndZoneWithNoSeed() (*gardenv1beta1.CloudProvider, *string, []string, error)

ChooseRegionAndZoneWithNoSeed determines all available Zones from the Shoot and the CloudProfile and then delegates the choosing of a region were no seed is deployed

func (*SchedulerGardenerTest) ChooseSeedWhereTestShootIsNotDeployed

func (s *SchedulerGardenerTest) ChooseSeedWhereTestShootIsNotDeployed(shoot *gardenv1beta1.Shoot) (*gardenv1beta1.Seed, error)

ChooseSeedWhereTestShootIsNotDeployed determines a Seed different from the shoot's seed respecting the CloudProvider If none can be found, it returns an error

func (*SchedulerGardenerTest) CreateShoot

CreateShoot Creates a shoot from a shoot Object

func (*SchedulerGardenerTest) GenerateInvalidSeed

func (s *SchedulerGardenerTest) GenerateInvalidSeed() (*gardenv1beta1.Seed, error)

GenerateInvalidSeed generates a seed with an invalid dummy name

func (*SchedulerGardenerTest) GenerateInvalidShoot

func (s *SchedulerGardenerTest) GenerateInvalidShoot() (*gardenv1beta1.Shoot, error)

GenerateInvalidShoot generates a shoot with an invalid dummy name

func (*SchedulerGardenerTest) ScheduleShoot

func (s *SchedulerGardenerTest) ScheduleShoot(ctx context.Context, shoot *gardenv1beta1.Shoot, seed *gardenv1beta1.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 (*SchedulerGardenerTest) WaitForShootToBeScheduled

func (s *SchedulerGardenerTest) WaitForShootToBeScheduled(ctx context.Context) error

WaitForShootToBeScheduled waits for the shoot to be scheduled successfully

func (*SchedulerGardenerTest) WaitForShootToBeUnschedulable

func (s *SchedulerGardenerTest) WaitForShootToBeUnschedulable(ctx context.Context) error

WaitForShootToBeUnschedulable waits for the shoot to be unschedulable. This is indicated by Events created by the scheduler on the shoot

type SearchResponse

type SearchResponse struct {
	Hits struct {
		Total uint64 `json:"total"`
	} `json:"hits"`
}

SearchResponse represents the response from a search query to elasticsearch

type ShootGardenerTest

type ShootGardenerTest struct {
	GardenClient kubernetes.Interface

	Shoot  *v1beta1.Shoot
	Logger *logrus.Logger
}

ShootGardenerTest represents an instance of shoot tests which entails all necessary data

func NewShootGardenerTest

func NewShootGardenerTest(kubeconfig string, shoot *v1beta1.Shoot, logger *logrus.Logger) (*ShootGardenerTest, error)

NewShootGardenerTest creates a new shootGardenerTest object, given an already created shoot (created after parsing a shoot YAML)

func (*ShootGardenerTest) AnnotateShoot

func (s *ShootGardenerTest) AnnotateShoot(ctx context.Context, annotations map[string]string) error

AnnotateShoot adds shoot annotation(s)

func (*ShootGardenerTest) CreateShoot

func (s *ShootGardenerTest) CreateShoot(ctx context.Context) (*v1beta1.Shoot, error)

CreateShoot Creates a shoot from a shoot Object

func (*ShootGardenerTest) DeleteShoot

func (s *ShootGardenerTest) DeleteShoot(ctx context.Context) error

DeleteShoot deletes the test shoot

func (*ShootGardenerTest) GetShoot

func (s *ShootGardenerTest) GetShoot(ctx context.Context) (*v1beta1.Shoot, error)

GetShoot gets the test shoot

func (*ShootGardenerTest) RemoveShootAnnotation

func (s *ShootGardenerTest) RemoveShootAnnotation(ctx context.Context, annotationKey string) error

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

func (*ShootGardenerTest) WaitForShootToBeCreated

func (s *ShootGardenerTest) WaitForShootToBeCreated(ctx context.Context) error

WaitForShootToBeCreated waits for the shoot to be created

func (*ShootGardenerTest) WaitForShootToBeDeleted

func (s *ShootGardenerTest) WaitForShootToBeDeleted(ctx context.Context) error

WaitForShootToBeDeleted waits for the shoot to be deleted

Directories

Path Synopsis
Package networkpolicies contain all network policies for various providers.
Package networkpolicies contain all network policies for various providers.

Jump to

Keyboard shortcuts

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