Documentation ¶
Index ¶
- Constants
- func ParseMetrics(metrics []byte) (model.Vector, error)
- func WithBody(b string) func(*HTTPOptions)
- func WithHTTPS() func(*HTTPOptions)
- func WithMethod(m string) func(*HTTPOptions)
- func WithPath(p string) func(*HTTPOptions)
- func WithPort(p string) func(*HTTPOptions)
- type AssertOption
- type Framework
- func (f *Framework) AssertAlertmanagerAbsent(t *testing.T, name, namespace string)
- func (f *Framework) AssertDeploymentReady(name, namespace string, fns ...OptionFn) func(t *testing.T)
- func (f *Framework) AssertNoEventWithReason(t *testing.T, reason string)
- func (f *Framework) AssertNoReconcileErrors(t *testing.T)
- func (f *Framework) AssertPromQLResult(t *testing.T, expr string, callback func(model.Value) error) error
- func (f *Framework) AssertPrometheusReplicaStatus(name, namespace string, expectedReplicas int32, fns ...OptionFn) func(t *testing.T)
- func (f *Framework) AssertResourceAbsent(name, namespace string, resource client.Object, fns ...OptionFn) func(t *testing.T)
- func (f *Framework) AssertResourceEventuallyExists(name, namespace string, resource client.Object, fns ...OptionFn) func(t *testing.T)
- func (f *Framework) AssertResourceNeverExists(name, namespace string, resource client.Object, fns ...OptionFn) func(t *testing.T)
- func (f *Framework) AssertStatefulsetReady(name, namespace string, fns ...OptionFn) func(t *testing.T)
- func (f *Framework) CleanUp(t *testing.T, cleanupFunc func())
- func (f *Framework) Evict(pod *corev1.Pod, gracePeriodSeconds int64) error
- func (f *Framework) GetOperatorPod(t *testing.T) *v1.Pod
- func (f *Framework) GetPodMetrics(pod *v1.Pod, opts ...func(*HTTPOptions)) ([]byte, error)
- func (f *Framework) GetResourceWithRetry(t *testing.T, name, namespace string, obj client.Object)
- func (f *Framework) GetStackWhenAvailable(t *testing.T, name, namespace string) v1alpha1.MonitoringStack
- func (f *Framework) GetStatefulSetPods(name string, namespace string) ([]corev1.Pod, error)
- func (f *Framework) Setup() error
- func (f *Framework) StartPortForward(podName string, ns string, port string, stopChan chan struct{}, ...) error
- func (f *Framework) StartServicePortForward(serviceName string, ns string, port string, stopChan chan struct{}) error
- func (f *Framework) UpdateWithRetry(t *testing.T, ms *stack.MonitoringStack, fns ...MonitoringStackConfig) error
- type HTTPOptions
- type MonitoringStackConfig
- type OptionFn
- type PrometheusClient
- type PrometheusResponse
Constants ¶
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 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 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 (*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 (*Framework) AssertNoReconcileErrors ¶
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) GetOperatorPod ¶
GetOperatorPod gets the operator's pod.
func (*Framework) GetPodMetrics ¶
GetPodMetrics requests the /metrics endpoint from the pod.
func (*Framework) GetResourceWithRetry ¶
func (*Framework) GetStackWhenAvailable ¶
func (*Framework) GetStatefulSetPods ¶
func (*Framework) Setup ¶
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 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