Skip to content

Commit

Permalink
Add E2E test for invalid targetallocator config
Browse files Browse the repository at this point in the history
  • Loading branch information
Mikołaj Świątek committed May 25, 2023
1 parent 707a986 commit 0b2aedb
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 0 deletions.
1 change: 1 addition & 0 deletions cmd/otel-allocator/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
25 changes: 25 additions & 0 deletions tests/e2e/prometheus-config-validation/04-assert.yaml
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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]

0 comments on commit 0b2aedb

Please sign in to comment.