From 0b2aedbe58a53810174a572f10482f4b80437a8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miko=C5=82aj=20=C5=9Awi=C4=85tek?= Date: Thu, 25 May 2023 17:39:51 +0200 Subject: [PATCH] Add E2E test for invalid targetallocator config --- cmd/otel-allocator/main.go | 1 + .../04-assert.yaml | 25 ++++++++++ .../04-promreceiver-noconfig.yaml | 46 +++++++++++++++++++ 3 files changed, 72 insertions(+) create mode 100644 tests/e2e/prometheus-config-validation/04-assert.yaml create mode 100644 tests/e2e/prometheus-config-validation/04-promreceiver-noconfig.yaml diff --git a/cmd/otel-allocator/main.go b/cmd/otel-allocator/main.go index 87d6ace99d..9b9fa956ca 100644 --- a/cmd/otel-allocator/main.go +++ b/cmd/otel-allocator/main.go @@ -72,6 +72,7 @@ func main() { cfg, configLoadErr := config.Load(*cliConf.ConfigFilePath) if configLoadErr != nil { setupLog.Error(configLoadErr, "Unable to load configuration") + os.Exit(1) } if validationErr := config.ValidateConfig(&cfg, &cliConf); validationErr != nil { diff --git a/tests/e2e/prometheus-config-validation/04-assert.yaml b/tests/e2e/prometheus-config-validation/04-assert.yaml new file mode 100644 index 0000000000..118faea0d1 --- /dev/null +++ b/tests/e2e/prometheus-config-validation/04-assert.yaml @@ -0,0 +1,25 @@ +apiVersion: apps/v1 +kind: StatefulSet +metadata: + name: promreceiver-noconfig-collector +status: + replicas: 1 + readyReplicas: 1 +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: promreceiver-noconfig-targetallocator +status: + replicas: 1 + unavailableReplicas: 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/04-promreceiver-noconfig.yaml b/tests/e2e/prometheus-config-validation/04-promreceiver-noconfig.yaml new file mode 100644 index 0000000000..54ed0c1efb --- /dev/null +++ b/tests/e2e/prometheus-config-validation/04-promreceiver-noconfig.yaml @@ -0,0 +1,46 @@ +--- +apiVersion: opentelemetry.io/v1alpha1 +kind: OpenTelemetryCollector +metadata: + name: promreceiver-noconfig +spec: + mode: statefulset + targetAllocator: + enabled: true + image: "local/opentelemetry-operator-targetallocator:e2e" + serviceAccount: ta + + config: | + receivers: + jaeger: + protocols: + grpc: + + prometheus: + config: + scrape_configs: [] + target_allocator: + endpoint: http://promreceiver-noconfig-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] +