framework

package
v0.104.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const OpenSourceRepositoryContext = "europe-docker.pkg.dev/sap-gcp-cp-k8s-stable-hub/landscaper"

OpenSourceRepositoryContext is the base url of the repository context for the gardener open source components. There all landscaper blueprints/components are available.

Variables

This section is empty.

Functions

func ApplyIdent

func ApplyIdent(s string, indent int) string

ApplyIdent applies the indentation to a string

func DumpConfigMap

func DumpConfigMap(logger utils.Logger, cm *corev1.ConfigMap) error

DumpConfigMap dumps information about the configmap

func DumpDeployItems

func DumpDeployItems(logger utils.Logger, deployItem *lsv1alpha1.DeployItem) error

DumpDeployItems dumps information about the deploy items

func DumpDeployment

func DumpDeployment(logger utils.Logger, deployment *appsv1.Deployment) error

DumpDeployment dumps information about the deployment

func DumpExecution

func DumpExecution(logger utils.Logger, exec *lsv1alpha1.Execution) error

DumpExecution dumps information about the execution

func DumpInstallation

func DumpInstallation(logger utils.Logger, inst *lsv1alpha1.Installation) error

DumpInstallation dumps information about the installation

func FormatAsYAML

func FormatAsYAML(obj interface{}, indent int) string

FormatAsYAML formats a object as yaml

func FormatContainerStatus

func FormatContainerStatus(status corev1.ContainerStatus, logs string, indent int) string

FormatContainerStatus returns a formatted container status.

func FormatContainerStatuses

func FormatContainerStatuses(ctx context.Context, pod *corev1.Pod, indent int, kubeClientSet kubernetes.Interface, start, end time.Time) string

FormatContainerStatuses formats the container statuses of a pod.

func FormatContainers

func FormatContainers(containers []corev1.Container, indent int) string

FormatContainers returns a pretty printed representation of a list of containers

func FormatContainersStatus

func FormatContainersStatus(containers []corev1.ContainerStatus, indent string) string

FormatContainers returns a pretty printed representation of a list of containers

func FormatLastError

func FormatLastError(err *lsv1alpha1.Error, indent string) string

FormatLastError formats a error in a human readable format.

func FormatList

func FormatList(list []string, indent int) string

FormatList creates a human readable list with the given indent.

func FormatPod

func FormatPod(ctx context.Context, pod *corev1.Pod, kubeClientSet kubernetes.Interface, indent int, start, end time.Time) string

FormatPod returns information about the pod. It also fetches the pods logs if a client is provided.

func GetContainerLogs

func GetContainerLogs(ctx context.Context, kubeClientSet kubernetes.Interface, podName, podNamespace, containerName string, start, end time.Time) ([]byte, error)

GetContainerLogs returns the logs of a container.

func StringIndent

func StringIndent(indent int) string

StringIndent creates the indentation for a number

Types

type Cleanup

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

Cleanup contains a list of Cleanup hocks

func (*Cleanup) Add

func (c *Cleanup) Add(fn func()) CleanupActionHandle

Add adds a Cleanup action function

func (*Cleanup) Remove

func (c *Cleanup) Remove(handle CleanupActionHandle)

Remove removes a Cleanup action with the given handle from the list.

func (*Cleanup) Run

func (c *Cleanup) Run(logger utils.Logger, testsFailed bool)

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

type CleanupActionHandle

type CleanupActionHandle *int

type CleanupFunc

type CleanupFunc func(ctx context.Context) error

type Dumper

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

Dumper is a struct to dump logs and useful information about known object for a state

func NewDumper

func NewDumper(logger utils.Logger, kubeClient client.Client, kubeClientSet kubernetes.Interface, lsNamespace string, namespaces ...string) *Dumper

NewDumper create a new dumper

func (*Dumper) AddNamespaces

func (d *Dumper) AddNamespaces(namespaces ...string)

AddNamespaces adds additional namespaces that should be dumped.

func (*Dumper) ClearNamespaces

func (d *Dumper) ClearNamespaces()

ClearNamespaces removes all current namespaces

func (*Dumper) Dump

func (d *Dumper) Dump(ctx context.Context) error

Dump searches for known objects in the given namespaces and dumps useful information about their state. Currently information about the main landscaper resources in dumped: - Installations - DeployItems todo: dump additional resources

func (*Dumper) DumpConfigMapsInNamespace

func (d *Dumper) DumpConfigMapsInNamespace(ctx context.Context, namespace string) error

DumpConfigMapsInNamespace dumps all configmaps in a namespace

func (*Dumper) DumpDeployItemsInNamespace

func (d *Dumper) DumpDeployItemsInNamespace(ctx context.Context, namespace string) error

DumpDeployItemsInNamespace dumps information about all deploy items int he given namespace

func (*Dumper) DumpDeploymentsInNamespace

func (d *Dumper) DumpDeploymentsInNamespace(ctx context.Context, ns string) error

DumpDeploymentsInNamespace dumps all deployment resources in a namespace.

func (*Dumper) DumpExecutionInNamespace

func (d *Dumper) DumpExecutionInNamespace(ctx context.Context, namespace string) error

DumpExecutionInNamespace dumps all executions in a namespace

func (*Dumper) DumpLandscaperResources

func (d *Dumper) DumpLandscaperResources(ctx context.Context) error

DumpLandscaperResources dumps all landscaper resources in the ls namespace.

func (*Dumper) FormatPodsWithSelector

func (d *Dumper) FormatPodsWithSelector(ctx context.Context, indent int, opts ...client.ListOption) string

FormatPodsWithSelector returns formatted pods that match a selector.

type Framework

type Framework struct {

	// RootPath is the filepath to the root of the landscaper repository
	RootPath string
	// RestConfig is the kubernetes rest config for the test cluster
	RestConfig *rest.Config
	// Client is the kubernetes client to interact with the test cluster
	Client       client.Client
	TargetClient client.Client
	// ClientSet is the kubernetes clientset to interact with the test cluster.
	ClientSet kubernetes.Interface
	// Cleanups contains all cleanup handles that are executed in the after suite
	Cleanup *Cleanup
	// LsNamespace defines the namespace where the landscaper controlplane components are deployed.
	// All functionality like waiting for the components to be ready or log dump is not available
	// if left empty.
	LsNamespace string
	// LsVersion defines the version of landscaper components to be used for the integration test
	// Will use the latest version (see VERSION) if left empty
	LsVersion string
	// DisableCleanup skips the state cleanup step
	DisableCleanup bool
	// RunOnShoot tests are executed on shoot and not a k3s cluster (only for compatibility with old setup)
	RunOnShoot bool

	// RegistryConfig defines the oci registry config file.
	// It is expected that the configfile contains exactly one server.
	RegistryConfig *configfile.ConfigFile

	RegistryConfigPath string

	RegistryCAPath string
	// RegistryBasePath defines the base path for the configured registry.
	// The base path is used to construct references for artifacts.
	RegistryBasePath string
	// OCIClient is a oci client that can up and download artifacts from the configured registry
	OCIClient ociclient.Client
	// OCICache is the oci store of the local oci client
	OCICache cache.Cache

	TestsFailed bool
	// contains filtered or unexported fields
}

Framework is the Landscaper test framework to execute tests. Also includes some helper functions.

func New

func New(logger utils2.Logger, cfg *Options) (*Framework, error)

func (*Framework) CleanupBeforeTestNamespaces

func (f *Framework) CleanupBeforeTestNamespaces(ctx context.Context) error

func (*Framework) IsRegistryEnabled

func (f *Framework) IsRegistryEnabled() bool

IsRegistryEnabled returns true if a docker registry is configured.

func (*Framework) Log

func (f *Framework) Log() utils2.Logger

Log returns the default logger

func (*Framework) NewState

func (f *Framework) NewState(ctx context.Context) (*envtest.State, CleanupFunc, error)

NewState creates a new state with a test namespace. It also returns a cleanup function that should be called when the test has finished.

func (*Framework) Register

func (f *Framework) Register() *State

Register registers the frameworks function that is called by ginkgo before and after each test

func (*Framework) TestLog

func (f *Framework) TestLog() utils2.Logger

TestLog returns a new testlogger that logs to the ginkgo managed writer

func (*Framework) WaitForSystemComponents

func (f *Framework) WaitForSystemComponents(ctx context.Context) error

WaitForSystemComponents waits for all system component of the landscaper to be ready

type Options

type Options struct {
	KubeconfigPath                 string
	RootPath                       string
	LsNamespace                    string
	LsVersion                      string
	DockerConfigPath               string
	DisableCleanup                 bool
	RunOnShoot                     bool
	DisableCleanupBefore           bool
	SkipWaitingForSystemComponents bool
	// contains filtered or unexported fields
}

func (*Options) AddFlags

func (o *Options) AddFlags(fs *flag.FlagSet)

AddFlags registers the framework related flags

func (*Options) Complete

func (o *Options) Complete() error

type State

type State struct {
	*envtest.State
	// contains filtered or unexported fields
}

State wraps the envtest.State with framework related functionality.

Jump to

Keyboard shortcuts

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