framework

package
v0.0.0-...-398e186 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2023 License: BSD-3-Clause, Apache-2.0 Imports: 32 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ValidAlertmanagerConfig = `` /* 229-byte string literal not displayed */

Functions

func AddLabelsToNamespace

func AddLabelsToNamespace(kubeClient kubernetes.Interface, name string, additionalLabels map[string]string) error

func CreateClusterRole

func CreateClusterRole(kubeClient kubernetes.Interface, relativePath string) error

func CreateClusterRoleBinding

func CreateClusterRoleBinding(kubeClient kubernetes.Interface, ns string, relativePath string) (finalizerFn, error)

func CreateDeployment

func CreateDeployment(kubeClient kubernetes.Interface, namespace string, d *appsv1.Deployment) error

func CreateIngress

func CreateIngress(kubeClient kubernetes.Interface, namespace string, i *v1beta1.Ingress) error

func CreateNamespace

func CreateNamespace(kubeClient kubernetes.Interface, name string) (*v1.Namespace, error)

func CreateRoleBinding

func CreateRoleBinding(kubeClient kubernetes.Interface, ns string, relativePath string) (finalizerFn, error)

func CreateServiceAccount

func CreateServiceAccount(kubeClient kubernetes.Interface, namespace string, relativPath string) (finalizerFn, error)

func CreateServiceAndWaitUntilReady

func CreateServiceAndWaitUntilReady(kubeClient kubernetes.Interface, namespace string, service *v1.Service) (finalizerFn, error)

func DeleteClusterRole

func DeleteClusterRole(kubeClient kubernetes.Interface, relativePath string) error

func DeleteClusterRoleBinding

func DeleteClusterRoleBinding(kubeClient kubernetes.Interface, relativePath string) error

func DeleteDeployment

func DeleteDeployment(kubeClient kubernetes.Interface, namespace, name string) error

func DeleteNamespace

func DeleteNamespace(kubeClient kubernetes.Interface, name string) error

func DeleteNginxIngressControllerIncDefaultBackend

func DeleteNginxIngressControllerIncDefaultBackend(kubeClient kubernetes.Interface, namespace string) error

func DeleteRoleBinding

func DeleteRoleBinding(kubeClient kubernetes.Interface, ns string, relativePath string) error

func DeleteServiceAccount

func DeleteServiceAccount(kubeClient kubernetes.Interface, namespace string, relativPath string) error

func DeleteServiceAndWaitUntilGone

func DeleteServiceAndWaitUntilGone(kubeClient kubernetes.Interface, namespace string, serviceName string) error

func GetIngressIP

func GetIngressIP(kubeClient kubernetes.Interface, namespace string, ingressName string) (*string, error)

func GetLogs

func GetLogs(kubeClient kubernetes.Interface, namespace string, podName, containerName string) (string, error)

func MakeBasicIngress

func MakeBasicIngress(serviceName string, servicePort int) *v1beta1.Ingress

func MakeDeployment

func MakeDeployment(pathToYaml string) (*appsv1.Deployment, error)

func PathToOSFile

func PathToOSFile(relativPath string) (*os.File, error)

func ProxyGetPod

func ProxyGetPod(kubeClient kubernetes.Interface, namespace, podName, path string) *rest.Request

func ProxyPostPod

func ProxyPostPod(kubeClient kubernetes.Interface, namespace, podName, path, body string) *rest.Request

func SetupNginxIngressControllerIncDefaultBackend

func SetupNginxIngressControllerIncDefaultBackend(kubeClient kubernetes.Interface, namespace string) error

func WaitForHTTPSuccessStatusCode

func WaitForHTTPSuccessStatusCode(timeout time.Duration, url string) error

func WaitForPodsReady

func WaitForPodsReady(kubeClient kubernetes.Interface, namespace string, timeout time.Duration, expectedReplicas int, opts metav1.ListOptions) error

WaitForPodsReady waits for a selection of Pods to be running and each container to pass its readiness check.

func WaitForPodsRunImage

func WaitForPodsRunImage(kubeClient kubernetes.Interface, namespace string, expectedReplicas int, image string, opts metav1.ListOptions) error

func WaitForServiceReady

func WaitForServiceReady(kubeClient kubernetes.Interface, namespace string, serviceName string) error

func WaitUntilDeploymentGone

func WaitUntilDeploymentGone(kubeClient kubernetes.Interface, namespace, name string, timeout time.Duration) error

Types

type Framework

type Framework struct {
	KubeClient     kubernetes.Interface
	MonClientV1    monitoringclient.MonitoringV1Interface
	HTTPClient     *http.Client
	MasterHost     string
	DefaultTimeout time.Duration
}

func New

func New(kubeconfig, opImage string) (*Framework, error)

New setups a test framework and returns it.

func (*Framework) AddAlertingToPrometheus

func (f *Framework) AddAlertingToPrometheus(p *monitoringv1.Prometheus, ns, name string)

func (*Framework) AlertmanagerConfigSecret

func (f *Framework) AlertmanagerConfigSecret(ns, name string) (*v1.Secret, error)

func (*Framework) CheckPrometheusFiringAlert

func (f *Framework) CheckPrometheusFiringAlert(ns, svcName, alertName string) (bool, error)

func (*Framework) CreateAlertmanagerAndWaitUntilReady

func (f *Framework) CreateAlertmanagerAndWaitUntilReady(ns string, a *monitoringv1.Alertmanager) (*monitoringv1.Alertmanager, error)

func (*Framework) CreatePrometheusAndWaitUntilReady

func (f *Framework) CreatePrometheusAndWaitUntilReady(ns string, p *monitoringv1.Prometheus) (*monitoringv1.Prometheus, error)

func (*Framework) CreatePrometheusOperator

func (f *Framework) CreatePrometheusOperator(ns, opImage string, namespacesToWatch []string) error

CreatePrometheusOperator creates a Prometheus Operator Kubernetes Deployment inside the specified namespace using the specified operator image. In addition one can specify the namespaces to watch, which defaults to all namespaces.

func (*Framework) CreateRule

func (*Framework) CreateSilence

func (f *Framework) CreateSilence(ns, n string) (string, error)

func (*Framework) DeleteAlertmanagerAndWaitUntilGone

func (f *Framework) DeleteAlertmanagerAndWaitUntilGone(ns, name string) error

func (*Framework) DeletePrometheusAndWaitUntilGone

func (f *Framework) DeletePrometheusAndWaitUntilGone(ns, name string) error

func (*Framework) DeleteRule

func (f *Framework) DeleteRule(ns string, r string) error

func (*Framework) GetActiveTargets

func (f *Framework) GetActiveTargets(ns, svcName string) ([]*Target, error)

func (*Framework) GetAlertmanagerStatus

func (f *Framework) GetAlertmanagerStatus(ns, n string) (amAPIStatusResp, error)

func (*Framework) GetPodRestartCount

func (f *Framework) GetPodRestartCount(ns, podName string) (map[string]int32, error)

GetPodRestartCount returns a map of container names and their restart counts for a given pod.

func (*Framework) GetSilences

func (f *Framework) GetSilences(ns, n string) ([]amAPISil, error)

func (*Framework) MakeAlertmanagerService

func (f *Framework) MakeAlertmanagerService(name, group string, serviceType v1.ServiceType) *v1.Service

func (*Framework) MakeAndCreateFiringRule

func (f *Framework) MakeAndCreateFiringRule(ns, name, alertName string) (*monitoringv1.PrometheusRule, error)

func (*Framework) MakeBasicAlertmanager

func (f *Framework) MakeBasicAlertmanager(name string, replicas int32) *monitoringv1.Alertmanager

func (*Framework) MakeBasicPrometheus

func (f *Framework) MakeBasicPrometheus(ns, name, group string, replicas int32) *monitoringv1.Prometheus

func (*Framework) MakeBasicRule

func (f *Framework) MakeBasicRule(ns, name string, groups []monitoringv1.RuleGroup) *monitoringv1.PrometheusRule

func (*Framework) MakeBasicServiceMonitor

func (f *Framework) MakeBasicServiceMonitor(name string) *monitoringv1.ServiceMonitor

func (*Framework) MakePrometheusService

func (f *Framework) MakePrometheusService(name, group string, serviceType v1.ServiceType) *v1.Service

func (*Framework) MakeThanosQuerierService

func (f *Framework) MakeThanosQuerierService(name string) *v1.Service

func (*Framework) MakeThanosService

func (f *Framework) MakeThanosService(name string) *v1.Service

func (*Framework) NewTestCtx

func (f *Framework) NewTestCtx(t *testing.T) TestCtx

func (*Framework) Poll

func (f *Framework) Poll(timeout, pollInterval time.Duration, pollFunc func() (bool, error)) error

func (*Framework) PrintEvents

func (f *Framework) PrintEvents() error

PrintEvents prints the Kubernetes events to standard out.

func (*Framework) PrintPodLogs

func (f *Framework) PrintPodLogs(ns, p string) error

PrintPodLogs prints the logs of a specified Pod

func (*Framework) QueryPrometheusSVC

func (f *Framework) QueryPrometheusSVC(ns, svcName, endpoint string, query map[string]string) ([]byte, error)

func (*Framework) SecretFromYaml

func (f *Framework) SecretFromYaml(filepath string) (*v1.Secret, error)

func (*Framework) SendAlertToAlertmanager

func (f *Framework) SendAlertToAlertmanager(ns, n string, start time.Time) error

SendAlertToAlertmanager sends an alert to the alertmanager in the given namespace (ns) with the given name (n).

func (*Framework) UpdateAlertmanagerAndWaitUntilReady

func (f *Framework) UpdateAlertmanagerAndWaitUntilReady(ns string, a *monitoringv1.Alertmanager) (*monitoringv1.Alertmanager, error)

func (*Framework) UpdatePrometheusAndWaitUntilReady

func (f *Framework) UpdatePrometheusAndWaitUntilReady(ns string, p *monitoringv1.Prometheus) (*monitoringv1.Prometheus, error)

func (*Framework) UpdateRule

func (*Framework) WaitForAlertmanagerConfigToContainString

func (f *Framework) WaitForAlertmanagerConfigToContainString(ns, amName, expectedString string) error

WaitForAlertmanagerConfigToContainString retrieves the Alertmanager configuration via the Alertmanager's API and checks if it contains the given string.

func (*Framework) WaitForAlertmanagerInitializedMesh

func (f *Framework) WaitForAlertmanagerInitializedMesh(ns, name string, amountPeers int) error

func (*Framework) WaitForAlertmanagerReady

func (f *Framework) WaitForAlertmanagerReady(ns, name string, replicas int) error

func (*Framework) WaitForConfigMapExist

func (f *Framework) WaitForConfigMapExist(ns, name string) (*v1.ConfigMap, error)

func (*Framework) WaitForConfigMapNotExist

func (f *Framework) WaitForConfigMapNotExist(ns, name string) error

func (*Framework) WaitForPrometheusFiringAlert

func (f *Framework) WaitForPrometheusFiringAlert(ns, svcName, alertName string) error

func (*Framework) WaitForPrometheusReady

func (f *Framework) WaitForPrometheusReady(p *monitoringv1.Prometheus, timeout time.Duration) error

func (*Framework) WaitForPrometheusRunImageAndReady

func (f *Framework) WaitForPrometheusRunImageAndReady(ns string, p *monitoringv1.Prometheus) error

func (*Framework) WaitForRule

func (f *Framework) WaitForRule(ns, name string) error

WaitForRule waits for a rule file with a given name to exist in a given namespace.

func (*Framework) WaitForTargets

func (f *Framework) WaitForTargets(ns, svcName string, amount int) error

type Target

type Target struct {
	ScrapeURL string `json:"scrapeUrl"`
}

type TestCtx

type TestCtx struct {
	ID string
	// contains filtered or unexported fields
}

func (*TestCtx) AddFinalizerFn

func (ctx *TestCtx) AddFinalizerFn(fn finalizerFn)

func (*TestCtx) Cleanup

func (ctx *TestCtx) Cleanup(t *testing.T)

func (*TestCtx) CreateNamespace

func (ctx *TestCtx) CreateNamespace(t *testing.T, kubeClient kubernetes.Interface) string

func (*TestCtx) GetObjID

func (ctx *TestCtx) GetObjID() string

GetObjID returns an ascending ID based on the length of cleanUpFns. It is based on the premise that every new object also appends a new finalizerFn on cleanUpFns. This can e.g. be used to create multiple namespaces in the same test context.

func (*TestCtx) SetupPrometheusRBAC

func (ctx *TestCtx) SetupPrometheusRBAC(t *testing.T, ns string, kubeClient kubernetes.Interface)

func (*TestCtx) SetupPrometheusRBACGlobal

func (ctx *TestCtx) SetupPrometheusRBACGlobal(t *testing.T, ns string, kubeClient kubernetes.Interface)

Jump to

Keyboard shortcuts

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