Skip to content

Commit ba33b9e

Browse files
committed
Add Kuttl Tests for OKP
This commit adds Kuttl tests related to the OKP deployment support. Signed-off-by: Lucas Alvares Gomes <lucasagomes@gmail.com>
1 parent 1d251de commit ba33b9e

13 files changed

Lines changed: 317 additions & 0 deletions
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../common/mock-objects/mock-resources.yaml
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../common/mock-objects/assert-mock-objects-created.yaml
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
---
2+
apiVersion: v1
3+
kind: Secret
4+
metadata:
5+
name: okp-access-key-secret
6+
namespace: openstack-lightspeed
7+
type: Opaque
8+
stringData:
9+
access_key: test-okp-access-key
10+
---
11+
apiVersion: lightspeed.openstack.org/v1beta1
12+
kind: OpenStackLightspeed
13+
metadata:
14+
name: openstack-lightspeed
15+
namespace: openstack-lightspeed
16+
spec:
17+
llmEndpoint: http://mock-llm-api-server-pod:8000/v1
18+
llmEndpointType: openai
19+
llmCredentials: openstack-lightspeed-apitoken
20+
modelName: ibm-granite/granite-3.1-8b-instruct
21+
tlsCACertBundle: openstack-lightspeed-cert
22+
llmProjectID: test-project-id
23+
llmDeploymentName: test-deployment-name
24+
llmAPIVersion: v1
25+
enableOCPRAG: false
26+
logging:
27+
ogxLogLevel: DEBUG
28+
lightspeedStackLogLevel: WARNING
29+
dataverseExporterLogLevel: DEBUG
30+
dev:
31+
featureFlags:
32+
- okp
33+
okpChunkFilterQuery: "product:*openstack*"
34+
okp:
35+
accessKey: okp-access-key-secret
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
##############################################################################
2+
# Assert that the operator created all expected OKP resources #
3+
##############################################################################
4+
#
5+
# NOTE: The OKP image (registry.redhat.io/offline-knowledge-portal/rhokp-rhel9)
6+
# is not available in CI, so the OKP pod won't start. Additionally, llama-stack
7+
# fails at startup when the Solr provider (served by OKP) is unreachable, so the
8+
# main deployment also won't reach Ready. Therefore, this test only asserts on
9+
# resource specs (not readyReplicas or CR status) to verify the operator creates
10+
# the correct resources when OKP is enabled.
11+
12+
# OKP Deployment (spec only — image not pullable in CI)
13+
---
14+
apiVersion: apps/v1
15+
kind: Deployment
16+
metadata:
17+
name: lightspeed-okp-server
18+
namespace: openstack-lightspeed
19+
spec:
20+
template:
21+
spec:
22+
containers:
23+
- name: okp
24+
env:
25+
- name: ACCESS_KEY
26+
valueFrom:
27+
secretKeyRef:
28+
key: access_key
29+
name: okp-access-key-secret
30+
ports:
31+
- name: okp
32+
containerPort: 8080
33+
34+
# OKP Service
35+
---
36+
apiVersion: v1
37+
kind: Service
38+
metadata:
39+
name: lightspeed-okp-server
40+
namespace: openstack-lightspeed
41+
spec:
42+
ports:
43+
- name: http
44+
port: 8080
45+
protocol: TCP
46+
targetPort: okp
47+
type: ClusterIP
48+
49+
# Main deployment — assert OKP env vars are injected (spec only, pod won't be
50+
# ready because llama-stack can't connect to the OKP Solr provider in CI)
51+
---
52+
apiVersion: apps/v1
53+
kind: Deployment
54+
metadata:
55+
name: lightspeed-stack-deployment
56+
namespace: openstack-lightspeed
57+
spec:
58+
template:
59+
spec:
60+
containers:
61+
- name: llama-stack
62+
env:
63+
- name: OPENSTACK_LIGHTSPEED_PROVIDER_API_KEY
64+
valueFrom:
65+
secretKeyRef:
66+
key: apitoken
67+
name: openstack-lightspeed-apitoken
68+
- name: POSTGRES_PASSWORD
69+
valueFrom:
70+
secretKeyRef:
71+
key: password
72+
name: lightspeed-postgres-secret
73+
- name: LLAMA_STACK_LOGGING
74+
value: all=debug
75+
- name: OGX_LOGGING
76+
value: all=debug
77+
- name: VECTOR_DB_DATA_PATH
78+
value: /vector-db-discovered-values
79+
- name: RH_SERVER_OKP
80+
value: http://lightspeed-okp-server.openstack-lightspeed.svc:8080
81+
- name: HF_HOME
82+
value: /tmp/huggingface
83+
- name: lightspeed-service-api
84+
env:
85+
- name: LIGHTSPEED_STACK_LOG_LEVEL
86+
value: WARNING
87+
- name: POSTGRES_PASSWORD
88+
valueFrom:
89+
secretKeyRef:
90+
key: password
91+
name: lightspeed-postgres-secret
92+
- name: RH_SERVER_OKP
93+
value: http://lightspeed-okp-server.openstack-lightspeed.svc:8080
94+
- name: lightspeed-to-dataverse-exporter
95+
args:
96+
- --mode
97+
- openshift
98+
- --config
99+
- /etc/config/config.yaml
100+
- --log-level
101+
- DEBUG
102+
- --data-dir
103+
- /tmp/data
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# Validate OKP sections in the lightspeed-stack ConfigMap.
2+
#
3+
# We cannot use the standard validate-config.sh approach (oc exec into the pod)
4+
# because the main deployment won't reach Ready — llama-stack fails at startup
5+
# when the OKP Solr provider is unreachable in CI. Instead, we verify the
6+
# operator wrote the correct OKP config sections into the base ConfigMap.
7+
---
8+
apiVersion: kuttl.dev/v1beta1
9+
kind: TestAssert
10+
commands:
11+
- script: |
12+
#!/bin/bash
13+
set -euo pipefail
14+
15+
CONFIG=$(oc get configmap lightspeed-stack-config \
16+
-n openstack-lightspeed \
17+
-o jsonpath='{.data.lightspeed-stack\.yaml}')
18+
19+
ERRORS=0
20+
21+
# Verify OKP section exists with expected fields
22+
if ! echo "$CONFIG" | grep -q "rhokp_url:"; then
23+
echo "ERROR: missing okp.rhokp_url in lightspeed-stack config"
24+
ERRORS=$((ERRORS + 1))
25+
fi
26+
if ! echo "$CONFIG" | grep -q "offline: true"; then
27+
echo "ERROR: missing okp.offline in lightspeed-stack config"
28+
ERRORS=$((ERRORS + 1))
29+
fi
30+
if ! echo "$CONFIG" | grep -q 'chunk_filter_query:.*product:\*openstack\*'; then
31+
echo "ERROR: missing okp.chunk_filter_query in lightspeed-stack config"
32+
ERRORS=$((ERRORS + 1))
33+
fi
34+
35+
# Verify "okp" is in rag.inline
36+
if ! echo "$CONFIG" | grep -q "^\- okp$\|^ - okp$\|^ - okp$"; then
37+
echo "ERROR: 'okp' not found in rag.inline"
38+
ERRORS=$((ERRORS + 1))
39+
fi
40+
41+
if [ "$ERRORS" -gt 0 ]; then
42+
echo ""
43+
echo "lightspeed-stack config content:"
44+
echo "$CONFIG"
45+
exit 1
46+
fi
47+
48+
echo "✓ lightspeed-stack config contains OKP sections"
49+
timeout: 120
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# Validate OKP sections in the llama-stack ConfigMap.
2+
#
3+
# We cannot use the standard validate-config.sh approach (oc exec into the pod)
4+
# because the main deployment won't reach Ready — llama-stack fails at startup
5+
# when the OKP Solr provider is unreachable in CI. Instead, we verify the
6+
# operator wrote the correct OKP config sections into the base ConfigMap.
7+
---
8+
apiVersion: kuttl.dev/v1beta1
9+
kind: TestAssert
10+
commands:
11+
- script: |
12+
#!/bin/bash
13+
set -euo pipefail
14+
15+
CONFIG=$(oc get configmap llama-stack-config \
16+
-n openstack-lightspeed \
17+
-o jsonpath='{.data.ogx_config\.yaml}')
18+
19+
ERRORS=0
20+
21+
# Verify external_providers_dir is set (null when OKP is disabled)
22+
if ! echo "$CONFIG" | grep -q "external_providers_dir: /app-root/providers.d"; then
23+
echo "ERROR: external_providers_dir not set to /app-root/providers.d"
24+
ERRORS=$((ERRORS + 1))
25+
fi
26+
27+
# Verify OKP Solr vector_io provider
28+
if ! echo "$CONFIG" | grep -q "provider_id: okp_solr"; then
29+
echo "ERROR: missing okp_solr vector_io provider"
30+
ERRORS=$((ERRORS + 1))
31+
fi
32+
if ! echo "$CONFIG" | grep -q "provider_type: remote::solr_vector_io"; then
33+
echo "ERROR: missing remote::solr_vector_io provider type"
34+
ERRORS=$((ERRORS + 1))
35+
fi
36+
37+
# Verify OKP embedding model registration
38+
if ! echo "$CONFIG" | grep -q "model_id: solr_embedding"; then
39+
echo "ERROR: missing solr_embedding model"
40+
ERRORS=$((ERRORS + 1))
41+
fi
42+
43+
# Verify OKP vector store registration
44+
if ! echo "$CONFIG" | grep -q "vector_store_id: portal-rag"; then
45+
echo "ERROR: missing portal-rag vector store"
46+
ERRORS=$((ERRORS + 1))
47+
fi
48+
49+
if [ "$ERRORS" -gt 0 ]; then
50+
echo ""
51+
echo "llama-stack config content:"
52+
echo "$CONFIG"
53+
exit 1
54+
fi
55+
56+
echo "✓ llama-stack config contains OKP sections"
57+
timeout: 120
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
apiVersion: lightspeed.openstack.org/v1beta1
3+
kind: OpenStackLightspeed
4+
metadata:
5+
name: openstack-lightspeed
6+
namespace: openstack-lightspeed
7+
spec:
8+
llmEndpoint: http://mock-llm-api-server-pod:8000/v1
9+
llmEndpointType: openai
10+
llmCredentials: openstack-lightspeed-apitoken
11+
modelName: ibm-granite/granite-3.1-8b-instruct
12+
tlsCACertBundle: openstack-lightspeed-cert
13+
llmProjectID: test-project-id
14+
llmDeploymentName: test-deployment-name
15+
llmAPIVersion: v1
16+
enableOCPRAG: false
17+
logging:
18+
ogxLogLevel: DEBUG
19+
lightspeedStackLogLevel: WARNING
20+
dataverseExporterLogLevel: DEBUG
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# After disabling OKP, the main deployment should recover (no more Solr
2+
# dependency) and the CR should reach Ready. This also confirms the operator
3+
# reconciled the updated CR and removed OKP-specific config.
4+
---
5+
apiVersion: apps/v1
6+
kind: Deployment
7+
metadata:
8+
name: lightspeed-stack-deployment
9+
namespace: openstack-lightspeed
10+
status:
11+
replicas: 1
12+
readyReplicas: 1
13+
availableReplicas: 1
14+
---
15+
apiVersion: lightspeed.openstack.org/v1beta1
16+
kind: OpenStackLightspeed
17+
metadata:
18+
name: openstack-lightspeed
19+
namespace: openstack-lightspeed
20+
status:
21+
conditions:
22+
- type: Ready
23+
status: "True"
24+
reason: Ready
25+
message: Setup complete
26+
- type: OCPRAGReady
27+
status: "True"
28+
reason: Ready
29+
message: OCP RAG is disabled
30+
- type: OpenStackLightspeedReady
31+
status: "True"
32+
reason: Ready
33+
message: OpenStack Lightspeed created
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# OKP Deployment should be gone
2+
---
3+
apiVersion: apps/v1
4+
kind: Deployment
5+
metadata:
6+
name: lightspeed-okp-server
7+
namespace: openstack-lightspeed
8+
# OKP Service should be gone
9+
---
10+
apiVersion: v1
11+
kind: Service
12+
metadata:
13+
name: lightspeed-okp-server
14+
namespace: openstack-lightspeed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../common/openstack-lightspeed-instance/cleanup-openstack-lightspeed-instance.yaml

0 commit comments

Comments
 (0)