Skip to content

Commit b371d7d

Browse files
committed
Add kuttl tests for lightspeed-app-server /metrics endpoint
The kuttl test asserts that the endpoint is reachable and responds with a valid Prometheus format.
1 parent e2975e3 commit b371d7d

8 files changed

Lines changed: 91 additions & 3 deletions

File tree

bundle/manifests/openstack-lightspeed-operator.clusterserviceversion.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ metadata:
2525
]
2626
capabilities: Basic Install
2727
categories: AI/Machine Learning
28-
createdAt: "2026-07-13T09:32:13Z"
28+
createdAt: "2026-07-15T14:51:41Z"
2929
description: AI-powered virtual assistant for Red Hat OpenStack Services on OpenShift
3030
features.operators.openshift.io/cnf: "false"
3131
features.operators.openshift.io/cni: "false"
@@ -305,7 +305,7 @@ spec:
305305
value: registry.redhat.io/openshift-lightspeed/lightspeed-console-plugin-rhel9:1.0.12
306306
- name: RELATED_IMAGE_CONSOLE_PF5_IMAGE_URL_DEFAULT
307307
value: registry.redhat.io/openshift-lightspeed/lightspeed-console-plugin-pf5-rhel9:1.0.12
308-
image: quay.io/openstack-lightspeed/operator:latest
308+
image: image-registry.openshift-image-registry.svc:5000/openstack-lightspeed/operator:latest
309309
livenessProbe:
310310
httpGet:
311311
path: /healthz

config/manager/kustomization.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ apiVersion: kustomize.config.k8s.io/v1beta1
44
kind: Kustomization
55
images:
66
- name: controller
7-
newName: quay.io/openstack-lightspeed/operator
7+
newName: image-registry.openshift-image-registry.svc:5000/openstack-lightspeed/operator
88
newTag: latest
99
patches:
1010
- patch: '[{"op": "replace", "path": "/spec/template/spec/containers/0/env/0/value",
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
---
2+
apiVersion: kuttl.dev/v1beta1
3+
kind: TestAssert
4+
commands:
5+
- script: |
6+
#!/bin/bash
7+
set -euo pipefail
8+
9+
NAMESPACE="openstack-lightspeed"
10+
CONTAINER="lightspeed-service-api"
11+
METRICS_PORT=8443
12+
METRICS_PATH="/metrics"
13+
SA_NAME="lightspeed-metrics-test"
14+
15+
echo "Creating test ServiceAccount and RBAC for metrics access..."
16+
oc create serviceaccount "$SA_NAME" -n "$NAMESPACE" --dry-run=client -o yaml | oc apply -f -
17+
cat <<EOF | oc apply -f -
18+
apiVersion: rbac.authorization.k8s.io/v1
19+
kind: ClusterRole
20+
metadata:
21+
name: ${SA_NAME}-role
22+
rules:
23+
- nonResourceURLs: ["/ls-access"]
24+
verbs: ["get"]
25+
---
26+
apiVersion: rbac.authorization.k8s.io/v1
27+
kind: ClusterRoleBinding
28+
metadata:
29+
name: ${SA_NAME}-binding
30+
roleRef:
31+
apiGroup: rbac.authorization.k8s.io
32+
kind: ClusterRole
33+
name: ${SA_NAME}-role
34+
subjects:
35+
- kind: ServiceAccount
36+
name: ${SA_NAME}
37+
namespace: ${NAMESPACE}
38+
EOF
39+
40+
echo "Getting bearer token..."
41+
TOKEN="$(oc create token "$SA_NAME" -n "$NAMESPACE")"
42+
43+
echo "Waiting for lightspeed-stack-deployment pod to be ready..."
44+
oc wait --for=condition=Ready pod \
45+
-l app.kubernetes.io/name=openstack-lightspeed-app-server \
46+
-n "$NAMESPACE" \
47+
--timeout=120s
48+
49+
echo "Getting pod name..."
50+
POD_NAME="$(oc get pods \
51+
-l app.kubernetes.io/name=openstack-lightspeed-app-server \
52+
-n "$NAMESPACE" \
53+
-o jsonpath='{.items[0].metadata.name}')"
54+
55+
if [ -z "$POD_NAME" ]; then
56+
echo "ERROR: No pod found for lightspeed-app-server"
57+
exit 1
58+
fi
59+
60+
echo "Fetching metrics from pod $POD_NAME (container: $CONTAINER)..."
61+
METRICS_OUTPUT="$(oc exec -n "$NAMESPACE" "$POD_NAME" \
62+
-c "$CONTAINER" -- \
63+
curl -sk -H "Authorization: Bearer ${TOKEN}" \
64+
"https://localhost:${METRICS_PORT}${METRICS_PATH}")"
65+
66+
if [ -z "$METRICS_OUTPUT" ]; then
67+
echo "ERROR: Empty response from /metrics endpoint"
68+
exit 1
69+
fi
70+
71+
echo "Validating response is valid Prometheus exposition format..."
72+
if ! echo "$METRICS_OUTPUT" | grep -q "^# HELP "; then
73+
echo "ERROR: Response does not contain Prometheus HELP declarations"
74+
echo "Response (first 500 chars):"
75+
echo "$METRICS_OUTPUT" | head -c 500
76+
exit 1
77+
fi
78+
79+
if ! echo "$METRICS_OUTPUT" | grep -q "^# TYPE "; then
80+
echo "ERROR: Response does not contain Prometheus TYPE declarations"
81+
echo "Response (first 500 chars):"
82+
echo "$METRICS_OUTPUT" | head -c 500
83+
exit 1
84+
fi
85+
86+
echo "Metrics endpoint is reachable and returns valid Prometheus format"
87+
timeout: 180
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../common/openstack-lightspeed-instance/assert-metrics-endpoint.yaml

test/kuttl/tests/basic-openstack-lightspeed-configuration/07-cleanup-openstack-lightspeed-instance.yaml renamed to test/kuttl/tests/basic-openstack-lightspeed-configuration/08-cleanup-openstack-lightspeed-instance.yaml

File renamed without changes.

test/kuttl/tests/basic-openstack-lightspeed-configuration/08-errors-openstack-lightspeed-instance.yaml renamed to test/kuttl/tests/basic-openstack-lightspeed-configuration/09-errors-openstack-lightspeed-instance.yaml

File renamed without changes.

test/kuttl/tests/basic-openstack-lightspeed-configuration/09-cleanup-mock-objects.yaml renamed to test/kuttl/tests/basic-openstack-lightspeed-configuration/10-cleanup-mock-objects.yaml

File renamed without changes.

test/kuttl/tests/basic-openstack-lightspeed-configuration/10-errors-mock-objects.yaml renamed to test/kuttl/tests/basic-openstack-lightspeed-configuration/11-errors-mock-objects.yaml

File renamed without changes.

0 commit comments

Comments
 (0)