diff --git a/hack/modify-test-images.sh b/hack/modify-test-images.sh index ee240ddbde..b43ee421bf 100755 --- a/hack/modify-test-images.sh +++ b/hack/modify-test-images.sh @@ -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 diff --git a/tests/e2e/prometheus-config-validation/00-assert.yaml b/tests/e2e/prometheus-config-validation/00-assert.yaml new file mode 100644 index 0000000000..3f4f177968 --- /dev/null +++ b/tests/e2e/prometheus-config-validation/00-assert.yaml @@ -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 diff --git a/tests/e2e/prometheus-config-validation/00-promreceiver-allocatorconfig.yaml b/tests/e2e/prometheus-config-validation/00-promreceiver-allocatorconfig.yaml new file mode 100644 index 0000000000..b53f21314b --- /dev/null +++ b/tests/e2e/prometheus-config-validation/00-promreceiver-allocatorconfig.yaml @@ -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] diff --git a/tests/e2e/prometheus-config-validation/01-assert.yaml b/tests/e2e/prometheus-config-validation/01-assert.yaml new file mode 100644 index 0000000000..07d50c63c4 --- /dev/null +++ b/tests/e2e/prometheus-config-validation/01-assert.yaml @@ -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 diff --git a/tests/e2e/prometheus-config-validation/01-promreceiver-labeldrop.yaml b/tests/e2e/prometheus-config-validation/01-promreceiver-labeldrop.yaml new file mode 100644 index 0000000000..1b57d96073 --- /dev/null +++ b/tests/e2e/prometheus-config-validation/01-promreceiver-labeldrop.yaml @@ -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] diff --git a/tests/e2e/prometheus-config-validation/02-assert.yaml b/tests/e2e/prometheus-config-validation/02-assert.yaml new file mode 100644 index 0000000000..33727878de --- /dev/null +++ b/tests/e2e/prometheus-config-validation/02-assert.yaml @@ -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 diff --git a/tests/e2e/prometheus-config-validation/02-promreceiver-allocatorconfig-extra.yaml b/tests/e2e/prometheus-config-validation/02-promreceiver-allocatorconfig-extra.yaml new file mode 100644 index 0000000000..f6190e439a --- /dev/null +++ b/tests/e2e/prometheus-config-validation/02-promreceiver-allocatorconfig-extra.yaml @@ -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] + diff --git a/tests/e2e/prometheus-config-validation/03-assert.yaml b/tests/e2e/prometheus-config-validation/03-assert.yaml new file mode 100644 index 0000000000..b9c6d5d5eb --- /dev/null +++ b/tests/e2e/prometheus-config-validation/03-assert.yaml @@ -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 diff --git a/tests/e2e/prometheus-config-validation/03-promreceiver-nopromconfig.yaml b/tests/e2e/prometheus-config-validation/03-promreceiver-nopromconfig.yaml new file mode 100644 index 0000000000..5420bb58a6 --- /dev/null +++ b/tests/e2e/prometheus-config-validation/03-promreceiver-nopromconfig.yaml @@ -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] +