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 27, 2025
1 parent c0618a9 commit c204545
Show file tree
Hide file tree
Showing 12 changed files with 103 additions and 1 deletion.
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
10 changes: 10 additions & 0 deletions config/samples/watcher_requirements.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: v1
kind: Secret
metadata:
name: metric-storage-prometheus-config
namespace: openstack
stringData:
host: metric-storage-prometheus.openstack.svc
port: "9090"
ca_secret: "combined-ca-bundle"
ca_key: "internal-ca-bundle.pem"
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
11 changes: 11 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,14 @@
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"
ca_secret: "combined-ca-bundle"
ca_key: "internal-ca-bundle.pem"
---
apiVersion: watcher.openstack.org/v1beta1
kind: Watcher
metadata:
Expand Down
2 changes: 1 addition & 1 deletion tests/kuttl/test-suites/default/deps/infra.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ spec:
cinder:
enabled: false
telemetry:
enabled: false
enabled: true
3 changes: 3 additions & 0 deletions tests/kuttl/test-suites/default/deps/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ namespace: watcher-kuttl-default
secretGenerator:
- literals:
- AdminPassword=password
- AodhPassword=password
- CeilometerPassword=password
- DbRootPassword=password
- DatabasePassword=password
- WatcherPassword=password
Expand Down Expand Up @@ -40,3 +42,4 @@ patches:
secret: osp-secret
- path: infra.yaml
- path: keystone.yaml
- path: telemetry.yaml
35 changes: 35 additions & 0 deletions tests/kuttl/test-suites/default/deps/telemetry.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
apiVersion: core.openstack.org/v1beta1
kind: OpenStackControlPlane
metadata:
name: openstack
spec:
telemetry:
template:
metricStorage:
enabled: true
dashboardsEnabled: true
monitoringStack:
alertingEnabled: true
scrapeInterval: 30s
storage:
strategy: persistent
retention: 24h
persistent:
pvcStorageRequest: 1G
autoscaling:
enabled: false
aodh:
passwordSelectors:
databaseAccount: aodh
databaseInstance: openstack
secret: osp-secret
heatInstance: heat
ceilometer:
enabled: true
secret: osp-secret
passwordSelector:
aodhService: AodhPassword
ceilometerService: CeilometerPassword
serviceUser: ceilometer
logging:
enabled: false
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
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"
ca_secret: "combined-ca-bundle"
ca_key: "internal-ca-bundle.pem"
---
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\s+cafile\s+=\s+/etc/pki/ca-trust/extracted/pem/prometheus/internal-ca-bundle.pem') == 1 ]
else
exit 1
fi
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
apiVersion: v1
kind: Secret
metadata:
name: custom-prometheus-config
namespace: watcher-kuttl-default
stringData:
host: metric-storage-prometheus.watcher-kuttl-default.svc
port: "9090"
ca_secret: "combined-ca-bundle"
ca_key: "internal-ca-bundle.pem"
---
apiVersion: watcher.openstack.org/v1beta1
kind: Watcher
metadata:
Expand All @@ -6,6 +17,7 @@ metadata:
spec:
databaseInstance: "openstack"
databaseAccount: watcher-precreated
prometheusSecret: custom-prometheus-config
tls:
caBundleSecretName: "combined-ca-bundle"
customServiceConfig: |
Expand Down

0 comments on commit c204545

Please sign in to comment.