framework

package
v0.0.0-...-dac8cc8 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	AsyncOperationTimeout = 5 * time.Minute
)

Functions

func CheckEnvVars

func CheckEnvVars(want []corev1.EnvVar, have []corev1.EnvVar, includes bool) []error

func ConsoleResourcesAvailable

func ConsoleResourcesAvailable(client *ClientSet) error

func ConsoleResourcesUnavailable

func ConsoleResourcesUnavailable(client *ClientSet) error

checks 3 times if the resources are unavailable - is fine if fails or 1st or 2nd run, resources could be in the process of being removed - is not fine if resources disappear, then reappear - it seems to take a bit longer to remove resources, so this wrapper should account for that.

func DeleteAll

func DeleteAll(t *testing.T, client *ClientSet)

func DeleteCompletely

func DeleteCompletely(getObject func() (runtime.Object, error), deleteObject func(*metav1.DeleteOptions) error) error

DeleteCompletely sends a delete request and waits until the resource and its dependents are deleted.

func DumpObject

func DumpObject(t *testing.T, prefix string, obj interface{})

DumpObject prints the object to the test log.

func DumpOperatorLogs

func DumpOperatorLogs(t *testing.T, client *ClientSet)

func DumpPodLogs

func DumpPodLogs(t *testing.T, podLogs PodSetLogs)

func GenerationChanged

func GenerationChanged(oldGeneration, newGeneration int64) bool

func GetConfig

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

GetConfig creates a *rest.Config for talking to a Kubernetes apiserver. Otherwise will assume running in cluster and use the cluster provided kubeconfig.

Config precedence

* KUBECONFIG environment variable pointing at a file

* In-cluster config if running in cluster

* $HOME/.kube/config if exists

Note that if you have done `oc login...` the `current-context` will be used. this means that the test will run as whatever user is currently logged in. kube:admin has a token, but no certs. - kube:admin is an oauth user, this is why it has tokens. system:admin has certs, but no token. - system:admin is a cert based user only. other users, your mileage may vary.

func GetConsoleCLIDownloads

func GetConsoleCLIDownloads(client *ClientSet, consoleCLIDownloadName string) (*consolev1.ConsoleCLIDownload, error)

func GetConsoleConfigMap

func GetConsoleConfigMap(client *ClientSet) (*corev1.ConfigMap, error)

func GetConsoleDeployment

func GetConsoleDeployment(client *ClientSet) (*appv1.Deployment, error)

func GetConsolePodDisruptionBudget

func GetConsolePodDisruptionBudget(client *ClientSet, pdbName string) (*policyv1.PodDisruptionBudget, error)

func GetConsoleRoute

func GetConsoleRoute(client *ClientSet) (*routev1.Route, error)

func GetConsoleService

func GetConsoleService(client *ClientSet) (*corev1.Service, error)

func GetCustomLogoConfigMap

func GetCustomLogoConfigMap(client *ClientSet) (*corev1.ConfigMap, error)

custom-logo in openshift-console should exist when custom branding is used

func GetDownloadsDeployment

func GetDownloadsDeployment(client *ClientSet) (*appv1.Deployment, error)

func GetResource

func GetResource(client *ClientSet, resource TestingResource) (runtime.Object, error)

func IsResourceAvailable

func IsResourceAvailable(errChan chan error, client *ClientSet, resource TestingResource)

IsResourceAvailable checks if tested resource is available during a 30 second period. if the resource does not exist by the end of the period, an error will be returned.

func IsResourceUnavailable

func IsResourceUnavailable(errChan chan error, client *ClientSet, resource TestingResource)

IsResourceUnavailable checks if tested resource is unavailable during a 15 second period. If the resource exists during that time, an error will be returned.

func LoopResources

func LoopResources(client *ClientSet, inner func(errChan chan error, client *ClientSet, resource TestingResource)) error

func MustManageConsole

func MustManageConsole(t *testing.T, client *ClientSet) error

func MustNormalLogLevel

func MustNormalLogLevel(t *testing.T, client *ClientSet) error

func MustPristine

func MustPristine(t *testing.T, client *ClientSet) *operatorsv1.Console

func MustRemoveConsole

func MustRemoveConsole(t *testing.T, client *ClientSet) error

func MustUnmanageConsole

func MustUnmanageConsole(t *testing.T, client *ClientSet) error

func NewClientConfigForTest

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

authn operator approach to getting config. choose func as needed. https://github.com/openshift/cluster-authentication-operator/blob/master/test/library/client.go NewClientConfigForTest returns a config configured to connect to the api server

func Pristine

func Pristine(t *testing.T, client *ClientSet) (*operatorsv1.Console, error)

set the operator config to a pristine state to start a next round of tests this should by default nullify out any customizations a user sets

func ResetClusterProxyConfig

func ResetClusterProxyConfig(client *ClientSet) error

func SetClusterProxyConfig

func SetClusterProxyConfig(proxyConfig configv1.ProxySpec, client *ClientSet) error

func SetLogLevel

func SetLogLevel(t *testing.T, client *ClientSet, logLevel operatorsv1.LogLevel) error

func StandardCleanup

func StandardCleanup(t *testing.T, client *ClientSet)

courtesy func to return state to something reasonable before the next test runs.

func WaitForSettledState

func WaitForSettledState(t *testing.T, client *ClientSet, phase string) (settled bool, err error)

A helper to ensure our operator config reaches a settled state before we begin the next test.

Types

type ClientSet

ClientSet is a set of Kubernetes clients.

func MustNewClientset

func MustNewClientset(t *testing.T, kubeconfig *restclient.Config) *ClientSet

MustNewClientset is like NewClienset but aborts the test if clienset cannot be constructed.

func NewClientset

func NewClientset(kubeconfig *restclient.Config) (*ClientSet, error)

NewClientset creates a set of Kubernetes clients. The default kubeconfig is used if not provided.

func StandardSetup

func StandardSetup(t *testing.T) (*ClientSet, *v1.Console)

func that ensures a clean slate before a test runs. setup is more aggressive than cleanup as the request for a clean slate on setup is assertive, not courtesy

type PodLog

type PodLog []string

func (PodLog) Contains

func (log PodLog) Contains(re *regexp.Regexp) bool

type PodSetLogs

type PodSetLogs map[string]PodLog

func GetLogsByLabelSelector

func GetLogsByLabelSelector(client *ClientSet, namespace string, labelSelector *metav1.LabelSelector) (PodSetLogs, error)

func GetOperatorLogs

func GetOperatorLogs(client *ClientSet) (PodSetLogs, error)

func (PodSetLogs) Contains

func (psl PodSetLogs) Contains(re *regexp.Regexp) bool

type TestFramework

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

type TestingResource

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

Jump to

Keyboard shortcuts

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