-
Notifications
You must be signed in to change notification settings - Fork 444
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
e2e test prometheus operator scrape config and probes
Signed-off-by: qiyang <[email protected]>
- Loading branch information
Showing
4 changed files
with
206 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
tests/e2e-targetallocator/targetallocator-prometheuscr/02-assert.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
apiVersion: apps/v1 | ||
kind: StatefulSet | ||
metadata: | ||
name: prometheus-cr-v1beta1-collector | ||
status: | ||
readyReplicas: 1 | ||
replicas: 1 | ||
--- | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: prometheus-cr-v1beta1-targetallocator | ||
status: | ||
observedGeneration: 1 | ||
readyReplicas: 1 | ||
replicas: 1 | ||
--- | ||
apiVersion: v1 | ||
data: | ||
targetallocator.yaml: | ||
( contains(@, join(':', ['service_monitor_selector', ' null'])) ): true | ||
( contains(@, join(':', ['pod_monitor_selector', ' null'])) ): true | ||
( contains(@, join(':', ['probe_selector', ' null'])) ): true | ||
( contains(@, join(':', ['scrape_config_selector', ' null'])) ): false | ||
( contains(@, join(':', ['matchlabels', ' {}}'])) ): false | ||
( contains(@, join(':', ['matchexpressions', ' {}}'])) ): false | ||
kind: ConfigMap | ||
metadata: | ||
name: prometheus-cr-v1beta1-targetallocator | ||
--- | ||
apiVersion: batch/v1 | ||
kind: Job | ||
metadata: | ||
name: check-ta-scrape-config-v1beta1 | ||
status: | ||
succeeded: 1 | ||
--- | ||
apiVersion: batch/v1 | ||
kind: Job | ||
metadata: | ||
name: check-ta-jobs-scrape-configs-v1beta1 | ||
status: | ||
succeeded: 1 | ||
--- | ||
apiVersion: batch/v1 | ||
kind: Job | ||
metadata: | ||
name: check-ta-probe-config-v1beta1 | ||
status: | ||
succeeded: 1 | ||
--- | ||
apiVersion: batch/v1 | ||
kind: Job | ||
metadata: | ||
name: check-ta-jobs-probes-v1beta1 | ||
status: | ||
succeeded: 1 |
141 changes: 141 additions & 0 deletions
141
tests/e2e-targetallocator/targetallocator-prometheuscr/02-install.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,141 @@ | ||
--- | ||
apiVersion: opentelemetry.io/v1beta1 | ||
kind: OpenTelemetryCollector | ||
metadata: | ||
name: prometheus-cr-v1beta1 | ||
spec: | ||
config: | ||
receivers: | ||
prometheus: | ||
config: | ||
scrape_configs: [] | ||
|
||
processors: | ||
|
||
exporters: | ||
prometheus: | ||
endpoint: 0.0.0.0:9090 | ||
service: | ||
pipelines: | ||
metrics: | ||
receivers: [prometheus] | ||
exporters: [prometheus] | ||
mode: statefulset | ||
serviceAccount: collector | ||
targetAllocator: | ||
enabled: true | ||
prometheusCR: | ||
enabled: true | ||
scrapeInterval: 1s | ||
scrapeConfigSelector: {} | ||
serviceAccount: ta | ||
--- | ||
apiVersion: monitoring.coreos.com/v1alpha1 | ||
kind: ScrapeConfig | ||
metadata: | ||
name: scrape-config-cr | ||
spec: | ||
kubernetesSDConfigs: | ||
- role: Node | ||
--- | ||
apiVersion: monitoring.coreos.com/v1 | ||
kind: Probe | ||
metadata: | ||
name: blackbox-exporter | ||
spec: | ||
jobName: http-get | ||
interval: 60s | ||
module: http_2xx | ||
prober: | ||
url: blackbox-exporter.monitoring-system.svc:19115 | ||
scheme: http | ||
path: /probe | ||
targets: | ||
staticConfig: | ||
static: | ||
- https://example.com | ||
--- | ||
apiVersion: batch/v1 | ||
kind: Job | ||
metadata: | ||
name: check-metrics-cr | ||
spec: | ||
template: | ||
spec: | ||
restartPolicy: OnFailure | ||
containers: | ||
- name: check-metrics | ||
image: curlimages/curl | ||
args: | ||
- /bin/sh | ||
- -c | ||
- | | ||
for i in $(seq 30); do | ||
if curl -m 1 -s http://prometheus-cr-v1beta1-collector:9090/metrics | grep "otelcol"; then exit 0; fi | ||
sleep 5 | ||
done | ||
exit 1 | ||
--- | ||
apiVersion: batch/v1 | ||
kind: Job | ||
metadata: | ||
name: check-ta-scrape-config-v1beta1 | ||
spec: | ||
template: | ||
spec: | ||
restartPolicy: OnFailure | ||
containers: | ||
- name: check-metrics | ||
image: curlimages/curl | ||
args: | ||
- /bin/sh | ||
- -c | ||
- curl -s http://prometheus-cr-v1beta1-targetallocator/scrape_configs | grep "scrape-config-cr" | ||
--- | ||
apiVersion: batch/v1 | ||
kind: Job | ||
metadata: | ||
name: check-ta-jobs-scrape-configs-v1beta1 | ||
spec: | ||
template: | ||
spec: | ||
restartPolicy: OnFailure | ||
containers: | ||
- name: check-metrics | ||
image: curlimages/curl | ||
args: | ||
- /bin/sh | ||
- -c | ||
- curl -s http://prometheus-cr-v1beta1-targetallocator/jobs | grep "scrape-config-cr" | ||
--- | ||
apiVersion: batch/v1 | ||
kind: Job | ||
metadata: | ||
name: check-ta-probe-config-v1beta1 | ||
spec: | ||
template: | ||
spec: | ||
restartPolicy: OnFailure | ||
containers: | ||
- name: check-metrics | ||
image: curlimages/curl | ||
args: | ||
- /bin/sh | ||
- -c | ||
- curl -s http://prometheus-cr-v1beta1-targetallocator/scrape_configs | grep "blackbox-exporter" | ||
--- | ||
apiVersion: batch/v1 | ||
kind: Job | ||
metadata: | ||
name: check-ta-jobs-probes-v1beta1 | ||
spec: | ||
template: | ||
spec: | ||
restartPolicy: OnFailure | ||
containers: | ||
- name: check-metrics | ||
image: curlimages/curl | ||
args: | ||
- /bin/sh | ||
- -c | ||
- curl -s http://prometheus-cr-v1beta1-targetallocator/jobs | grep "blackbox-exporter" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters