Skip to content

Commit

Permalink
Add e2e tests for prometheus receiver configuration (#1762)
Browse files Browse the repository at this point in the history
* Add e2e tests for prometheus receiver configuration

* add new tests to the modify images script
  • Loading branch information
Mikołaj Świątek authored May 24, 2023
1 parent 5805127 commit a5537a1
Show file tree
Hide file tree
Showing 9 changed files with 323 additions and 0 deletions.
1 change: 1 addition & 0 deletions hack/modify-test-images.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ SED_BIN=${SED_BIN:-sed}

${SED_BIN} -i "s#local/opentelemetry-operator-targetallocator:e2e#${TARGETALLOCATOR_IMG}#g" tests/e2e/smoke-targetallocator/00-install.yaml
${SED_BIN} -i "s#local/opentelemetry-operator-targetallocator:e2e#${TARGETALLOCATOR_IMG}#g" tests/e2e/targetallocator-features/00-install.yaml
${SED_BIN} -i "s#local/opentelemetry-operator-targetallocator:e2e#${TARGETALLOCATOR_IMG}#g" tests/e2e/prometheus-config-validation/*.yaml
25 changes: 25 additions & 0 deletions tests/e2e/prometheus-config-validation/00-assert.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: promreceiver-allocatorconfig-collector
status:
replicas: 1
readyReplicas: 1
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: promreceiver-allocatorconfig-targetallocator
status:
replicas: 1
readyReplicas: 1
---
# Print TA and operator logs if test fails
apiVersion: kuttl.dev/v1beta1
kind: TestAssert
collectors:
- selector: app.kubernetes.io/component=opentelemetry-targetallocator
- selector: app.kubernetes.io/component=opentelemetry-collector
- selector: app.kubernetes.io/name=opentelemetry-operator
namespace: opentelemetry-operator-system
container: manager
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
apiVersion: v1
kind: ServiceAccount
metadata:
name: ta
automountServiceAccountToken: true
---
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: pod-view
rules:
- apiGroups: [""]
resources: [ "pods" ]
verbs: [ "get", "list", "watch"]
---
apiVersion: kuttl.dev/v1beta1
kind: TestStep
commands:
- command: kubectl -n $NAMESPACE create rolebinding default-view-$NAMESPACE --role=pod-view --serviceaccount=$NAMESPACE:ta
---
apiVersion: opentelemetry.io/v1alpha1
kind: OpenTelemetryCollector
metadata:
name: promreceiver-allocatorconfig
spec:
mode: statefulset
targetAllocator:
enabled: true
image: "local/opentelemetry-operator-targetallocator:e2e"
serviceAccount: ta
prometheusCR:
enabled: true

config: |
receivers:
jaeger:
protocols:
grpc:
# Collect own metrics
prometheus:
config:
scrape_configs:
- job_name: 'otel-collector'
scrape_interval: 10s
static_configs:
- targets: [ '0.0.0.0:8888' ]
target_allocator:
endpoint: http://promreceiver-allocatorconfig-targetallocator
interval: 30s
collector_id: ${POD_NAME}
processors:
exporters:
logging:
extensions:
health_check:
service:
telemetry:
metrics:
address: :8888
extensions:
- health_check
pipelines:
traces:
receivers: [jaeger]
processors: []
exporters: [logging]
28 changes: 28 additions & 0 deletions tests/e2e/prometheus-config-validation/01-assert.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
## Uncomment this after https://github.com/open-telemetry/opentelemetry-operator/issues/958 is resolved
## Unfortunately kuttl doesn't have a way to skip tests

# apiVersion: apps/v1
# kind: StatefulSet
# metadata:
# name: labeldrop-collector
# status:
# replicas: 1
# readyReplicas: 1
# ---
# apiVersion: apps/v1
# kind: Deployment
# metadata:
# name: labeldrop-targetallocator
# status:
# replicas: 1
# readyReplicas: 1
# ---
# # Print TA and operator logs if test fails
# apiVersion: kuttl.dev/v1beta1
# kind: TestAssert
# collectors:
# - selector: app.kubernetes.io/component=opentelemetry-targetallocator
# - selector: app.kubernetes.io/component=opentelemetry-collector
# - selector: app.kubernetes.io/name=opentelemetry-operator
# namespace: opentelemetry-operator-system
# container: manager
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
## Uncomment this after https://github.com/open-telemetry/opentelemetry-operator/issues/958 is resolved
## Unfortunately kuttl doesn't have a way to skip tests

# apiVersion: opentelemetry.io/v1alpha1
# kind: OpenTelemetryCollector
# metadata:
# name: labeldrop
# spec:
# mode: statefulset
# targetAllocator:
# enabled: true
# image: "local/opentelemetry-operator-targetallocator:e2e"
# serviceAccount: ta
# prometheusCR:
# enabled: true

# config: |
# receivers:
# jaeger:
# protocols:
# grpc:

# # Collect own metrics
# prometheus:
# config:
# scrape_configs:
# - job_name: 'otel-collector'
# scrape_interval: 10s
# static_configs:
# - targets: [ '0.0.0.0:8888' ]
# metric_relabel_configs:
# - action: labeldrop
# regex: (id|name)

# target_allocator:
# endpoint: http://labeldrop-targetallocator
# interval: 30s
# collector_id: ${POD_NAME}

# processors:

# exporters:
# logging:
# service:
# pipelines:
# traces:
# receivers: [jaeger]
# processors: []
# exporters: [logging]
25 changes: 25 additions & 0 deletions tests/e2e/prometheus-config-validation/02-assert.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: promreceiver-allocatorconfig-extra-collector
status:
replicas: 1
readyReplicas: 1
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: promreceiver-allocatorconfig-extra-targetallocator
status:
replicas: 1
readyReplicas: 1
---
# Print TA and operator logs if test fails
apiVersion: kuttl.dev/v1beta1
kind: TestAssert
collectors:
- selector: app.kubernetes.io/component=opentelemetry-targetallocator
- selector: app.kubernetes.io/component=opentelemetry-collector
- selector: app.kubernetes.io/name=opentelemetry-operator
namespace: opentelemetry-operator-system
container: manager
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
---
apiVersion: opentelemetry.io/v1alpha1
kind: OpenTelemetryCollector
metadata:
name: promreceiver-allocatorconfig-extra
spec:
mode: statefulset
targetAllocator:
enabled: true
image: "local/opentelemetry-operator-targetallocator:e2e"
serviceAccount: ta
prometheusCR:
enabled: true

config: |
receivers:
jaeger:
protocols:
grpc:
# Collect own metrics
prometheus:
config:
scrape_configs:
- job_name: 'otel-collector'
scrape_interval: 10s
static_configs:
- targets: [ '0.0.0.0:8888' ]
target_allocator:
endpoint: http://promreceiver-allocatorconfig-extra-targetallocator
interval: 30s
collector_id: ${POD_NAME}
http_sd_config:
refresh_interval: 10s
processors:
exporters:
logging:
extensions:
health_check:
service:
telemetry:
metrics:
address: :8888
extensions:
- health_check
pipelines:
traces:
receivers: [jaeger]
processors: []
exporters: [logging]
25 changes: 25 additions & 0 deletions tests/e2e/prometheus-config-validation/03-assert.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: promreceiver-nopromconfig-collector
status:
replicas: 1
readyReplicas: 1
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: promreceiver-nopromconfig-targetallocator
status:
replicas: 1
readyReplicas: 1
---
# Print TA and operator logs if test fails
apiVersion: kuttl.dev/v1beta1
kind: TestAssert
collectors:
- selector: app.kubernetes.io/component=opentelemetry-targetallocator
- selector: app.kubernetes.io/component=opentelemetry-collector
- selector: app.kubernetes.io/name=opentelemetry-operator
namespace: opentelemetry-operator-system
container: manager
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
---
apiVersion: opentelemetry.io/v1alpha1
kind: OpenTelemetryCollector
metadata:
name: promreceiver-nopromconfig
spec:
mode: statefulset
targetAllocator:
enabled: true
image: "local/opentelemetry-operator-targetallocator:e2e"
serviceAccount: ta
prometheusCR:
enabled: true

config: |
receivers:
jaeger:
protocols:
grpc:
prometheus:
config:
scrape_configs: []
target_allocator:
endpoint: http://promreceiver-nopromconfig-targetallocator
interval: 30s
collector_id: ${POD_NAME}
http_sd_config:
refresh_interval: 10s
processors:
exporters:
logging:
extensions:
health_check:
service:
telemetry:
metrics:
address: :8888
extensions:
- health_check
pipelines:
traces:
receivers: [jaeger]
processors: []
exporters: [logging]

0 comments on commit a5537a1

Please sign in to comment.