framework

package
v0.0.0-...-f3f2784 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	OperatorDeploymentNamespace = "openshift-image-registry"
	OperatorDeploymentName      = "cluster-image-registry-operator"
)
View Source
const (
	ClusterVersionName = "version"
)

Variables

View Source
var AsyncOperationTimeout = 5 * time.Minute

AsyncOperationTimeout is how long we want to wait for asynchronous operations to complete. ForeverTestTimeout is not long enough to create several replicas and get them available on a slow machine.

Functions

func AreClusterOperatorsHealthy

func AreClusterOperatorsHealthy(cos []configv1.ClusterOperator) error

func CheckAbsenceOfOperatorPods

func CheckAbsenceOfOperatorPods(te TestEnv)

func CheckEnvVars

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

func CheckEnvVarsAreNotSet

func CheckEnvVarsAreNotSet(te TestEnv, got []corev1.EnvVar, names []string)

func CheckPodsAreNotRestarted

func CheckPodsAreNotRestarted(te TestEnv, labels labels.Selector)

func ConditionExistsWithStatusAndReason

func ConditionExistsWithStatusAndReason(te TestEnv, conditionType string, conditionStatus operatorapi.ConditionStatus, conditionReason string)

func CreateOrUpdateSecret

func CreateOrUpdateSecret(ctx context.Context, name string, namespace string, data map[string]string) (*corev1.Secret, error)

func DeleteCompletely

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

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

func DeployImageRegistry

func DeployImageRegistry(te TestEnv, spec *imageregistryapiv1.ImageRegistrySpec)

func DisableCVOForOperator

func DisableCVOForOperator(te TestEnv)

func DumpClusterProxyResource

func DumpClusterProxyResource(te TestEnv)

DumpClusterProxyResource prints out the cluster proxy configuration

func DumpImagePrunerResource

func DumpImagePrunerResource(logger Logger, client *Clientset)

func DumpImageRegistryDeployment

func DumpImageRegistryDeployment(te TestEnv)

func DumpImageRegistryResource

func DumpImageRegistryResource(te TestEnv)

func DumpNodeCADaemonSet

func DumpNodeCADaemonSet(te TestEnv)

func DumpObject

func DumpObject(logger Logger, prefix string, obj interface{})

DumpObject prints the object to the test log.

func DumpOperatorDeployment

func DumpOperatorDeployment(te TestEnv)

func DumpOperatorLogs

func DumpOperatorLogs(ctx context.Context, te TestEnv)

func DumpPodLogs

func DumpPodLogs(logger Logger, podLogs PodSetLogs)

func DumpYAML

func DumpYAML(logger Logger, prefix string, obj interface{})

DumpYAML prints the object to the test log as YAML.

func EncodeX509Certificate

func EncodeX509Certificate(cert *x509.Certificate) []byte

func EnsureClusterOperatorStatusIsNormal

func EnsureClusterOperatorStatusIsNormal(te TestEnv)

func EnsureClusterOperatorStatusIsSet

func EnsureClusterOperatorStatusIsSet(te TestEnv) *configapiv1.ClusterOperator

func EnsureDefaultExternalRegistryHostnameIsSet

func EnsureDefaultExternalRegistryHostnameIsSet(te TestEnv)

func EnsureDefaultExternalRouteExists

func EnsureDefaultExternalRouteExists(te TestEnv)

func EnsureExternalRegistryHostnamesAreSet

func EnsureExternalRegistryHostnamesAreSet(te TestEnv, wantedHostnames []string)

func EnsureExternalRoutesExist

func EnsureExternalRoutesExist(t *testing.T, client *Clientset, wantedRoutes []string)

func EnsureInternalRegistryHostnameIsSet

func EnsureInternalRegistryHostnameIsSet(te TestEnv)

func EnsureNodeCADaemonSetIsAvailable

func EnsureNodeCADaemonSetIsAvailable(te TestEnv)

func EnsureOperatorIsNotHotLooping

func EnsureOperatorIsNotHotLooping(te TestEnv)

func EnsureServiceCAConfigMap

func EnsureServiceCAConfigMap(te TestEnv)

func FlagExistsWithValue

func FlagExistsWithValue(args []string, flag string, value string) error

func FollowPodLog

func FollowPodLog(client *Clientset, pod corev1.Pod) (<-chan string, <-chan error, error)

FollowPodLog attaches to the pod log stream, reads it until the pod is dead or an error happens while reading.

If an error happens when fetching pod's Stream() this function returns immediately. If a failure happens during pods log read the error is sent back to the caller through an error channel.

func GenerateX509Certificate

func GenerateX509Certificate(hostname string, caCert *x509.Certificate, caPrivateKey *rsa.PrivateKey) ([]byte, []byte, error)

func GenerateX509RootCA

func GenerateX509RootCA() (*x509.Certificate, *rsa.PrivateKey, error)

func GetImageRegistryDeployment

func GetImageRegistryDeployment(te TestEnv) *appsv1.Deployment

func IsClusterOperatorHealthy

func IsClusterOperatorHealthy(co *configv1.ClusterOperator) error

func MarshalJSON

func MarshalJSON(patch interface{}) []byte

func PlatformHasDefaultStorage

func PlatformHasDefaultStorage(te TestEnv) bool

func PlatformIsOneOf

func PlatformIsOneOf(te TestEnv, platforms []configv1.PlatformType) bool

func PrunerConditionExistsWithStatusAndReason

func PrunerConditionExistsWithStatusAndReason(te TestEnv, conditionType string, conditionStatus operatorapi.ConditionStatus, conditionReason string)

func RemoveImageRegistry

func RemoveImageRegistry(te TestEnv)

func ResetClusterProxyConfig

func ResetClusterProxyConfig(te TestEnv)

ResetClusterProxyConfig patches the cluster proxy resource to contain an empty proxy configuration

func ResetResourceProxyConfig

func ResetResourceProxyConfig(te TestEnv)

ResetResourceProxyConfig patches the image registry resource to contain an empty proxy configuration

func SetClusterProxyConfig

func SetClusterProxyConfig(te TestEnv, proxyConfig openshiftapiv1.ProxySpec)

SetClusterProxyConfig patches the cluster proxy resource to contain the provided proxy configuration

func SetResourceProxyConfig

func SetResourceProxyConfig(te TestEnv, proxyConfig imageregistryapiv1.ImageRegistryConfigProxy)

SetResourceProxyConfig patches the image registry resource to contain the provided proxy configuration

func StopDeployment

func StopDeployment(te TestEnv, namespace, name string)

func TeardownImageRegistry

func TeardownImageRegistry(te TestEnv)

func WaitForNodeCADaemonSet

func WaitForNodeCADaemonSet(client *Clientset) (*appsv1.DaemonSet, error)

func WaitForRegistryDeployment

func WaitForRegistryDeployment(client *Clientset) (*kappsapiv1.Deployment, error)

func WaitUntilClusterOperatorsAreHealthy

func WaitUntilClusterOperatorsAreHealthy(te TestEnv, interval, timeout time.Duration)

func WaitUntilDeploymentIsRolledOut

func WaitUntilDeploymentIsRolledOut(te TestEnv, namespace, name string)

func WaitUntilFinalized

func WaitUntilFinalized(obj metav1.Object, getObject func() (metav1.Object, error)) error

WaitUntilFinalized waits until obj is finalized. It expects getObject to return the up-to-date version of obj.

func WaitUntilImageRegistryConfigIsProcessed

func WaitUntilImageRegistryConfigIsProcessed(te TestEnv) *imageregistryapiv1.Config

func WaitUntilImageRegistryIsAvailable

func WaitUntilImageRegistryIsAvailable(te TestEnv)

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 *Clientset, err error)

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

type ConditionStatus

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

func (ConditionStatus) IsFalse

func (cs ConditionStatus) IsFalse() bool

func (ConditionStatus) IsTrue

func (cs ConditionStatus) IsTrue() bool

func (ConditionStatus) Reason

func (cs ConditionStatus) Reason() string

func (ConditionStatus) String

func (cs ConditionStatus) String() string

type ContainerLog

type ContainerLog []string

func (ContainerLog) Contains

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

type ImageRegistryConditions

type ImageRegistryConditions struct {
	Available   ConditionStatus
	Progressing ConditionStatus
	Degraded    ConditionStatus
	Removed     ConditionStatus
}

func (ImageRegistryConditions) String

func (c ImageRegistryConditions) String() string

type JSONPatch

type JSONPatch struct {
	Op    string      `json:"op"`
	Path  string      `json:"path"`
	Value interface{} `json:"value,omitempty"`
}

type Logger

type Logger interface {
	Logf(string, ...interface{})
}

Logger is an interface to report events from tests. It is implemented by testing.T.

type PodLog

type PodLog map[string]ContainerLog

func (PodLog) Contains

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

type PodSetLogs

type PodSetLogs map[string]PodLog

func GetLogsByLabelSelector

func GetLogsByLabelSelector(ctx context.Context, client *Clientset, namespace string, labelSelector *metav1.LabelSelector, previous bool) (PodSetLogs, error)

func GetLogsForPod

func GetLogsForPod(ctx context.Context, client *Clientset, namespace string, podName string) (PodSetLogs, error)

func GetOperatorLogs

func GetOperatorLogs(ctx context.Context, client *Clientset) (PodSetLogs, error)

func (PodSetLogs) Contains

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

type TestEnv

type TestEnv interface {
	Client() *Clientset
	Failed() bool
	Log(a ...interface{})
	Logf(format string, a ...interface{})
	Error(a ...interface{})
	Errorf(format string, a ...interface{})
	Fatal(a ...interface{})
	Fatalf(format string, a ...interface{})
}

func Setup

func Setup(t *testing.T) TestEnv

func SetupAvailableImageRegistry

func SetupAvailableImageRegistry(t *testing.T, spec *imageregistryapiv1.ImageRegistrySpec) TestEnv

Directories

Path Synopsis
mock

Jump to

Keyboard shortcuts

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