Documentation
¶
Index ¶
- Constants
- Variables
- func MakeBasicIngress(serviceName string, servicePort int) *networkv1.Ingress
- func MakeConfigMapWithCert(kubeClient kubernetes.Interface, ns, name, keyKey, certKey, caKey string, ...) *v1.ConfigMap
- func MakeDeployment(source string) (*appsv1.Deployment, error)
- func MakeSecretWithCert(ns, name string, keyList []string, dataList [][]byte) *corev1.Secret
- func MakeService(source string) (*v1.Service, error)
- func PathToOSFile(relativePath string) (*os.File, error)
- func SourceToIOReader(source string) (io.Reader, error)
- func StartPortForward(ctx context.Context, config *rest.Config, scheme string, name string, ...) (func(), error)
- func URLToIOReader(url string) (io.Reader, error)
- func WaitForCRDReady(listFunc func(opts metav1.ListOptions) (runtime.Object, error)) error
- func WaitForHTTPSuccessStatusCode(timeout time.Duration, url string) error
- type Cert
- type ExecOptions
- type FinalizerFn
- type Framework
- func (f *Framework) AddAlertingToPrometheus(p *monitoringv1.Prometheus, ns, name string)
- func (f *Framework) AddLabelsToNamespace(ctx context.Context, name string, additionalLabels map[string]string) error
- func (f *Framework) AddRemoteReceiveWithWebTLSToPrometheus(p *monitoringv1.Prometheus, prwtc PromRemoteWriteTestConfig)
- func (f *Framework) AddRemoteWriteWithTLSToPrometheus(p *monitoringv1.Prometheus, url string, prwtc PromRemoteWriteTestConfig)
- func (f *Framework) AlertmanagerConfigSecret(ns, name string) (*v1.Secret, error)
- func (f *Framework) AlertmangerSVCGetRequest(ctx context.Context, ns, svcName, endpoint string, query map[string]string) ([]byte, error)
- func (f *Framework) AssertCondition(conds []monitoringv1.Condition, expectedType monitoringv1.ConditionType, ...) error
- func (f *Framework) CheckPrometheusFiringAlert(ctx context.Context, ns, svcName, alertName string) (bool, error)
- func (f *Framework) CheckThanosFiringAlert(ctx context.Context, ns, svcName, alertName string) (bool, error)
- func (f *Framework) CreateAlertmanagerAndWaitUntilReady(ctx context.Context, a *monitoringv1.Alertmanager) (*monitoringv1.Alertmanager, error)
- func (f *Framework) CreateAlertmanagerConfig(ctx context.Context, ns, name string) (*monitoringv1alpha1.AlertmanagerConfig, error)
- func (f *Framework) CreateBlackBoxExporterAndWaitUntilReady(ctx context.Context, ns, name string) error
- func (f *Framework) CreateDeployment(ctx context.Context, namespace string, d *appsv1.Deployment) error
- func (f *Framework) CreateIngress(ctx context.Context, namespace string, i *networkv1.Ingress) error
- func (f *Framework) CreateNamespace(ctx context.Context, t *testing.T, testCtx *TestCtx) string
- func (f *Framework) CreateOrUpdateAdmissionWebhookServer(ctx context.Context, namespace string, image string) (*v1.Service, []byte, error)
- func (f *Framework) CreateOrUpdateCRD(ctx context.Context, crd *v1.CustomResourceDefinition) error
- func (f *Framework) CreateOrUpdateCRDAndWaitUntilReady(ctx context.Context, crdName string, ...) error
- func (f *Framework) CreateOrUpdateClusterRole(ctx context.Context, source string) (*rbacv1.ClusterRole, error)
- func (f *Framework) CreateOrUpdateDeploymentAndWaitUntilReady(ctx context.Context, namespace string, deployment *appsv1.Deployment) error
- func (f *Framework) CreateOrUpdatePrometheusOperator(ctx context.Context, namespace string, ...) ([]FinalizerFn, error)
- func (f *Framework) CreateOrUpdatePrometheusOperatorWithOpts(ctx context.Context, opts PrometheusOperatorOpts) ([]FinalizerFn, error)
- func (f *Framework) CreateOrUpdateRoleBinding(ctx context.Context, ns string, relativePath string) (FinalizerFn, error)
- func (f *Framework) CreateOrUpdateRoleBindingForSubjectNamespace(ctx context.Context, ns, subjectNs string, source string) (FinalizerFn, error)
- func (f *Framework) CreateOrUpdateSecretWithCert(ctx context.Context, certBytes, keyBytes []byte, ns, name string) error
- func (f *Framework) CreateOrUpdateServiceAndWaitUntilReady(ctx context.Context, namespace string, service *v1.Service) (FinalizerFn, error)
- func (f *Framework) CreatePrometheusAgentAndWaitUntilReady(ctx context.Context, ns string, p *monitoringv1alpha1.PrometheusAgent) (*monitoringv1alpha1.PrometheusAgent, error)
- func (f *Framework) CreatePrometheusAndWaitUntilReady(ctx context.Context, ns string, p *monitoringv1.Prometheus) (*monitoringv1.Prometheus, error)
- func (f *Framework) CreateRule(ctx context.Context, ns string, ar *monitoringv1.PrometheusRule) (*monitoringv1.PrometheusRule, error)
- func (f *Framework) CreateScrapeConfig(ctx context.Context, ns string, ar *monitoringv1alpha1.ScrapeConfig) (*monitoringv1alpha1.ScrapeConfig, error)
- func (f *Framework) CreateSilence(ctx context.Context, ns, n string) (string, error)
- func (f *Framework) CreateThanosRulerAndWaitUntilReady(ctx context.Context, ns string, tr *monitoringv1.ThanosRuler) (*monitoringv1.ThanosRuler, error)
- func (f *Framework) DeleteAlertmanagerAndWaitUntilGone(ctx context.Context, ns, name string) error
- func (f *Framework) DeleteCRD(ctx context.Context, name string) error
- func (f *Framework) DeleteClusterRole(ctx context.Context, source string) error
- func (f *Framework) DeleteClusterRoleBinding(ctx context.Context, ns string, source string) error
- func (f *Framework) DeleteDeployment(ctx context.Context, namespace, name string) error
- func (f *Framework) DeleteNamespace(ctx context.Context, name string) error
- func (f *Framework) DeleteNginxIngressControllerIncDefaultBackend(ctx context.Context, namespace string) error
- func (f *Framework) DeletePrometheusAgentAndWaitUntilGone(ctx context.Context, ns, name string) error
- func (f *Framework) DeletePrometheusAndWaitUntilGone(ctx context.Context, ns, name string) error
- func (f *Framework) DeletePrometheusOperatorClusterResource(ctx context.Context) error
- func (f *Framework) DeleteRoleBinding(ctx context.Context, ns string, source string) error
- func (f *Framework) DeleteRule(ctx context.Context, ns string, r string) error
- func (f *Framework) DeleteScrapeConfig(ctx context.Context, ns string, r string) error
- func (f *Framework) DeleteServiceAccount(ctx context.Context, namespace string, source string) error
- func (f *Framework) DeleteServiceAndWaitUntilGone(ctx context.Context, namespace string, serviceName string) error
- func (f *Framework) DeleteThanosRulerAndWaitUntilGone(ctx context.Context, ns, name string) error
- func (f *Framework) ExecWithOptions(ctx context.Context, options ExecOptions) (string, string, error)
- func (f *Framework) GetActiveTargets(ctx context.Context, ns, svcName string) ([]*Target, error)
- func (f *Framework) GetAlertmanagerPodStatus(ctx context.Context, ns, n string, https bool) (models.AlertmanagerStatus, error)
- func (f *Framework) GetCRD(ctx context.Context, name string) (*v1.CustomResourceDefinition, error)
- func (f *Framework) GetDeployment(ctx context.Context, ns, name string) (*appsv1.Deployment, error)
- func (f *Framework) GetHealthyTargets(ctx context.Context, ns, svcName string) ([]*Target, error)
- func (f *Framework) GetIngressIP(ctx context.Context, namespace string, ingressName string) (*string, error)
- func (f *Framework) GetLogs(ctx context.Context, namespace string, podName, containerName string) (string, error)
- func (f *Framework) GetMetricVal(ctx context.Context, ...) (float64, error)
- func (f *Framework) GetPodRestartCount(ctx context.Context, ns, podName string) (map[string]int32, error)
- func (f *Framework) GetRule(ctx context.Context, ns, name string) (*monitoringv1.PrometheusRule, error)
- func (f *Framework) GetScrapeConfig(ctx context.Context, ns, name string) (*monitoringv1alpha1.ScrapeConfig, error)
- func (f *Framework) GetSilences(ctx context.Context, ns, n string) (models.GettableSilences, error)
- func (f *Framework) ListCRDs(ctx context.Context) (*v1.CustomResourceDefinitionList, error)
- func (f *Framework) MakeAlertmanagerService(name, group string, serviceType v1.ServiceType) *v1.Service
- func (f *Framework) MakeAndCreateFiringRule(ctx context.Context, ns, name, alertName string) (*monitoringv1.PrometheusRule, error)
- func (f *Framework) MakeAndCreateInvalidRule(ctx context.Context, ns, name, alertName string) (*monitoringv1.PrometheusRule, error)
- func (f *Framework) MakeBasicAlertmanager(ns, name string, replicas int32) *monitoringv1.Alertmanager
- func (f *Framework) MakeBasicPodMonitor(name string) *monitoringv1.PodMonitor
- func (f *Framework) MakeBasicPrometheus(ns, name, group string, replicas int32) *monitoringv1.Prometheus
- func (f *Framework) MakeBasicPrometheusAgent(ns, name, group string, replicas int32) *monitoringv1alpha1.PrometheusAgent
- func (f *Framework) MakeBasicRule(ns, name string, groups []monitoringv1.RuleGroup) *monitoringv1.PrometheusRule
- func (f *Framework) MakeBasicScrapeConfig(ns, name string) *monitoringv1alpha1.ScrapeConfig
- func (f *Framework) MakeBasicServiceMonitor(name string) *monitoringv1.ServiceMonitor
- func (f *Framework) MakeBasicStaticProbe(name, url string, targets []string) *monitoringv1.Probe
- func (f *Framework) MakeBasicThanosRuler(name string, replicas int32, queryEndpoint string) *monitoringv1.ThanosRuler
- func (f *Framework) MakeBlackBoxExporterService(ns, name string) *v1.Service
- func (f *Framework) MakeCRD(source string) (*v1.CustomResourceDefinition, error)
- func (f *Framework) MakeEchoDeployment(group string) *appsv1.Deployment
- func (f *Framework) MakeEchoService(name, group string, serviceType v1.ServiceType) *v1.Service
- func (f *Framework) MakePrometheusService(name, group string, serviceType v1.ServiceType) *v1.Service
- func (f *Framework) MakeThanosQuerierService(name string) *v1.Service
- func (f *Framework) MakeThanosRulerService(name, group string, serviceType v1.ServiceType) *v1.Service
- func (f *Framework) NewTestCtx(t *testing.T) *TestCtx
- func (f *Framework) PatchAlertmanager(ctx context.Context, name, ns string, spec monitoringv1.AlertmanagerSpec) (*monitoringv1.Alertmanager, error)
- func (f *Framework) PatchAlertmanagerAndWaitUntilReady(ctx context.Context, name, ns string, spec monitoringv1.AlertmanagerSpec) (*monitoringv1.Alertmanager, error)
- func (f *Framework) PatchPrometheus(ctx context.Context, name, ns string, spec monitoringv1.PrometheusSpec) (*monitoringv1.Prometheus, error)
- func (f *Framework) PatchPrometheusAgent(ctx context.Context, name, ns string, ...) (*monitoringv1alpha1.PrometheusAgent, error)
- func (f *Framework) PatchPrometheusAgentAndWaitUntilReady(ctx context.Context, name, ns string, ...) (*monitoringv1alpha1.PrometheusAgent, error)
- func (f *Framework) PatchPrometheusAndWaitUntilReady(ctx context.Context, name, ns string, spec monitoringv1.PrometheusSpec) (*monitoringv1.Prometheus, error)
- func (f *Framework) PatchThanosRuler(ctx context.Context, name, ns string, spec monitoringv1.ThanosRulerSpec) (*monitoringv1.ThanosRuler, error)
- func (f *Framework) PatchThanosRulerAndWaitUntilReady(ctx context.Context, name, ns string, spec monitoringv1.ThanosRulerSpec) (*monitoringv1.ThanosRuler, error)
- func (f *Framework) PollAlertmanagerConfiguration(ctx context.Context, ns, amName string, ...) error
- func (f *Framework) PrintEvents(ctx context.Context) error
- func (f *Framework) PrintPodLogs(ctx context.Context, ns, p string) error
- func (f *Framework) PrintPrometheusLogs(ctx context.Context, t *testing.T, p *monitoringv1.Prometheus)
- func (f *Framework) PrometheusQuery(ns, svcName, scheme, query string) ([]PrometheusQueryResult, error)
- func (f *Framework) PrometheusSVCGetRequest(ctx context.Context, ns, svcName, scheme, endpoint string, ...) ([]byte, error)
- func (f *Framework) ProxyGetPod(namespace, resourceName, path string) *rest.Request
- func (f *Framework) ProxyPostPod(namespace, resourceName, path, body string) *rest.Request
- func (f *Framework) RemoveLabelsFromNamespace(ctx context.Context, name string, labels ...string) error
- func (f *Framework) ScaleAlertmanagerAndWaitUntilReady(ctx context.Context, name, ns string, replicas int32) (*monitoringv1.Alertmanager, error)
- func (f *Framework) ScalePrometheusAgentAndWaitUntilReady(ctx context.Context, name, ns string, shards int32) (*monitoringv1alpha1.PrometheusAgent, error)
- func (f *Framework) ScalePrometheusAndWaitUntilReady(ctx context.Context, name, ns string, shards int32) (*monitoringv1.Prometheus, error)
- func (f *Framework) SecretFromYaml(filepath string) (*v1.Secret, error)
- func (f *Framework) SendAlertToAlertmanager(ctx context.Context, ns, n string) error
- func (f *Framework) SetupNginxIngressControllerIncDefaultBackend(ctx context.Context, namespace string) error
- func (f *Framework) SetupPrometheusRBAC(ctx context.Context, t *testing.T, testCtx *TestCtx, ns string)
- func (f *Framework) SetupPrometheusRBACGlobal(ctx context.Context, t *testing.T, testCtx *TestCtx, ns string)
- func (f *Framework) ThanosSVCGetRequest(ctx context.Context, ns, svcName, endpoint string, query map[string]string) ([]byte, error)
- func (f *Framework) UpdateClusterRole(ctx context.Context, clusterRole *rbacv1.ClusterRole) error
- func (f *Framework) UpdateDeployment(ctx context.Context, deployment *appsv1.Deployment) (*appsv1.Deployment, error)
- func (f *Framework) UpdatePrometheusReplicasAndWaitUntilReady(ctx context.Context, name, ns string, replicas int32) (*monitoringv1.Prometheus, error)
- func (f *Framework) UpdateRule(ctx context.Context, ns string, ar *monitoringv1.PrometheusRule) (*monitoringv1.PrometheusRule, error)
- func (f *Framework) UpdateScrapeConfig(ctx context.Context, ns string, ar *monitoringv1alpha1.ScrapeConfig) (*monitoringv1alpha1.ScrapeConfig, error)
- func (f *Framework) WaitForActiveTargets(ctx context.Context, ns, svcName string, amount int) error
- func (f *Framework) WaitForAlertmanagerConfigToBeReloaded(ctx context.Context, ns, amName string, previousReloadTimestamp time.Time) error
- func (f *Framework) WaitForAlertmanagerConfigToContainString(ctx context.Context, ns, amName, expected string) error
- func (f *Framework) WaitForAlertmanagerFiringAlert(ctx context.Context, ns, svcName, alertName string) error
- func (f *Framework) WaitForAlertmanagerPodInitialized(ctx context.Context, ns, name string, amountPeers int, ...) error
- func (f *Framework) WaitForAlertmanagerReady(ctx context.Context, a *monitoringv1.Alertmanager) error
- func (f *Framework) WaitForConfigMapExist(ctx context.Context, ns, name string) (*v1.ConfigMap, error)
- func (f *Framework) WaitForConfigMapNotExist(ctx context.Context, ns, name string) error
- func (f *Framework) WaitForDeploymentReady(ctx context.Context, namespace, deploymentName string, ...) error
- func (f *Framework) WaitForDiscoveryWorking(ctx context.Context, ns, svcName, prometheusName string) error
- func (f *Framework) WaitForHealthyTargets(ctx context.Context, ns, svcName string, amount int) error
- func (f *Framework) WaitForPodsReady(ctx context.Context, namespace string, timeout time.Duration, ...) error
- func (f *Framework) WaitForPodsRunImage(ctx context.Context, namespace string, expectedReplicas int, image string, ...) error
- func (f *Framework) WaitForPrometheusAgentReady(ctx context.Context, p *monitoringv1alpha1.PrometheusAgent, ...) (*monitoringv1alpha1.PrometheusAgent, error)
- func (f *Framework) WaitForPrometheusFiringAlert(ctx context.Context, ns, svcName, alertName string) error
- func (f *Framework) WaitForPrometheusReady(ctx context.Context, p *monitoringv1.Prometheus, timeout time.Duration) (*monitoringv1.Prometheus, error)
- func (f *Framework) WaitForPrometheusRunImageAndReady(ctx context.Context, ns string, p *monitoringv1.Prometheus) error
- func (f *Framework) WaitForResourceAvailable(ctx context.Context, ...) error
- func (f *Framework) WaitForRule(ctx context.Context, ns, name string) error
- func (f *Framework) WaitForServiceReady(ctx context.Context, namespace string, serviceName string) error
- func (f *Framework) WaitForThanosFiringAlert(ctx context.Context, ns, svcName, alertName string) error
- func (f *Framework) WaitForThanosRulerReady(ctx context.Context, ns string, tr *monitoringv1.ThanosRuler, ...) error
- func (f *Framework) WaitUntilDeploymentGone(ctx context.Context, kubeClient kubernetes.Interface, namespace, name string, ...) error
- type Key
- type PromRemoteWriteTestConfig
- type PrometheusOperatorOpts
- type PrometheusQueryAPIResponse
- type PrometheusQueryData
- type PrometheusQueryResult
- type Target
- type TestCtx
- type ThanosAlert
- type ThanosAlertsAPIResponse
- type ThanosAlertsData
Constants ¶
const ( SECRET = 0 CONFIGMAP = 1 )
Variables ¶
var ( CRDCreateRule = rbacv1.PolicyRule{ APIGroups: []string{"apiextensions.k8s.io"}, Resources: []string{"customresourcedefinitions"}, Verbs: []string{"create"}, } CRDMonitoringRule = rbacv1.PolicyRule{ APIGroups: []string{"apiextensions.k8s.io"}, Resources: []string{"customresourcedefinitions"}, ResourceNames: []string{ "alertmanagers.monitoring.rhobs", "podmonitors.monitoring.rhobs", "probes.monitoring.rhobs", "prometheuses.monitoring.rhobs", "prometheusrules.monitoring.rhobs", "servicemonitors.monitoring.rhobs", "thanosrulers.monitoring.rhobs", }, Verbs: []string{"get", "update"}, } )
var ValidAlertmanagerConfig = `` /* 229-byte string literal not displayed */
Functions ¶
func MakeBasicIngress ¶
func MakeConfigMapWithCert ¶
func MakeDeployment ¶
func MakeDeployment(source string) (*appsv1.Deployment, error)
func MakeSecretWithCert ¶
func StartPortForward ¶
func StartPortForward(ctx context.Context, config *rest.Config, scheme string, name string, ns string, port string) (func(), error)
StartPortForward initiates a port forwarding connection to a pod on the localhost interface. It returns a closer function that should be invoked to stop the proxy server. The function blocks until the port forwarding proxy server is ready to receive connections or the context is canceled.
func WaitForCRDReady ¶
WaitForCRDReady waits for a Custom Resource Definition to be available for use.
Types ¶
type ExecOptions ¶
type ExecOptions struct {
Command []string
Namespace string
PodName string
ContainerName string
Stdin io.Reader
CaptureStdout bool
CaptureStderr bool
// If false, whitespace in std{err,out} will be removed.
PreserveWhitespace bool
}
ExecOptions passed to ExecWithOptions.
type FinalizerFn ¶
type FinalizerFn func() error
type Framework ¶
type Framework struct {
KubeClient kubernetes.Interface
MonClientV1 v1monitoringclient.MonitoringV1Interface
MonClientV1alpha1 v1alpha1monitoringclient.MonitoringV1alpha1Interface
MonClientV1beta1 v1beta1monitoringclient.MonitoringV1beta1Interface
APIServerClient apiclient.Interface
HTTPClient *http.Client
MasterHost string
DefaultTimeout time.Duration
RestConfig *rest.Config
// contains filtered or unexported fields
}
func New ¶
func New(kubeconfig, opImage, exampleDir, resourcesDir string, operatorVersion semver.Version) (*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) AddLabelsToNamespace ¶
func (*Framework) AddRemoteReceiveWithWebTLSToPrometheus ¶
func (f *Framework) AddRemoteReceiveWithWebTLSToPrometheus(p *monitoringv1.Prometheus, prwtc PromRemoteWriteTestConfig)
func (*Framework) AddRemoteWriteWithTLSToPrometheus ¶
func (f *Framework) AddRemoteWriteWithTLSToPrometheus(p *monitoringv1.Prometheus, url string, prwtc PromRemoteWriteTestConfig)
func (*Framework) AlertmanagerConfigSecret ¶
func (*Framework) AlertmangerSVCGetRequest ¶
func (*Framework) AssertCondition ¶
func (f *Framework) AssertCondition(conds []monitoringv1.Condition, expectedType monitoringv1.ConditionType, expectedStatus monitoringv1.ConditionStatus) error
func (*Framework) CheckPrometheusFiringAlert ¶ added in v0.24.0
func (*Framework) CheckThanosFiringAlert ¶
func (*Framework) CreateAlertmanagerAndWaitUntilReady ¶
func (f *Framework) CreateAlertmanagerAndWaitUntilReady(ctx context.Context, a *monitoringv1.Alertmanager) (*monitoringv1.Alertmanager, error)
func (*Framework) CreateAlertmanagerConfig ¶
func (f *Framework) CreateAlertmanagerConfig(ctx context.Context, ns, name string) (*monitoringv1alpha1.AlertmanagerConfig, error)
func (*Framework) CreateBlackBoxExporterAndWaitUntilReady ¶
func (*Framework) CreateDeployment ¶
func (*Framework) CreateIngress ¶
func (*Framework) CreateNamespace ¶
func (*Framework) CreateOrUpdateAdmissionWebhookServer ¶
func (f *Framework) CreateOrUpdateAdmissionWebhookServer( ctx context.Context, namespace string, image string, ) (*v1.Service, []byte, error)
CreateOrUpdateAdmissionWebhookServer deploys an HTTPS server which acts as a validating and mutating webhook server for PrometheusRule and AlertManagerConfig. It is also able to convert AlertmanagerConfig objects from v1alpha1 to v1beta1. Returns the service and the certificate authority which can be used to trust the TLS certificate of the server.
func (*Framework) CreateOrUpdateCRD ¶
CreateOrUpdateCRD creates a custom resource definition on the apiserver.
func (*Framework) CreateOrUpdateCRDAndWaitUntilReady ¶
func (f *Framework) CreateOrUpdateCRDAndWaitUntilReady(ctx context.Context, crdName string, listFunc func(opts metav1.ListOptions) (runtime.Object, error)) error
CreateCRDAndWaitUntilReady creates a Custom Resource Definition from yaml manifest on the apiserver and wait until it is available for use.
func (*Framework) CreateOrUpdateClusterRole ¶
func (*Framework) CreateOrUpdateDeploymentAndWaitUntilReady ¶
func (*Framework) CreateOrUpdatePrometheusOperator ¶
func (f *Framework) CreateOrUpdatePrometheusOperator( ctx context.Context, namespace string, namespaceAllowlist, namespaceDenylist, prometheusInstanceNamespaces, alertmanagerInstanceNamespaces []string, createResourceAdmissionHooks, createClusterRoleBindings, createScrapeConfigCrd bool, ) ([]FinalizerFn, error)
func (*Framework) CreateOrUpdatePrometheusOperatorWithOpts ¶
func (f *Framework) CreateOrUpdatePrometheusOperatorWithOpts( ctx context.Context, opts PrometheusOperatorOpts, ) ([]FinalizerFn, error)
CreateOrUpdatePrometheusOperatorWithOpts creates or updates a Prometheus Operator Kubernetes Deployment inside the specified namespace using the specified operator image. Semver is used to control the installation for different versions of Prometheus Operator. In addition one can specify the namespaces to watch, which defaults to all namespaces. It returns a slice of functions to tear down the deployment.
func (*Framework) CreateOrUpdateRoleBinding ¶
func (*Framework) CreateOrUpdateRoleBindingForSubjectNamespace ¶
func (*Framework) CreateOrUpdateSecretWithCert ¶
func (*Framework) CreateOrUpdateServiceAndWaitUntilReady ¶
func (*Framework) CreatePrometheusAgentAndWaitUntilReady ¶
func (f *Framework) CreatePrometheusAgentAndWaitUntilReady(ctx context.Context, ns string, p *monitoringv1alpha1.PrometheusAgent) (*monitoringv1alpha1.PrometheusAgent, error)
func (*Framework) CreatePrometheusAndWaitUntilReady ¶
func (f *Framework) CreatePrometheusAndWaitUntilReady(ctx context.Context, ns string, p *monitoringv1.Prometheus) (*monitoringv1.Prometheus, error)
func (*Framework) CreateRule ¶ added in v0.20.0
func (f *Framework) CreateRule(ctx context.Context, ns string, ar *monitoringv1.PrometheusRule) (*monitoringv1.PrometheusRule, error)
func (*Framework) CreateScrapeConfig ¶
func (f *Framework) CreateScrapeConfig(ctx context.Context, ns string, ar *monitoringv1alpha1.ScrapeConfig) (*monitoringv1alpha1.ScrapeConfig, error)
func (*Framework) CreateSilence ¶ added in v0.18.1
func (*Framework) CreateThanosRulerAndWaitUntilReady ¶
func (f *Framework) CreateThanosRulerAndWaitUntilReady(ctx context.Context, ns string, tr *monitoringv1.ThanosRuler) (*monitoringv1.ThanosRuler, error)
func (*Framework) DeleteAlertmanagerAndWaitUntilGone ¶
func (*Framework) DeleteClusterRole ¶
func (*Framework) DeleteClusterRoleBinding ¶
func (*Framework) DeleteDeployment ¶
func (*Framework) DeleteNamespace ¶
func (*Framework) DeleteNginxIngressControllerIncDefaultBackend ¶
func (*Framework) DeletePrometheusAgentAndWaitUntilGone ¶
func (*Framework) DeletePrometheusAndWaitUntilGone ¶
func (*Framework) DeletePrometheusOperatorClusterResource ¶
DeletePrometheusOperatorClusterResource delete Prometheus Operator cluster wide resources if the resource is found.
func (*Framework) DeleteRoleBinding ¶
func (*Framework) DeleteRule ¶ added in v0.22.0
func (*Framework) DeleteScrapeConfig ¶
func (*Framework) DeleteServiceAccount ¶
func (*Framework) DeleteServiceAndWaitUntilGone ¶
func (*Framework) DeleteThanosRulerAndWaitUntilGone ¶
func (*Framework) ExecWithOptions ¶
func (f *Framework) ExecWithOptions(ctx context.Context, options ExecOptions) (string, string, error)
ExecWithOptions executes a command in the specified container, returning stdout, stderr and error. `options` allowed for additional parameters to be passed. Inspired by https://github.com/kubernetes/kubernetes/blob/dde6e8e7465468c32642659cb708a5cc922add64/test/e2e/framework/exec_util.go#L36-L51
func (*Framework) GetActiveTargets ¶
func (*Framework) GetAlertmanagerPodStatus ¶
func (*Framework) GetDeployment ¶
func (*Framework) GetHealthyTargets ¶
func (*Framework) GetIngressIP ¶
func (*Framework) GetMetricVal ¶
func (f *Framework) GetMetricVal(ctx context.Context, protocol, ns, podName, portNumberOrName, metricName string) (float64, error)
GetMetricVal get a particular metric value from a pod. When portNumberOfName is "", default port will be used to access metrics endpoint.
func (*Framework) GetPodRestartCount ¶ added in v0.24.0
func (f *Framework) GetPodRestartCount(ctx context.Context, ns, podName string) (map[string]int32, error)
GetPodRestartCount returns a map of container names and their restart counts for a given pod.
func (*Framework) GetRule ¶
func (f *Framework) GetRule(ctx context.Context, ns, name string) (*monitoringv1.PrometheusRule, error)
func (*Framework) GetScrapeConfig ¶
func (f *Framework) GetScrapeConfig(ctx context.Context, ns, name string) (*monitoringv1alpha1.ScrapeConfig, error)
func (*Framework) GetSilences ¶ added in v0.18.1
func (*Framework) ListCRDs ¶
ListCRDs gets a list of custom resource definitions from the apiserver.
func (*Framework) MakeAlertmanagerService ¶
func (*Framework) MakeAndCreateFiringRule ¶ added in v0.20.0
func (f *Framework) MakeAndCreateFiringRule(ctx context.Context, ns, name, alertName string) (*monitoringv1.PrometheusRule, error)
func (*Framework) MakeAndCreateInvalidRule ¶
func (f *Framework) MakeAndCreateInvalidRule(ctx context.Context, ns, name, alertName string) (*monitoringv1.PrometheusRule, error)
func (*Framework) MakeBasicAlertmanager ¶
func (f *Framework) MakeBasicAlertmanager(ns, name string, replicas int32) *monitoringv1.Alertmanager
func (*Framework) MakeBasicPodMonitor ¶
func (f *Framework) MakeBasicPodMonitor(name string) *monitoringv1.PodMonitor
func (*Framework) MakeBasicPrometheus ¶
func (f *Framework) MakeBasicPrometheus(ns, name, group string, replicas int32) *monitoringv1.Prometheus
func (*Framework) MakeBasicPrometheusAgent ¶
func (f *Framework) MakeBasicPrometheusAgent(ns, name, group string, replicas int32) *monitoringv1alpha1.PrometheusAgent
func (*Framework) MakeBasicRule ¶ added in v0.20.0
func (f *Framework) MakeBasicRule(ns, name string, groups []monitoringv1.RuleGroup) *monitoringv1.PrometheusRule
func (*Framework) MakeBasicScrapeConfig ¶
func (f *Framework) MakeBasicScrapeConfig(ns, name string) *monitoringv1alpha1.ScrapeConfig
func (*Framework) MakeBasicServiceMonitor ¶
func (f *Framework) MakeBasicServiceMonitor(name string) *monitoringv1.ServiceMonitor
func (*Framework) MakeBasicStaticProbe ¶
func (f *Framework) MakeBasicStaticProbe(name, url string, targets []string) *monitoringv1.Probe
func (*Framework) MakeBasicThanosRuler ¶
func (f *Framework) MakeBasicThanosRuler(name string, replicas int32, queryEndpoint string) *monitoringv1.ThanosRuler
func (*Framework) MakeBlackBoxExporterService ¶
func (*Framework) MakeCRD ¶
func (f *Framework) MakeCRD(source string) (*v1.CustomResourceDefinition, error)
MakeCRD creates a CustomResourceDefinition object from yaml manifest.
func (*Framework) MakeEchoDeployment ¶
func (f *Framework) MakeEchoDeployment(group string) *appsv1.Deployment
func (*Framework) MakeEchoService ¶
func (*Framework) MakePrometheusService ¶
func (*Framework) MakeThanosQuerierService ¶ added in v0.21.0
func (*Framework) MakeThanosRulerService ¶
func (*Framework) PatchAlertmanager ¶
func (f *Framework) PatchAlertmanager(ctx context.Context, name, ns string, spec monitoringv1.AlertmanagerSpec) (*monitoringv1.Alertmanager, error)
func (*Framework) PatchAlertmanagerAndWaitUntilReady ¶
func (f *Framework) PatchAlertmanagerAndWaitUntilReady(ctx context.Context, name, ns string, spec monitoringv1.AlertmanagerSpec) (*monitoringv1.Alertmanager, error)
func (*Framework) PatchPrometheus ¶
func (f *Framework) PatchPrometheus(ctx context.Context, name, ns string, spec monitoringv1.PrometheusSpec) (*monitoringv1.Prometheus, error)
func (*Framework) PatchPrometheusAgent ¶
func (f *Framework) PatchPrometheusAgent(ctx context.Context, name, ns string, spec monitoringv1alpha1.PrometheusAgentSpec) (*monitoringv1alpha1.PrometheusAgent, error)
func (*Framework) PatchPrometheusAgentAndWaitUntilReady ¶
func (f *Framework) PatchPrometheusAgentAndWaitUntilReady(ctx context.Context, name, ns string, spec monitoringv1alpha1.PrometheusAgentSpec) (*monitoringv1alpha1.PrometheusAgent, error)
func (*Framework) PatchPrometheusAndWaitUntilReady ¶
func (f *Framework) PatchPrometheusAndWaitUntilReady(ctx context.Context, name, ns string, spec monitoringv1.PrometheusSpec) (*monitoringv1.Prometheus, error)
func (*Framework) PatchThanosRuler ¶
func (f *Framework) PatchThanosRuler(ctx context.Context, name, ns string, spec monitoringv1.ThanosRulerSpec) (*monitoringv1.ThanosRuler, error)
func (*Framework) PatchThanosRulerAndWaitUntilReady ¶
func (f *Framework) PatchThanosRulerAndWaitUntilReady(ctx context.Context, name, ns string, spec monitoringv1.ThanosRulerSpec) (*monitoringv1.ThanosRuler, error)
func (*Framework) PollAlertmanagerConfiguration ¶
func (f *Framework) PollAlertmanagerConfiguration(ctx context.Context, ns, amName string, conditions ...func(config string) error) error
PollAlertmanagerConfiguration retrieves the Alertmanager configuration via the Alertmanager's API and checks that all conditions return without error. It will retry every 10 second for 5 minutes before giving up.
func (*Framework) PrintEvents ¶ added in v0.22.0
PrintEvents prints the Kubernetes events to standard out.
func (*Framework) PrintPodLogs ¶ added in v0.22.0
PrintPodLogs prints the logs of a specified Pod.
func (*Framework) PrintPrometheusLogs ¶
func (f *Framework) PrintPrometheusLogs(ctx context.Context, t *testing.T, p *monitoringv1.Prometheus)
PrintPrometheusLogs prints the logs for each Prometheus replica.
func (*Framework) PrometheusQuery ¶
func (f *Framework) PrometheusQuery(ns, svcName, scheme, query string) ([]PrometheusQueryResult, error)
func (*Framework) PrometheusSVCGetRequest ¶
func (*Framework) ProxyGetPod ¶
ProxyGetPod expects resourceName as "[protocol:]podName[:portNameOrNumber]". protocol is optional and the valid values are "http" and "https". Without specifying protocol, "http" will be used. podName is mandatory. portNameOrNumber is optional. Without specifying portNameOrNumber, default port will be used.
func (*Framework) ProxyPostPod ¶
ProxyPostPod expects resourceName as "[protocol:]podName[:portNameOrNumber]". protocol is optional and the valid values are "http" and "https". Without specifying protocol, "http" will be used. podName is mandatory. portNameOrNumber is optional. Without specifying portNameOrNumber, default port will be used.
func (*Framework) RemoveLabelsFromNamespace ¶
func (*Framework) ScaleAlertmanagerAndWaitUntilReady ¶
func (f *Framework) ScaleAlertmanagerAndWaitUntilReady(ctx context.Context, name, ns string, replicas int32) (*monitoringv1.Alertmanager, error)
func (*Framework) ScalePrometheusAgentAndWaitUntilReady ¶
func (f *Framework) ScalePrometheusAgentAndWaitUntilReady(ctx context.Context, name, ns string, shards int32) (*monitoringv1alpha1.PrometheusAgent, error)
func (*Framework) ScalePrometheusAndWaitUntilReady ¶
func (f *Framework) ScalePrometheusAndWaitUntilReady(ctx context.Context, name, ns string, shards int32) (*monitoringv1.Prometheus, error)
func (*Framework) SecretFromYaml ¶
func (*Framework) SendAlertToAlertmanager ¶ added in v0.24.0
SendAlertToAlertmanager sends an alert to the alertmanager in the given namespace (ns) with the given name (n).
func (*Framework) SetupNginxIngressControllerIncDefaultBackend ¶
func (*Framework) SetupPrometheusRBAC ¶
func (*Framework) SetupPrometheusRBACGlobal ¶
func (*Framework) ThanosSVCGetRequest ¶
func (*Framework) UpdateClusterRole ¶
func (*Framework) UpdateDeployment ¶
func (f *Framework) UpdateDeployment(ctx context.Context, deployment *appsv1.Deployment) (*appsv1.Deployment, error)
func (*Framework) UpdatePrometheusReplicasAndWaitUntilReady ¶
func (f *Framework) UpdatePrometheusReplicasAndWaitUntilReady(ctx context.Context, name, ns string, replicas int32) (*monitoringv1.Prometheus, error)
func (*Framework) UpdateRule ¶ added in v0.20.0
func (f *Framework) UpdateRule(ctx context.Context, ns string, ar *monitoringv1.PrometheusRule) (*monitoringv1.PrometheusRule, error)
func (*Framework) UpdateScrapeConfig ¶
func (f *Framework) UpdateScrapeConfig(ctx context.Context, ns string, ar *monitoringv1alpha1.ScrapeConfig) (*monitoringv1alpha1.ScrapeConfig, error)
func (*Framework) WaitForActiveTargets ¶
WaitForActiveTargets waits for a number of targets to be configured.
func (*Framework) WaitForAlertmanagerConfigToBeReloaded ¶
func (*Framework) WaitForAlertmanagerConfigToContainString ¶ added in v0.20.0
func (*Framework) WaitForAlertmanagerFiringAlert ¶
func (*Framework) WaitForAlertmanagerPodInitialized ¶
func (*Framework) WaitForAlertmanagerReady ¶
func (f *Framework) WaitForAlertmanagerReady(ctx context.Context, a *monitoringv1.Alertmanager) error
WaitForAlertmanagerReady waits for each individual pod as well as the cluster as a whole to be ready.
func (*Framework) WaitForConfigMapExist ¶ added in v0.20.0
func (*Framework) WaitForConfigMapNotExist ¶ added in v0.20.0
func (*Framework) WaitForDeploymentReady ¶
func (*Framework) WaitForDiscoveryWorking ¶
func (*Framework) WaitForHealthyTargets ¶
func (f *Framework) WaitForHealthyTargets(ctx context.Context, ns, svcName string, amount int) error
WaitForHealthyTargets waits for a number of targets to be configured and healthy.
func (*Framework) WaitForPodsReady ¶
func (f *Framework) WaitForPodsReady(ctx context.Context, 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 (*Framework) WaitForPodsRunImage ¶
func (*Framework) WaitForPrometheusAgentReady ¶
func (f *Framework) WaitForPrometheusAgentReady(ctx context.Context, p *monitoringv1alpha1.PrometheusAgent, timeout time.Duration) (*monitoringv1alpha1.PrometheusAgent, error)
func (*Framework) WaitForPrometheusFiringAlert ¶ added in v0.19.0
func (*Framework) WaitForPrometheusReady ¶
func (f *Framework) WaitForPrometheusReady(ctx context.Context, p *monitoringv1.Prometheus, timeout time.Duration) (*monitoringv1.Prometheus, error)
func (*Framework) WaitForPrometheusRunImageAndReady ¶
func (f *Framework) WaitForPrometheusRunImageAndReady(ctx context.Context, ns string, p *monitoringv1.Prometheus) error
func (*Framework) WaitForResourceAvailable ¶
func (f *Framework) WaitForResourceAvailable(ctx context.Context, getResourceStatus func(context.Context) (resourceStatus, error), timeout time.Duration) error
WaitForResourceAvailable waits for a monitoring resource to report itself as being reconciled & available. If the resource isn't available within the given timeout, it returns an error.
func (*Framework) WaitForRule ¶ added in v0.20.0
WaitForRule waits for a rule file with a given name to exist in a given namespace.
func (*Framework) WaitForServiceReady ¶
func (*Framework) WaitForThanosFiringAlert ¶
func (*Framework) WaitForThanosRulerReady ¶
func (f *Framework) WaitForThanosRulerReady(ctx context.Context, ns string, tr *monitoringv1.ThanosRuler, timeout time.Duration) error
type PrometheusOperatorOpts ¶
type PrometheusQueryAPIResponse ¶
type PrometheusQueryAPIResponse struct {
Status string `json:"status"`
Data *PrometheusQueryData `json:"data"`
}
type PrometheusQueryData ¶
type PrometheusQueryData struct {
ResultType string `json:"resultType"`
Result []PrometheusQueryResult `json:"result"`
}
type PrometheusQueryResult ¶
type TestCtx ¶
type TestCtx struct {
// contains filtered or unexported fields
}
func (*TestCtx) AddFinalizerFn ¶
func (ctx *TestCtx) AddFinalizerFn(fn FinalizerFn)
type ThanosAlert ¶
type ThanosAlertsAPIResponse ¶
type ThanosAlertsAPIResponse struct {
Status string `json:"status"`
Data *ThanosAlertsData `json:"data"`
}
type ThanosAlertsData ¶
type ThanosAlertsData struct {
Alerts []ThanosAlert `json:"alerts"`
}
Source Files
¶
- admission_webhooks.go
- alertmanager.go
- cluster_role.go
- cluster_role_binding.go
- config_map.go
- context.go
- crd.go
- deployment.go
- event.go
- framework.go
- helpers.go
- ingress.go
- namespace.go
- pod.go
- probe.go
- prometheus.go
- prometheus_rule.go
- prometheusagent.go
- replication_controller.go
- role_binding.go
- scrapeconfig.go
- secret.go
- service.go
- service_account.go
- status.go
- thanosruler.go