Skip to content

Commit

Permalink
Add kuttl tests for prometheus configuration
Browse files Browse the repository at this point in the history
This patch adds some required prometheus secret for kuttl jobs to run
and adds validation checks.

Also, it modifies the watcher_deploy make target to create a secret so
that the watcher can be deployed until the secret is created by the
telemetry operator.
  • Loading branch information
amoralej committed Jan 23, 2025
1 parent b61921c commit 4219449
Show file tree
Hide file tree
Showing 9 changed files with 60 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -385,11 +385,13 @@ watcher: ## Install watcher operator via olm

.PHONY: watcher_deploy
watcher_deploy: ## Deploy watcher service
oc apply -f config/samples/watcher_requirements.yaml
oc apply -f config/samples/watcher_v1beta1_watcher.yaml

.PHONY: watcher_deploy_cleanup
watcher_deploy_cleanup: ## Undeploy watcher service
oc delete -f config/samples/watcher_v1beta1_watcher.yaml
oc delete -f config/samples/watcher_requirements.yaml

.PHONY: watcher_cleanup
watcher_cleanup: export CATALOG_IMG=${CATALOG_IMAGE}
Expand Down
9 changes: 9 additions & 0 deletions config/samples/watcher_requirements.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
apiVersion: v1
kind: Secret
metadata:
name: metric-storage-prometheus-config
namespace: openstack
stringData:
host: metric-storage-prometheus.openstack.svc
port: "9090"
prometheus_ca.crt: ""
10 changes: 10 additions & 0 deletions tests/kuttl/test-suites/default/common/cleanup-errors.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -96,3 +96,13 @@ apiVersion: keystone.openstack.org/v1beta1
kind: KeystoneEndpoint
metadata:
name: watcher
---
apiVersion: v1
kind: Secret
metadata:
name: metric-storage-prometheus-config
---
apiVersion: v1
kind: Secret
metadata:
name: custom-prometheus-config
6 changes: 6 additions & 0 deletions tests/kuttl/test-suites/default/common/cleanup-watcher.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,9 @@ delete:
- apiVersion: watcher.openstack.org/v1beta1
kind: Watcher
name: watcher-kuttl
- apiVersion: v1
kind: Secret
name: metric-storage-prometheus-config
- apiVersion: v1
kind: Secret
name: custom-prometheus-config
10 changes: 10 additions & 0 deletions tests/kuttl/test-suites/default/common/deploy-with-defaults.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
apiVersion: v1
kind: Secret
metadata:
name: metric-storage-prometheus-config
namespace: watcher-kuttl-default
stringData:
host: metric-storage-prometheus.watcher-kuttl-default.svc
port: "9090"
prometheus_ca.crt: ""
---
apiVersion: watcher.openstack.org/v1beta1
kind: Watcher
metadata:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
apiVersion: v1
kind: Secret
metadata:
name: metric-storage-prometheus-config
namespace: watcher-kuttl-default
stringData:
host: metric-storage-prometheus.watcher-kuttl-default.svc
port: "9090"
prometheus_ca.crt: ""
---
apiVersion: watcher.openstack.org/v1beta1
kind: Watcher
metadata:
Expand Down
1 change: 1 addition & 0 deletions tests/kuttl/test-suites/default/watcher/01-assert.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ spec:
apiServiceTemplate:
replicas: 1
resources: {}
prometheusSecret: metric-storage-prometheus-config
status:
apiServiceReadyCount: 1
conditions:
Expand Down
1 change: 1 addition & 0 deletions tests/kuttl/test-suites/default/watcher/04-assert.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ commands:
if [ -n "${APIPOD}" ]; then
[ $(echo $(oc rsh -c watcher-api ${APIPOD} cat /etc/watcher/watcher.conf.d/01-global-custom.conf) |grep -c "^# Global config") == 1 ]
[ $(echo $(oc rsh -c watcher-api ${APIPOD} cat /etc/watcher/watcher.conf.d/02-service-custom.conf) |grep -c "^# Service config") == 1 ]
[ $(echo $(oc rsh -c watcher-api ${APIPOD} cat /etc/watcher/watcher.conf.d/00-default.conf) |grep -czPo '\[prometheus_client\]\s+host\s+=\s+metric-storage-prometheus.watcher-kuttl-default.svc\s+port\s+=\s+9090') == 1 ]
else
exit 1
fi
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
apiVersion: v1
kind: Secret
metadata:
name: custom-prometheus-config
namespace: watcher-kuttl-default
stringData:
host: metric-storage-prometheus.watcher-kuttl-default.svc
port: "9090"
prometheus_ca.crt: ""
---
apiVersion: watcher.openstack.org/v1beta1
kind: Watcher
metadata:
Expand All @@ -6,6 +16,7 @@ metadata:
spec:
databaseInstance: "openstack"
databaseAccount: watcher-precreated
prometheusSecret: custom-prometheus-config
tls:
caBundleSecretName: "combined-ca-bundle"
customServiceConfig: |
Expand Down

0 comments on commit 4219449

Please sign in to comment.