framework

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2024 License: Apache-2.0 Imports: 35 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultTestTimeout = 40 * time.Second

default ForeverTestTimeout is 30, some test fail because they take more than 30s change to custom in order to let the test finish withouth errors

Variables

This section is empty.

Functions

func ParseMetrics

func ParseMetrics(metrics []byte) (model.Vector, error)

func WithBody

func WithBody(b string) func(*HTTPOptions)

func WithHTTPS

func WithHTTPS() func(*HTTPOptions)

func WithMethod

func WithMethod(m string) func(*HTTPOptions)

func WithPath

func WithPath(p string) func(*HTTPOptions)

func WithPort

func WithPort(p string) func(*HTTPOptions)

Types

type AssertOption

type AssertOption struct {
	PollInterval time.Duration
	WaitTimeout  time.Duration
}

type Framework

type Framework struct {
	Config             *rest.Config
	K8sClient          client.Client
	Retain             bool
	IsOpenshiftCluster bool
	RootCA             *x509.CertPool
	MetricsClientCert  *tls.Certificate
	OperatorNamespace  string
	// contains filtered or unexported fields
}

func (*Framework) AssertAlertmanagerAbsent

func (f *Framework) AssertAlertmanagerAbsent(t *testing.T, name, namespace string)

func (*Framework) AssertDeploymentReady

func (f *Framework) AssertDeploymentReady(name, namespace string, fns ...OptionFn) func(t *testing.T)

AssertDeploymentReady asserts that a deployment has the desired number of pods running

func (*Framework) AssertNoEventWithReason

func (f *Framework) AssertNoEventWithReason(t *testing.T, reason string)

func (*Framework) AssertNoReconcileErrors

func (f *Framework) AssertNoReconcileErrors(t *testing.T)

AssertNoReconcileErrors asserts that there are no reconcilation errors

func (*Framework) AssertPromQLResult

func (f *Framework) AssertPromQLResult(t *testing.T, expr string, callback func(model.Value) error) error

AssertPromQLResult evaluates the PromQL expression against the in-cluster Prometheus stack. It returns an error if the request fails. Otherwise the result is passed to the callback function for additional checks.

func (*Framework) AssertPrometheusReplicaStatus

func (f *Framework) AssertPrometheusReplicaStatus(name, namespace string, expectedReplicas int32, fns ...OptionFn) func(t *testing.T)

AssertPrometheusReplicaStatus asserts that prometheus is scaled correctly duration a time period of customForeverTestTimeout

func (*Framework) AssertResourceAbsent

func (f *Framework) AssertResourceAbsent(name, namespace string, resource client.Object, fns ...OptionFn) func(t *testing.T)

AssertResourceAbsent asserts that a resource is not present or, if present, is deleted within the timeout

func (*Framework) AssertResourceEventuallyExists

func (f *Framework) AssertResourceEventuallyExists(name, namespace string, resource client.Object, fns ...OptionFn) func(t *testing.T)

AssertResourceEventuallyExists asserts that a resource is created duration a time period of customForeverTestTimeout

func (*Framework) AssertResourceNeverExists

func (f *Framework) AssertResourceNeverExists(name, namespace string, resource client.Object, fns ...OptionFn) func(t *testing.T)

AssertResourceNeverExists asserts that a resource is never created for the duration of the timeout

func (*Framework) AssertStatefulsetReady

func (f *Framework) AssertStatefulsetReady(name, namespace string, fns ...OptionFn) func(t *testing.T)

AssertStatefulsetReady asserts that a statefulset has the desired number of pods running

func (*Framework) CleanUp

func (f *Framework) CleanUp(t *testing.T, cleanupFunc func())

func (*Framework) Evict

func (f *Framework) Evict(pod *corev1.Pod, gracePeriodSeconds int64) error

func (*Framework) GetOperatorPod

func (f *Framework) GetOperatorPod(t *testing.T) *v1.Pod

GetOperatorPod gets the operator's pod.

func (*Framework) GetPodMetrics

func (f *Framework) GetPodMetrics(pod *v1.Pod, opts ...func(*HTTPOptions)) ([]byte, error)

GetPodMetrics requests the /metrics endpoint from the pod.

func (*Framework) GetResourceWithRetry

func (f *Framework) GetResourceWithRetry(t *testing.T, name, namespace string, obj client.Object)

func (*Framework) GetStackWhenAvailable

func (f *Framework) GetStackWhenAvailable(t *testing.T, name, namespace string) v1alpha1.MonitoringStack

func (*Framework) GetStatefulSetPods

func (f *Framework) GetStatefulSetPods(name string, namespace string) ([]corev1.Pod, error)

func (*Framework) Setup

func (f *Framework) Setup() error

Setup finalizes the initilization of the Framework object by setting parameters which are specific to OpenShift.

func (*Framework) StartPortForward

func (f *Framework) StartPortForward(podName string, ns string, port string, stopChan chan struct{}, errChan chan error) error

StartPortForward initiates a port forwarding connection to a pod on the localhost interface.

The function call blocks until the port forwarding proxy server is ready to receive connections. The errChan parameter can be used to retrieve errors happening after the port-fowarding connection is in place.

func (*Framework) StartServicePortForward

func (f *Framework) StartServicePortForward(serviceName string, ns string, port string, stopChan chan struct{}) error

StartServicePortForward initiates a port forwarding connection to a service on the localhost interface.

The function call blocks until the port forwarding proxy server is ready to receive connections.

func (*Framework) UpdateWithRetry

func (f *Framework) UpdateWithRetry(t *testing.T, ms *stack.MonitoringStack, fns ...MonitoringStackConfig) error

UpdateWithRetry updates monitoringstack with retry

type HTTPOptions

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

type MonitoringStackConfig

type MonitoringStackConfig func(monitoringStack *stack.MonitoringStack)

func SetAlertmanagerDisabled

func SetAlertmanagerDisabled(disabled bool) MonitoringStackConfig

func SetPrometheusReplicas

func SetPrometheusReplicas(replicas int32) MonitoringStackConfig

func SetResourceSelector

func SetResourceSelector(resourceSelector *v1.LabelSelector) MonitoringStackConfig

type OptionFn

type OptionFn func(*AssertOption)

func WithPollInterval

func WithPollInterval(d time.Duration) OptionFn

func WithTimeout

func WithTimeout(d time.Duration) OptionFn

type PrometheusClient

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

PrometheusClient is an HTTP-based client for querying a Prometheus server

func NewPrometheusClient

func NewPrometheusClient(url string) *PrometheusClient

func NewTLSPrometheusClient

func NewTLSPrometheusClient(url string, caCert string, serverName string) (*PrometheusClient, error)

func (*PrometheusClient) Query

func (c *PrometheusClient) Query(query string) (*PrometheusResponse, error)

type PrometheusResponse

type PrometheusResponse struct {
	Status string                 `json:"status"`
	Error  string                 `json:"error"`
	Data   prometheusResponseData `json:"data"`
}

PrometheusResponse is used to contain prometheus query results

Jump to

Keyboard shortcuts

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