From 1177e8a31dbcf9725796d4a9a00596ad2f5d96b8 Mon Sep 17 00:00:00 2001 From: Radovan Fuchs Date: Wed, 25 Nov 2026 12:37:45 +0100 Subject: [PATCH 1/2] update the konflux files to run in lib mode only --- .tekton/integration-tests/README.md | 3 +- .../lightspeed-stack-integration-test.yaml | 7 +- .../lightspeed-stack-rhelai-test.yaml | 2 +- docs/testing/e2e_testing.md | 15 +- .../lightspeed/lightspeed-stack.yaml | 101 ++- .../manifests/lightspeed/ogx-openai.yaml | 3 + tests/e2e-prow/rhoai/pipeline-konflux.sh | 124 +-- .../rhoai/pipeline-services-konflux.sh | 41 +- tests/e2e-prow/rhoai/pipeline.sh | 2 +- tests/e2e-prow/rhoai/run-tests.sh | 7 + tests/e2e-prow/rhoai/scripts/e2e-ops.sh | 704 ++---------------- .../library-mode/lightspeed-stack-rhelai.yaml | 44 ++ tests/e2e/features/environment.py | 7 +- tests/e2e/features/steps/common.py | 11 +- tests/e2e/utils/README.md | 4 - tests/e2e/utils/ogx_prow_utils.py | 42 -- tests/e2e/utils/prow_utils.py | 139 ++-- tests/e2e/utils/utils.py | 20 +- 18 files changed, 342 insertions(+), 934 deletions(-) create mode 100644 tests/e2e/configuration/library-mode/lightspeed-stack-rhelai.yaml delete mode 100644 tests/e2e/utils/ogx_prow_utils.py diff --git a/.tekton/integration-tests/README.md b/.tekton/integration-tests/README.md index 963cd70f4c..ef937a33dc 100644 --- a/.tekton/integration-tests/README.md +++ b/.tekton/integration-tests/README.md @@ -4,7 +4,8 @@ ### OpenAI E2E (`lightspeed-stack-integration-test.yaml`) -Standard e2e test pipeline using OpenAI as the inference provider. +Standard e2e test pipeline using OpenAI as the inference provider. Deploys a single +`lightspeed-stack-service` pod (library mode, OGX in-process) via `pipeline-konflux.sh`. ### RHEL AI E2E (`lightspeed-stack-rhelai-test.yaml`) diff --git a/.tekton/integration-tests/pipeline/lightspeed-stack-integration-test.yaml b/.tekton/integration-tests/pipeline/lightspeed-stack-integration-test.yaml index 47072844f5..55b6f439fd 100644 --- a/.tekton/integration-tests/pipeline/lightspeed-stack-integration-test.yaml +++ b/.tekton/integration-tests/pipeline/lightspeed-stack-integration-test.yaml @@ -14,8 +14,8 @@ spec: default: '{"components": [{"name":"lightspeed-stack-0-8", "containerImage": "quay.io/example/lightspeed-stack-0-8:latest"}]}' type: string - name: llama-stack-image - description: 'OGX runs from source on UBI (init container clones repo and installs deps). Parameter name kept for backwards compatibility.' - default: 'run-from-source (UBI)' + description: 'Deprecated (library mode). Kept for Konflux parameter compatibility; OGX runs in-process in lightspeed-stack.' + default: 'in-process (library mode)' type: string - name: test-name description: 'The name of the test corresponding to a defined Konflux integration test.' @@ -63,7 +63,7 @@ spec: - name: env value: '{"COMPUTE_NODE_TYPE":"$(params.compute-node-type)","HOSTED_MANAGEMENT_CLUSTER":"$(params.hosted-management-cluster)"}' - name: get-stack-images - description: Extract lightspeed-stack image and commit from SNAPSHOT (OGX runs from source in-pod) + description: Extract lightspeed-stack image and commit from SNAPSHOT (Konflux E2E library mode) runAfter: - provision-cluster params: @@ -237,6 +237,7 @@ spec: value: "true" - name: LIGHTSPEED_STACK_IMAGE value: "$(params.lightspeedstackimage)" + # LLAMA_STACK_IMAGE: deprecated param; echoed only (library mode, no separate OGX image). - name: LLAMA_STACK_IMAGE value: "$(params.llamastackimage)" - name: NAMESPACE diff --git a/.tekton/integration-tests/pipeline/lightspeed-stack-rhelai-test.yaml b/.tekton/integration-tests/pipeline/lightspeed-stack-rhelai-test.yaml index ce8ae44a14..d058a21624 100644 --- a/.tekton/integration-tests/pipeline/lightspeed-stack-rhelai-test.yaml +++ b/.tekton/integration-tests/pipeline/lightspeed-stack-rhelai-test.yaml @@ -526,7 +526,7 @@ spec: cd tests/e2e-prow/rhoai && chmod +x pipeline-konflux.sh echo "[e2e] 7/8 Running pipeline-konflux.sh with RHEL AI configs..." export LLAMA_STACK_CONFIG="$(cd ../../.. && pwd)/tests/e2e/configs/run-rhelai.yaml" - export LCS_CONFIG="$(cd ../../.. && pwd)/tests/e2e/configuration/server-mode/lightspeed-stack-rhelai.yaml" + export LCS_CONFIG="$(cd ../../.. && pwd)/tests/e2e/configuration/library-mode/lightspeed-stack-rhelai.yaml" ./pipeline-konflux.sh PIPELINE_EXIT=$? echo "[e2e] 8/8 pipeline-konflux.sh exited with code $PIPELINE_EXIT" diff --git a/docs/testing/e2e_testing.md b/docs/testing/e2e_testing.md index bced4e7ef0..03856271ed 100644 --- a/docs/testing/e2e_testing.md +++ b/docs/testing/e2e_testing.md @@ -74,21 +74,21 @@ tests/e2e-prow/ └── rhoai/ # RHOAI / OpenShift E2E ├── run-tests.sh # Entry to run E2E in Prow ├── pipeline.sh # Prow: full vLLM + LCS + behave (main branch workflow) - ├── pipeline-konflux.sh # Konflux: OpenAI Llama run-from-source + run-ci.yaml + behave + ├── pipeline-konflux.sh # Konflux: library-mode LCS pod + run-ci.yaml + behave ├── pipeline-services.sh # Services for Prow (vLLM OGX image + LCS) - ├── pipeline-services-konflux.sh # Services for Konflux (ogx-openai + templated LCS) + ├── pipeline-services-konflux.sh # Konflux: library-mode lightspeed-stack pod only ├── pipeline-vllm.sh # vLLM cluster setup (called from pipeline.sh) ├── pipeline-test-pod.sh # Test pod pipeline ├── configs/ # vLLM OGX `run.yaml` (used by pipeline.sh for ogx-config ConfigMap seed) ├── scripts/ - │ ├── e2e-ops.sh # E2E ops (e.g. disrupt/restore OGX) — called from prow_utils + │ ├── e2e-ops.sh # E2E ops (Konflux library mode: single LCS pod) │ ├── bootstrap.sh │ ├── deploy-vllm.sh │ ├── fetch-vllm-image.sh │ ├── get-vllm-pod-info.sh │ └── gpu-setup.sh └── manifests/ # OpenShift/Kubernetes manifests - ├── lightspeed/ # Lightspeed stack, OGX, mock-jwks, mock-mcp + ├── lightspeed/ # LCS pod manifest, ogx-prow (classic Prow), mocks ├── vllm/ # vLLM runtime and inference services (CPU/GPU) ├── operators/ # Operator install (operatorgroup, operators, ds-cluster) ├── namespaces/ # NFD, nvidia-operator @@ -287,7 +287,8 @@ For another YAML (`lightspeed-stack-okp-online.yaml`, tool RAG, and so on), repe | Variable | Default | Description | |---------------------------------|-------------|-------------------------------------------------------------------------------------------------------------------------------------------| -| `E2E_DEPLOYMENT_MODE` | `server` | `server` or `library`. Drives config paths and which scenarios run (e.g. `@skip-in-library-mode`). | +| `E2E_DEPLOYMENT_MODE` | `server` | `server` or `library`. Drives config paths and which scenarios run (e.g. `@skip-in-library-mode`). Konflux forces `library`. | +| `E2E_LIGHTSPEED_CONFIG_DIR` | see below | Repo-relative folder for Prow/Konflux ConfigMap YAML sources. Konflux default: `tests/e2e/configuration/library-mode`. | | `E2E_LSC_HOSTNAME` | `localhost` | Host of the Lightspeed Core Stack API. | | `E2E_LSC_PORT` | `8080` | Port of the Lightspeed Core Stack API. | | `E2E_OGX_HOSTNAME` | `localhost` | Host of the OGX service (server mode). GitHub Actions repo variable: `E2E_LLAMA_HOSTNAME` (compose maps it here). | @@ -313,8 +314,12 @@ For local Docker runs, defaults are usually enough. Override when the stack is o - **Server mode** (`E2E_DEPLOYMENT_MODE=server`): Lightspeed Core Stack talks to a **separate** OGX service (e.g. `OGX` container). Configs under `configuration/server-mode/` are used. Scenarios that need a dedicated OGX container (e.g. "OGX unreachable") run; those tagged `@skip-in-library-mode` run as well. - **Library mode** (`E2E_DEPLOYMENT_MODE=library`): OGX runs **in-process** with the app. Configs under `configuration/library-mode/` are used. Scenarios tagged `@skip-in-library-mode` are skipped (no separate OGX to disrupt or query for shields). +**Konflux** (`pipeline-konflux.sh`) always sets `E2E_DEPLOYMENT_MODE=library` and deploys only `lightspeed-stack-service` (no `llama-stack-service`, no `:8321` port-forward). The OpenShift ConfigMap `llama-stack-config` still holds the synthesis profile `run.yaml` mounted into the LCS pod. + Mode is set in `before_all` from `E2E_DEPLOYMENT_MODE` and stored as `context.is_library_mode`. +**Konflux** (`pipeline-konflux.sh`) and the Tekton integration pipelines set `E2E_DEPLOYMENT_MODE=library` and deploy a single `lightspeed-stack-service` pod (no `llama-stack-service` / `ogx-openai.yaml`). **Classic Prow** (`pipeline.sh`) remains server mode with `ogx-prow.yaml`. + --- ## Tags and Hooks diff --git a/tests/e2e-prow/rhoai/manifests/lightspeed/lightspeed-stack.yaml b/tests/e2e-prow/rhoai/manifests/lightspeed/lightspeed-stack.yaml index 3370030517..9e9ad780dc 100644 --- a/tests/e2e-prow/rhoai/manifests/lightspeed/lightspeed-stack.yaml +++ b/tests/e2e-prow/rhoai/manifests/lightspeed/lightspeed-stack.yaml @@ -1,14 +1,18 @@ +# Konflux / library-mode E2E: single pod with in-process OGX (matches docker-compose-library.yaml). +# Needs ConfigMaps: lightspeed-stack-config, llama-stack-config (legacy name — key run.yaml), rag-data, e2e-skills; +# Secrets: openai-api-key-secret, optional faiss-vector-store-secret, optional vllm-* for RHEL AI. apiVersion: v1 kind: Pod metadata: name: lightspeed-stack-service spec: + imagePullSecrets: + - name: quay-lightspeed-pull-secret securityContext: seccompProfile: type: RuntimeDefault - # Seed agent-skills fixtures (docker-compose: ./tests/e2e/skills -> /app-root/skills). - # ConfigMap cannot preserve nested skill dirs; extract tarball into emptyDir. initContainers: + # Seed agent-skills fixtures (docker-compose: ./tests/e2e/skills -> /app-root/skills). - name: seed-skills image: busybox:latest securityContext: @@ -25,13 +29,44 @@ spec: - | set -e tar xzf /skills-seed/skills.tgz -C /skills-dest - ls -la /skills-dest volumeMounts: - name: skills-seed mountPath: /skills-seed readOnly: true - name: skills mountPath: /skills-dest + # FAISS BYOK fixture — entrypoint.sh copies seed into KV_RAG_PATH (writable). + - name: seed-rag + image: busybox:latest + securityContext: + allowPrivilegeEscalation: false + capabilities: + drop: ["ALL"] + runAsNonRoot: true + runAsUser: 1000 + seccompProfile: + type: RuntimeDefault + command: + - /bin/sh + - -c + - | + set -e + if [ ! -f /rag-seed/kv_store.db.gz ]; then + echo "WARN: rag-data ConfigMap missing kv_store.db.gz" + exit 0 + fi + gzip -dc /rag-seed/kv_store.db.gz > /rag-dest/kv_store.db + sz=$(wc -c < /rag-dest/kv_store.db) + if [ "$sz" -lt 1048576 ]; then + echo "FATAL: RAG seed too small (${sz} bytes)" + exit 1 + fi + volumeMounts: + - name: rag-data + mountPath: /rag-seed + readOnly: true + - name: rag-seed + mountPath: /rag-dest containers: - name: lightspeed-stack-container securityContext: @@ -43,45 +78,51 @@ spec: seccompProfile: type: RuntimeDefault env: - - name: E2E_OGX_HOSTNAME + - name: OPENAI_API_KEY valueFrom: secretKeyRef: - name: llama-stack-ip-secret + name: openai-api-key-secret key: key + - name: E2E_OPENAI_MODEL + value: "gpt-5.6-luna" - name: FAISS_VECTOR_STORE_ID valueFrom: secretKeyRef: name: faiss-vector-store-secret key: id optional: true - # LCS inference.providers (openai): pydantic-ai reads OPENAI_API_KEY at startup. - - name: OPENAI_API_KEY + - name: RAG_SEED_DIR + value: "/app-root/.e2e-rag-seed" + - name: KV_RAG_PATH + value: "/tmp/e2e-rag-work/kv_store.db" + - name: VLLM_URL valueFrom: secretKeyRef: - name: openai-api-key-secret + name: vllm-url-secret + key: key + optional: true + - name: VLLM_API_KEY + valueFrom: + secretKeyRef: + name: vllm-api-key-secret key: key optional: true - - name: E2E_OPENAI_MODEL - value: "gpt-5.6-luna" - # Unused for server-mode FAISS (llama pod owns the fixture); keep out of ~/.llama. - - name: KV_RAG_PATH - value: "/app-root/.e2e-rag-work/kv_store.db" - - name: OTEL_SDK_DISABLED - value: "true" - - name: OTEL_ANONYMIZATION_SECRET - value: "lightspeed-stack-otel-anonymization-dev-default" - name: VLLM_MODEL valueFrom: secretKeyRef: name: vllm-model-secret key: key optional: true + - name: OTEL_SDK_DISABLED + value: "true" + - name: OTEL_ANONYMIZATION_SECRET + value: "lightspeed-stack-otel-anonymization-dev-default" + - name: HF_HUB_OFFLINE + value: "1" image: ${LIGHTSPEED_STACK_IMAGE} - command: ["/bin/sh", "-c", "mkdir -p /tmp/data && exec /app-root/entrypoint.sh"] + command: ["/bin/sh", "-c", "mkdir -p /tmp/data /tmp/e2e-rag-work && exec /app-root/entrypoint.sh"] ports: - containerPort: 8080 - # TCP probes avoid HTTP/auth. LCS + Llama handshake and large images can take 60–120s before :8080 listens; - # aggressive liveness was killing the container (connection refused) and breaking port-forward sandboxes. readinessProbe: tcpSocket: port: 8080 @@ -98,16 +139,19 @@ spec: - name: config mountPath: /app-root/lightspeed-stack.yaml subPath: lightspeed-stack.yaml - # Agent skills E2E (skills.feature): matches docker-compose mount path + - name: ogx-run-config + mountPath: /app-root/run.yaml + subPath: run.yaml + - name: rag-seed + mountPath: /app-root/.e2e-rag-seed + readOnly: true - name: skills mountPath: /app-root/skills readOnly: true - # MCPFileAuth E2E: must match authorization_headers paths in lightspeed-stack-mcp-file-auth.yaml (/tmp/mcp-token) - name: mcp-file-auth-token mountPath: /tmp/mcp-token subPath: token readOnly: true - # InvalidMCPFileAuthConfig E2E: docker-compose mounts tests/e2e/secrets/invalid-mcp-token here - name: mcp-invalid-file-auth-token mountPath: /tmp/invalid-mcp-token subPath: token @@ -116,6 +160,15 @@ spec: - name: config configMap: name: lightspeed-stack-config + - name: ogx-run-config + configMap: + name: llama-stack-config + - name: rag-data + configMap: + name: rag-data + optional: true + - name: rag-seed + emptyDir: {} - name: skills-seed configMap: name: e2e-skills @@ -126,4 +179,4 @@ spec: secretName: mcp-file-auth-token - name: mcp-invalid-file-auth-token secret: - secretName: mcp-invalid-file-auth-token + secretName: mcp-invalid-file-auth-token \ No newline at end of file diff --git a/tests/e2e-prow/rhoai/manifests/lightspeed/ogx-openai.yaml b/tests/e2e-prow/rhoai/manifests/lightspeed/ogx-openai.yaml index ea199c6c03..1c577a6b26 100644 --- a/tests/e2e-prow/rhoai/manifests/lightspeed/ogx-openai.yaml +++ b/tests/e2e-prow/rhoai/manifests/lightspeed/ogx-openai.yaml @@ -1,3 +1,6 @@ +# DEPRECATED for Konflux E2E (library mode uses lightspeed-stack.yaml only). +# Retained for reference / historical server-mode experiments — not applied by pipeline-konflux.sh. +# # OGX from source on UBI: init clones repo + seeds FAISS, main restores seed then uses # scripts/ogx-entrypoint.sh (same enrich/start path as GitHub Actions docker-compose). # Needs ConfigMaps: llama-stack-config (run.yaml), rag-data (kv_store.db.gz), lightspeed-stack-config; diff --git a/tests/e2e-prow/rhoai/pipeline-konflux.sh b/tests/e2e-prow/rhoai/pipeline-konflux.sh index 70cc11b0aa..3fd251ba48 100755 --- a/tests/e2e-prow/rhoai/pipeline-konflux.sh +++ b/tests/e2e-prow/rhoai/pipeline-konflux.sh @@ -1,13 +1,15 @@ #!/bin/bash -# Konflux integration E2E: OGX run-from-source + configurable inference provider. -# Default: OpenAI (run-ci.yaml). For RHEL AI vLLM: set LLAMA_STACK_CONFIG and LCS_CONFIG env vars. -# Prow (vLLM) workflow uses pipeline.sh unchanged. +# Konflux integration E2E: library mode only (OGX in-process in lightspeed-stack-service). +# Default: OpenAI (run-ci.yaml + configuration/library-mode/lightspeed-stack.yaml). +# RHEL AI vLLM: set LLAMA_STACK_CONFIG and LCS_CONFIG in Tekton. Classic Prow uses pipeline.sh (unchanged here). set -euo pipefail trap 'echo "❌ Pipeline failed at line $LINENO"; exit 1' ERR # Signal to e2e tests that we're running in Prow/OpenShift export RUNNING_PROW=true export E2E_KONFLUX_E2E=1 +export E2E_DEPLOYMENT_MODE=library +export E2E_LIGHTSPEED_CONFIG_DIR="${E2E_LIGHTSPEED_CONFIG_DIR:-tests/e2e/configuration/library-mode}" #======================================== # 1. GLOBAL CONFIG @@ -21,7 +23,7 @@ log() { [ "$QUIET" != "1" ] && echo "$@"; } # Always print progress so Konflux UI shows where we are (short one-liners) progress() { echo "[e2e] $*"; } -# Lightspeed-stack image (from Konflux SNAPSHOT or default). OGX runs from source in-pod (no image). +# Lightspeed-stack image (from Konflux SNAPSHOT or default); OGX is in-process in that image. LIGHTSPEED_STACK_IMAGE="${LIGHTSPEED_STACK_IMAGE:-quay.io/lightspeed-core/lightspeed-stack:dev-latest}" log "Using lightspeed-stack image: $LIGHTSPEED_STACK_IMAGE" export LIGHTSPEED_STACK_IMAGE @@ -203,37 +205,22 @@ log "✅ Mock servers deployed" # before_feature via e2e-ops deploy-okp-solr (7GB image, ~10-15 min first pull). # No other e2e feature depends on OKP. # -# e2e-tunnel-proxy and e2e-interception-proxy are deployed from proxy.feature steps -# (see tests/e2e/features/steps/proxy.py + e2e-ops deploy-e2e-*-proxy). +# Proxy/TLS networking tests use Docker Compose only (@skip-in-prow). #======================================== -# 5. DEPLOY LIGHTSPEED STACK AND OGX +# 5. DEPLOY LIGHTSPEED STACK (LIBRARY MODE) #======================================== -progress "Deploying lightspeed-stack and llama-stack" +progress "Deploying lightspeed-stack (library mode)" -# PVC for OGX app-root: caches dnf/uv/git install so TLS per-scenario pod -# recreates skip the expensive init (~6-15 min → ~1-2 min). Delete first to guarantee -# a fresh checkout for this pipeline revision; re-create immediately so the pod can bind. -log "Recreating llama-stack-app-root PVC (fresh per pipeline run)..." +# Drop legacy server-mode llama-stack resources from earlier pipeline revisions. +oc delete pod llama-stack-service -n "$NAMESPACE" --ignore-not-found=true --wait=false 2>/dev/null || true +oc delete svc llama-stack-service-svc -n "$NAMESPACE" --ignore-not-found=true 2>/dev/null || true oc delete pvc llama-stack-app-root -n "$NAMESPACE" --ignore-not-found=true 2>/dev/null || true -cat <<'EOF' | oc apply -n "$NAMESPACE" -f - -apiVersion: v1 -kind: PersistentVolumeClaim -metadata: - name: llama-stack-app-root -spec: - accessModes: - - ReadWriteOnce - resources: - requests: - storage: 10Gi -EOF -log "✅ llama-stack-app-root PVC created" - -# Configurable config paths: default to OpenAI, override for RHEL AI / vLLM. + +# Configurable paths: OpenAI defaults; Tekton overrides for RHEL AI / vLLM. LLAMA_STACK_CONFIG="${LLAMA_STACK_CONFIG:-$REPO_ROOT/tests/e2e/configs/run-ci.yaml}" -LCS_CONFIG="${LCS_CONFIG:-$REPO_ROOT/tests/e2e/configuration/server-mode/lightspeed-stack.yaml}" -log "OGX config: $LLAMA_STACK_CONFIG" +LCS_CONFIG="${LCS_CONFIG:-$REPO_ROOT/tests/e2e/configuration/library-mode/lightspeed-stack.yaml}" +log "OGX synthesis profile (run.yaml): $LLAMA_STACK_CONFIG" log "LCS config: $LCS_CONFIG" oc create configmap llama-stack-config -n "$NAMESPACE" \ --from-file=run.yaml="$LLAMA_STACK_CONFIG" \ @@ -300,17 +287,6 @@ else fi -# ConfigMap for OGX run-from-source (init container clones this repo @ this revision) -REPO_URL="${REPO_URL:-$(cd "$REPO_ROOT" && git config --get remote.origin.url 2>/dev/null)}" -REPO_REVISION="${REPO_REVISION:-$(cd "$REPO_ROOT" && git rev-parse HEAD 2>/dev/null)}" -[[ -z "$REPO_URL" ]] && REPO_URL='https://github.com/lightspeed-core/lightspeed-stack.git' -[[ -z "$REPO_REVISION" ]] && REPO_REVISION='main' -oc create configmap llama-stack-source -n "$NAMESPACE" \ - --from-literal=repo_url="$REPO_URL" \ - --from-literal=repo_revision="$REPO_REVISION" \ - --dry-run=client -o yaml | oc apply -f - -log "llama-stack-source ConfigMap: repo @ ${REPO_REVISION}" - "$PIPELINE_DIR/pipeline-services-konflux.sh" # Print pod logs with echo so CI/Konflux log capture shows each line (especially when QUIET=1) @@ -320,30 +296,24 @@ e2e_echo_pod_logs() { while IFS= read -r line || [[ -n "$line" ]]; do echo "[e2e] $line" done < <(oc logs lightspeed-stack-service -n "$NAMESPACE" --tail="$n" 2>&1) || true - echo "[e2e] ========== llama-stack-service logs (tail $n) ==========" - while IFS= read -r line || [[ -n "$line" ]]; do - echo "[e2e] $line" - done < <(oc logs llama-stack-service -n "$NAMESPACE" --tail="$n" 2>&1) || true } -progress "Waiting for lightspeed-stack and llama-stack pods (up to 10 min)" +progress "Waiting for lightspeed-stack-service (up to 10 min)" for i in $(seq 1 60); do lcs_ready=$(oc get pod lightspeed-stack-service -n "$NAMESPACE" -o jsonpath='{.status.conditions[?(@.type=="Ready")].status}' 2>/dev/null || echo "False") - llama_ready=$(oc get pod llama-stack-service -n "$NAMESPACE" -o jsonpath='{.status.conditions[?(@.type=="Ready")].status}' 2>/dev/null || echo "False") - if [[ "$lcs_ready" == "True" ]] && [[ "$llama_ready" == "True" ]]; then - log "✅ Both service pods are ready after $(( i * 10 ))s" + if [[ "$lcs_ready" == "True" ]]; then + log "✅ lightspeed-stack-service ready after $(( i * 10 ))s" break fi if [ $((i % 6)) -eq 0 ]; then lcs_status=$(oc get pod lightspeed-stack-service -n "$NAMESPACE" -o jsonpath='{.status.phase}' 2>/dev/null || echo "unknown") - llama_status=$(oc get pod llama-stack-service -n "$NAMESPACE" -o jsonpath='{.status.phase}' 2>/dev/null || echo "unknown") - progress "[$(( i * 10 ))s] lightspeed-stack: $lcs_status ($lcs_ready), llama-stack: $llama_status ($llama_ready)" + progress "[$(( i * 10 ))s] lightspeed-stack: $lcs_status ($lcs_ready)" fi if [ $i -eq 60 ]; then - progress "❌ One or both service pods failed to become ready within 600s timeout" + progress "❌ lightspeed-stack-service failed to become ready within 600s timeout" e2e_echo_pod_logs 200 exit 1 fi @@ -357,8 +327,6 @@ else e2e_echo_pod_logs 200 echo "[e2e] ========== oc describe lightspeed-stack-service ==========" oc describe pod lightspeed-stack-service -n "$NAMESPACE" 2>&1 | while IFS= read -r line || [[ -n "$line" ]]; do echo "[e2e] $line"; done || true - echo "[e2e] ========== oc describe llama-stack-service ==========" - oc describe pod llama-stack-service -n "$NAMESPACE" 2>&1 | while IFS= read -r line || [[ -n "$line" ]]; do echo "[e2e] $line"; done || true fi @@ -368,9 +336,7 @@ fi # So behave/e2e-ops can kill this listener before rebinding 8080 (restart-lightspeed hooks). # Debug hook/port churn: export E2E_OPS_VERBOSE=1 before running pipeline.sh export E2E_LSC_PORT_FORWARD_PID_FILE="${E2E_LSC_PORT_FORWARD_PID_FILE:-/tmp/e2e-lightspeed-port-forward.pid}" -export E2E_OGX_PORT_FORWARD_PID_FILE="${E2E_OGX_PORT_FORWARD_PID_FILE:-/tmp/e2e-ogx-port-forward.pid}" rm -f "$E2E_LSC_PORT_FORWARD_PID_FILE" -rm -f "$E2E_OGX_PORT_FORWARD_PID_FILE" oc label pod lightspeed-stack-service pod=lightspeed-stack-service -n $NAMESPACE @@ -391,7 +357,7 @@ kill_listeners_on_ports() { fi done } -kill_listeners_on_ports 8080 8000 8321 +kill_listeners_on_ports 8080 8000 # Start port-forward for lightspeed-stack progress "Starting port-forward, then E2E tests" @@ -404,13 +370,6 @@ log "Starting port-forward for mock-jwks..." oc port-forward svc/mock-jwks 8000:8000 -n $NAMESPACE & PF_JWKS_PID=$! -# Behave runs in this shell; pipeline-services-konflux.sh cannot export here. MCP hooks call -# OGX directly — mirror LCS and forward llama-stack-service-svc to localhost:8321. -log "Starting port-forward for llama-stack (MCP / ogx_client hooks)..." -oc port-forward svc/llama-stack-service-svc 8321:8321 -n $NAMESPACE & -PF_OGX_PID=$! -echo "$PF_OGX_PID" >"$E2E_OGX_PORT_FORWARD_PID_FILE" - # Wait for port-forward to be usable (app may not be listening immediately; port-forward can drop) log "Waiting for port-forward to lightspeed-stack to be ready..." for i in $(seq 1 36); do @@ -430,7 +389,6 @@ for i in $(seq 1 36); do done < <(oc get events -n "$NAMESPACE" --sort-by='.lastTimestamp' 2>&1 | tail -40) || true kill $PF_LCS_PID 2>/dev/null || true kill $PF_JWKS_PID 2>/dev/null || true - kill $PF_OGX_PID 2>/dev/null || true exit 1 fi # If port-forward process died, restart it (e.g. "connection refused" / "lost connection to pod") @@ -443,35 +401,8 @@ for i in $(seq 1 36); do sleep 5 done -log "Waiting for OGX port-forward (localhost:8321 /v1/health)..." -for i in $(seq 1 36); do - if curl -sf http://localhost:8321/v1/health > /dev/null 2>&1; then - log "✅ OGX port-forward ready after $(( i * 5 ))s" - break - fi - if [ $i -eq 36 ]; then - echo "❌ Port-forward to llama-stack never became healthy (3 min)" | tee /dev/stderr - trap - ERR - set +e - e2e_echo_pod_logs 250 - kill $PF_LCS_PID 2>/dev/null || true - kill $PF_JWKS_PID 2>/dev/null || true - kill $PF_OGX_PID 2>/dev/null || true - exit 1 - fi - if ! kill -0 $PF_OGX_PID 2>/dev/null; then - log "Llama port-forward died, restarting (attempt $i)..." - oc port-forward svc/llama-stack-service-svc 8321:8321 -n $NAMESPACE & - PF_OGX_PID=$! - echo "$PF_OGX_PID" >"$E2E_OGX_PORT_FORWARD_PID_FILE" - fi - sleep 5 -done - export E2E_LSC_HOSTNAME="localhost" export E2E_JWKS_HOSTNAME="localhost" -export E2E_OGX_HOSTNAME="localhost" -export E2E_OGX_PORT="8321" # Same pattern as tests/e2e-prow/rhoai/pipeline.sh and .github/workflows/e2e_tests_*.yaml: # Behave {MODEL}/{PROVIDER} use these when set; avoids wrong fallbacks if /v1/models # discovery in before_all is empty (matches run-ci.yaml openai + E2E_OPENAI_MODEL). @@ -485,7 +416,6 @@ fi export E2E_DEFAULT_PROVIDER_OVERRIDE E2E_DEFAULT_MODEL_OVERRIDE log "LCS accessible at: http://$E2E_LSC_HOSTNAME:8080" log "Mock JWKS accessible at: http://$E2E_JWKS_HOSTNAME:8000" -log "OGX (e2e client hooks) at: http://$E2E_OGX_HOSTNAME:$E2E_OGX_PORT" #======================================== # 7. RUN TESTS @@ -513,20 +443,10 @@ if [[ -n "${E2E_LSC_PORT_FORWARD_PID_FILE:-}" && -f "$E2E_LSC_PORT_FORWARD_PID_F fi rm -f "$E2E_LSC_PORT_FORWARD_PID_FILE" fi -if [[ -n "${E2E_OGX_PORT_FORWARD_PID_FILE:-}" && -f "$E2E_OGX_PORT_FORWARD_PID_FILE" ]]; then - read -r _ll_pf <"$E2E_OGX_PORT_FORWARD_PID_FILE" 2>/dev/null || true - if [[ "${_ll_pf:-}" =~ ^[0-9]+$ ]]; then - kill -9 "$_ll_pf" 2>/dev/null || true - fi - rm -f "$E2E_OGX_PORT_FORWARD_PID_FILE" -fi - kill $PF_LCS_PID 2>/dev/null || true kill $PF_JWKS_PID 2>/dev/null || true -kill $PF_OGX_PID 2>/dev/null || true wait $PF_LCS_PID 2>/dev/null || true wait $PF_JWKS_PID 2>/dev/null || true -wait $PF_OGX_PID 2>/dev/null || true set -e trap 'echo "❌ Pipeline failed at line $LINENO"; exit 1' ERR diff --git a/tests/e2e-prow/rhoai/pipeline-services-konflux.sh b/tests/e2e-prow/rhoai/pipeline-services-konflux.sh index d907c1fce1..9ca47c9f24 100755 --- a/tests/e2e-prow/rhoai/pipeline-services-konflux.sh +++ b/tests/e2e-prow/rhoai/pipeline-services-konflux.sh @@ -1,5 +1,5 @@ #!/bin/bash -# Deploy Llama (OpenAI run-from-source) + Lightspeed for Konflux E2E only. Prow uses pipeline-services.sh. +# Deploy Lightspeed Stack (library mode) for Konflux E2E only. Classic Prow uses pipeline-services.sh. BASE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" REPO_ROOT="$(cd "$BASE_DIR/../../.." && pwd)" @@ -18,44 +18,19 @@ if [ -f "$REPO_ROOT/tests/e2e/secrets/invalid-mcp-token" ]; then --dry-run=client -o yaml | oc apply -f - fi -# 1. OGX (run from source). Cluster DNS name matches oc expose --name=llama-stack-service-svc. -# Secret must exist before the pod: both LCS and OGX-container use E2E_OGX_HOSTNAME from it. -_LLAMA_SVC_FQDN="llama-stack-service-svc.${NAMESPACE}.svc.cluster.local" -oc create secret generic llama-stack-ip-secret \ - --from-literal=key="$_LLAMA_SVC_FQDN" \ - -n "$NAMESPACE" \ - --dry-run=client -o yaml | oc apply -f - - -# PVC must exist before the pod (pipeline-konflux.sh creates it; guard here for standalone use). -oc get pvc llama-stack-app-root -n "$NAMESPACE" >/dev/null 2>&1 || \ - oc apply -n "$NAMESPACE" -f - <<'PVCEOF' -apiVersion: v1 -kind: PersistentVolumeClaim -metadata: - name: llama-stack-app-root -spec: - accessModes: - - ReadWriteOnce - resources: - requests: - storage: 10Gi -PVCEOF - -timeout 120 oc delete pod llama-stack-service -n "$NAMESPACE" --ignore-not-found=true --wait=true 2>/dev/null || true -oc apply -n "$NAMESPACE" -f "$BASE_DIR/manifests/lightspeed/ogx-openai.yaml" -# First boot runs the full init (dnf + git clone + uv sync ≈ 6-15 min); use a generous timeout. -oc wait pod/llama-stack-service -n "$NAMESPACE" --for=condition=Ready --timeout=900s -oc label pod llama-stack-service pod=llama-stack-service -n "$NAMESPACE" -oc expose pod llama-stack-service --name=llama-stack-service-svc --port=8321 --type=ClusterIP -n "$NAMESPACE" - -# 2. Lightspeed Stack (image from env; default if unset) LIGHTSPEED_STACK_IMAGE="${LIGHTSPEED_STACK_IMAGE:-quay.io/lightspeed-core/lightspeed-stack:dev-latest}" export LIGHTSPEED_STACK_IMAGE LIGHTSPEED_MANIFEST="$BASE_DIR/manifests/lightspeed/lightspeed-stack.yaml" + +timeout 120 oc delete pod lightspeed-stack-service -n "$NAMESPACE" --ignore-not-found=true --wait=true 2>/dev/null || \ + oc delete pod lightspeed-stack-service -n "$NAMESPACE" --ignore-not-found=true --force --grace-period=0 2>/dev/null || true + if command -v envsubst >/dev/null 2>&1; then envsubst '${LIGHTSPEED_STACK_IMAGE}' < "$LIGHTSPEED_MANIFEST" | oc apply -n "$NAMESPACE" -f - else - # ubi-minimal etc. may lack gettext; template only expands LIGHTSPEED_STACK_IMAGE sed "s|\${LIGHTSPEED_STACK_IMAGE}|${LIGHTSPEED_STACK_IMAGE}|g" "$LIGHTSPEED_MANIFEST" | oc apply -n "$NAMESPACE" -f - fi + +oc wait pod/lightspeed-stack-service -n "$NAMESPACE" --for=condition=Ready --timeout=900s +oc label pod lightspeed-stack-service pod=lightspeed-stack-service -n "$NAMESPACE" --overwrite \ No newline at end of file diff --git a/tests/e2e-prow/rhoai/pipeline.sh b/tests/e2e-prow/rhoai/pipeline.sh index af0ebf592d..5494150f65 100755 --- a/tests/e2e-prow/rhoai/pipeline.sh +++ b/tests/e2e-prow/rhoai/pipeline.sh @@ -13,7 +13,7 @@ export NAMESPACE MODEL_NAME="meta-llama/Llama-3.1-8B-Instruct" PIPELINE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" -# RHOAI OGX image (unused when building from source via ogx-openai.yaml) +# RHOAI OGX image (classic server mode: built llama-stack-e2e image + ogx-prow.yaml) # LLAMA_STACK_IMAGE="${LLAMA_STACK_IMAGE:-quay.io/rhoai/odh-llama-stack-core-rhel9:rhoai-3.4-ea.2}" # echo "Using OGX image: $LLAMA_STACK_IMAGE" # export LLAMA_STACK_IMAGE diff --git a/tests/e2e-prow/rhoai/run-tests.sh b/tests/e2e-prow/rhoai/run-tests.sh index 6ce53a0510..a29362fe6d 100755 --- a/tests/e2e-prow/rhoai/run-tests.sh +++ b/tests/e2e-prow/rhoai/run-tests.sh @@ -7,6 +7,12 @@ cd "$(dirname "$0")/../../.." # Timestamps to pinpoint where time is spent (e.g. if Prow 2h timeout is hit) ts() { echo "[$(date -u +%Y-%m-%dT%H:%M:%SZ)] $*"; } +# Konflux library mode: behave + ConfigMap updates use library-mode YAMLs. +if [[ "${E2E_KONFLUX_E2E:-0}" == "1" ]]; then + export E2E_DEPLOYMENT_MODE="${E2E_DEPLOYMENT_MODE:-library}" + export E2E_LIGHTSPEED_CONFIG_DIR="${E2E_LIGHTSPEED_CONFIG_DIR:-tests/e2e/configuration/library-mode}" +fi + # FAISS_VECTOR_STORE_ID should be exported by pipeline.sh or pipeline-konflux.sh if [ -z "$FAISS_VECTOR_STORE_ID" ]; then echo "❌ FAISS_VECTOR_STORE_ID is not set - should be exported by the OpenShift E2E pipeline" @@ -16,6 +22,7 @@ fi ts "Start run-tests.sh" echo "Running tests from: $(pwd)" echo "E2E_LSC_HOSTNAME: $E2E_LSC_HOSTNAME" +echo "E2E_DEPLOYMENT_MODE: ${E2E_DEPLOYMENT_MODE:-server}" echo "FAISS_VECTOR_STORE_ID: $FAISS_VECTOR_STORE_ID" # Wait for service to be ready (retry up to 60 seconds) diff --git a/tests/e2e-prow/rhoai/scripts/e2e-ops.sh b/tests/e2e-prow/rhoai/scripts/e2e-ops.sh index ba5f75237e..df382b060e 100755 --- a/tests/e2e-prow/rhoai/scripts/e2e-ops.sh +++ b/tests/e2e-prow/rhoai/scripts/e2e-ops.sh @@ -3,54 +3,40 @@ # Usage: e2e-ops.sh [args...] # # Architecture note (why logs look "fine" but CI flakes): -# - pipeline.sh starts oc port-forward to localhost:8080 for the whole test run. -# - Behave before_feature calls restart-lightspeed, which must kill that forward and start a new one. -# - In-cluster pod logs (Uvicorn up, Llama OK) do not reflect localhost bind races; "address already in use" -# is the CI runner, not the application. +# - pipeline-konflux.sh keeps oc port-forward to localhost:8080 for the test run. +# - Behave hooks call restart-lightspeed, which must kill that forward and rebind. # - E2E_LSC_PORT_FORWARD_PID_FILE coordinates the handoff. -# - pipeline-konflux.sh (and hooks) forward llama-stack-service-svc to localhost:8321 for -# Behave steps that call OGX directly (MCP toolgroups, shields). When the llama -# pod is recreated, that forward must be restarted or you get "PodSandbox ... not found" / -# APIConnectionError on subsequent scenarios. -# - E2E_OGX_PORT_FORWARD_PID_FILE coordinates killing/restarting the 8321 forward. -# - restart-lightspeed ensures Llama is running before LCS recreate when needed. -# - restart-both-services is available explicitly; restart-lightspeed / restart-ogx -# do not auto-trigger a full stack restart on failure. -# - OKP Solr is not deployed in pipeline setup. Features tagged @cfg_okp call -# deploy-okp-solr from before_feature (7GB image, first pull ~10-15 min). -# Background "OKP is running" GETs Solr from inside the OGX pod (in-cluster -# Service). Behave does not port-forward Solr to the runner. +# - Single pod: lightspeed-stack-service (OGX in-process). No separate OGX pod or :8321 forward. +# - OKP Solr: deploy-okp-solr from @cfg_okp features; reachability checked from the LCS pod. +# - Proxy/TLS sidecars (tunnel proxy, mock TLS) are Docker Compose only (@skip-in-prow). # # Commands: -# restart-lightspeed - Restart lightspeed-stack pod and port-forward -# restart-ogx - Restart/restore OGX pod and localhost:8321 forward -# restart-both-services - Full OGX then lightspeed-stack restart (explicit only) -# restart-port-forward - Re-establish port-forward for lightspeed -# restart-ogx-port-forward - Re-establish port-forward for OGX (8321) -# wait-for-pod [attempts] - Wait for a pod to be ready -# update-configmap - Update ConfigMap from file -# get-configmap-content - Get ConfigMap content (outputs to stdout) -# disrupt-ogx - Delete OGX pod to disrupt connection -# deploy-e2e-tunnel-proxy - Deploy in-cluster tunnel proxy (proxy.feature step) -# deploy-e2e-interception-proxy - Deploy in-cluster interception proxy (proxy.feature step) -# deploy-e2e-mock-tls-inference - Deploy mock HTTPS inference server (tls-*.feature) -# delete-e2e-mock-tls-inference - Remove mock TLS pod + Service (manual cleanup) -# restart-e2e-mock-tls-inference - Delete then deploy mock TLS (manual / recovery) -# sync-mock-tls-certs-secret - Copy mock /certs into Secret for OGX mount -# check-okp-solr-from-llama - GET Solr portal-rag select from inside the OGX pod -# deploy-okp-solr - Deploy OKP Solr (idempotent; @cfg_okp before_feature) -# delete-okp-solr - Delete OKP Solr pod -# disrupt-okp-solr - Delete OKP Solr pod to disrupt connection -# restore-okp-solr - Restore OKP Solr pod +# restart-lightspeed - Restart lightspeed-stack pod and port-forward +# restart-jwks-port-forward - Re-establish JWKS port-forward for LCS auth tests +# restart-port-forward - Re-establish port-forward for lightspeed +# wait-for-pod [attempts] - Wait for a pod to be ready +# update-configmap - Update ConfigMap from file +# get-configmap-content - Get ConfigMap content (outputs to stdout) +# dump-pod-logs [tail-lines] - Print init + container logs +# check-okp-solr-from-llama - GET Solr from inside lightspeed-stack-service (legacy name) +# deploy-okp-solr - Deploy OKP Solr (idempotent; @cfg_okp before_feature) +# delete-okp-solr - Delete OKP Solr pod +# disrupt-okp-solr - Delete OKP Solr pod to disrupt connection +# restore-okp-solr - Restore OKP Solr pod set -e NAMESPACE="${NAMESPACE:-e2e-rhoai-dsc}" SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" MANIFEST_DIR="$SCRIPT_DIR/../manifests/lightspeed" -# Written by pipeline.sh when it starts LCS port-forward; e2e-ops kills this PID before rebinding 8080. + +# Konflux always runs library mode (single lightspeed-stack pod). +if [[ "${E2E_KONFLUX_E2E:-0}" == "1" ]]; then + export E2E_DEPLOYMENT_MODE=library +fi + +# Written by pipeline-konflux.sh when it starts LCS port-forward; e2e-ops kills this PID before rebinding 8080. E2E_LSC_PORT_FORWARD_PID_FILE="${E2E_LSC_PORT_FORWARD_PID_FILE:-/tmp/e2e-lightspeed-port-forward.pid}" -E2E_OGX_PORT_FORWARD_PID_FILE="${E2E_OGX_PORT_FORWARD_PID_FILE:-/tmp/e2e-ogx-port-forward.pid}" E2E_JWKS_PORT_FORWARD_PID_FILE="${E2E_JWKS_PORT_FORWARD_PID_FILE:-/tmp/e2e-jwks-port-forward.pid}" # ============================================================================ @@ -182,24 +168,6 @@ kill_stale_lightspeed_forward() { free_local_tcp_port "$port" } -# Kill anything likely to hold the OGX local forward (localhost:8321). -kill_stale_llama_forward() { - local port="${1:-8321}" - local saved_pf - if [[ -f "$E2E_OGX_PORT_FORWARD_PID_FILE" ]]; then - read -r saved_pf <"$E2E_OGX_PORT_FORWARD_PID_FILE" 2>/dev/null || true - if [[ "$saved_pf" =~ ^[0-9]+$ ]]; then - kill -9 "$saved_pf" 2>/dev/null || true - fi - fi - pkill -9 -f "port-forward.*llama-stack-service-svc.*${port}:${port}" 2>/dev/null || true - pkill -9 -f "oc port-forward svc/llama-stack-service-svc ${port}:${port}" 2>/dev/null || true - pkill -9 -f "port-forward pod/llama-stack-service.*${port}:${port}" 2>/dev/null || true - free_local_tcp_port "$port" - sleep 1 - free_local_tcp_port "$port" -} - # Kill anything likely to hold the mock-jwks local forward (localhost:8000). kill_stale_jwks_forward() { local port="${1:-8000}" @@ -234,9 +202,6 @@ e2e_ops_diagnose_forward_failure() { tail -30 /tmp/port-forward.log 2>/dev/null | sed 's/^/[e2e-ops] /' || true fi e2e_ops_dump_pod_logs "lightspeed-stack-service" 10000 - if [[ "${E2E_COPY_MOCK_TLS_CERTS_TO_OGX:-0}" == "1" ]]; then - e2e_ops_dump_pod_logs "llama-stack-service" 10000 - fi } verify_connectivity() { @@ -290,138 +255,39 @@ verify_connectivity() { return 1 } -# Single check: Llama serves /v1/health on loopback inside the main container. -_llama_stack_http_health_once() { - local pod="llama-stack-service" - local ctr="llama-stack-container" - if oc exec -n "$NAMESPACE" "$pod" -c "$ctr" -- \ - curl -sf --max-time 10 "http://127.0.0.1:8321/v1/health" >/dev/null 2>&1; then +# ============================================================================ +# Command implementations +# ============================================================================ + +# RHEL AI matrix: after LCS restart, wait until /v1/models lists the configured vLLM model. +_wait_for_vllm_model_in_lcs_registry() { + if ! oc get secret vllm-url-secret -n "$NAMESPACE" &>/dev/null; then return 0 fi - if oc exec -n "$NAMESPACE" "$pod" -c "$ctr" -- \ - /opt/app-root/.venv/bin/python -c \ - "import urllib.request; urllib.request.urlopen('http://127.0.0.1:8321/v1/health', timeout=10).read()" \ - >/dev/null 2>&1; then + local model_id + model_id="$(oc get secret vllm-model-secret -n "$NAMESPACE" -o jsonpath='{.data.key}' 2>/dev/null | base64 -d 2>/dev/null || true)" + if [[ -z "$model_id" ]]; then return 0 fi - return 1 -} - -# After the pod is Ready, confirm the process is actually serving HTTP (not only kubelet probes). -wait_for_llama_stack_http_health() { - local max_attempts="${1:-35}" + local needle="vllm/${model_id}" + local local_port="${LOCAL_PORT:-8080}" + echo "[e2e-ops] Waiting for ${needle} in LCS GET /v1/models..." local attempt - - echo "Verifying OGX is fully up (GET /v1/health inside pod)..." - for ((attempt=1; attempt<=max_attempts; attempt++)); do - if _llama_stack_http_health_once; then - echo "✓ OGX /v1/health OK (attempt $attempt/$max_attempts)" + for ((attempt=1; attempt<=60; attempt++)); do + if curl -sf --max-time 15 "http://127.0.0.1:${local_port}/v1/models" 2>/dev/null | grep -Fq "$needle"; then + echo "[e2e-ops] LCS registry lists ${needle} (attempt ${attempt})" return 0 fi - if [[ $attempt -lt $max_attempts ]]; then - sleep 2 - fi + sleep 5 done - echo "ERROR: OGX did not respond on http://127.0.0.1:8321/v1/health inside the pod" - e2e_ops_dump_pod_logs "llama-stack-service" 200 + echo "[e2e-ops] ERROR: ${needle} not registered in LCS after restart (5m)" return 1 } -# ============================================================================ -# Command implementations -# ============================================================================ - -# Llama pod recreate + in-pod health + :8321 port-forward. -_restart_llama_stack_core() { - echo "===== Restoring llama-stack service =====" - echo "Deleting llama-stack pod (if any) before apply..." - timeout 45 oc delete pod llama-stack-service -n "$NAMESPACE" --ignore-not-found=true --wait=true 2>/dev/null || { - oc delete pod llama-stack-service -n "$NAMESPACE" --ignore-not-found=true --force --grace-period=0 2>/dev/null || true - sleep 3 - } - - echo "Applying pod manifest..." - if [[ "${E2E_KONFLUX_E2E:-0}" == "1" ]]; then - if [[ "${E2E_COPY_INTERCEPTION_CA_TO_OGX:-0}" == "1" ]]; then - echo "[e2e-ops] Syncing e2e-interception-proxy-ca secret before llama-stack apply..." - if ! cmd_sync_interception_proxy_ca_secret; then - echo "===== Llama-stack restore FAILED (interception CA secret sync) =====" - return 1 - fi - fi - if [[ "${E2E_COPY_MOCK_TLS_CERTS_TO_OGX:-0}" == "1" ]] \ - && [[ "${E2E_SYNC_MOCK_TLS_CERTS:-0}" == "1" ]]; then - echo "[e2e-ops] Syncing e2e-mock-tls-certs secret before llama-stack apply..." - if ! cmd_sync_mock_tls_certs_secret; then - echo "===== Llama-stack restore FAILED (mock TLS cert secret sync) =====" - return 1 - fi - fi - _LLAMA_SVC_FQDN="llama-stack-service-svc.${NAMESPACE}.svc.cluster.local" - oc create secret generic llama-stack-ip-secret \ - --from-literal=key="$_LLAMA_SVC_FQDN" \ - -n "$NAMESPACE" \ - --dry-run=client -o yaml | oc apply -f - - oc apply -n "$NAMESPACE" -f "$MANIFEST_DIR/ogx-openai.yaml" - # Konflux: setup-from-source init (dnf, git, uv) often needs 6–15 min before the main container is Ready. - local llama_wait_attempts=90 - if [[ "${E2E_KONFLUX_E2E:-0}" == "1" ]]; then - llama_wait_attempts=360 - fi - if ! wait_for_pod "llama-stack-service" "$llama_wait_attempts"; then - echo "===== Llama-stack restore FAILED (pod not ready) =====" - return 1 - fi - echo "Labeling pod for service..." - oc label pod llama-stack-service pod=llama-stack-service -n "$NAMESPACE" --overwrite - if [[ "${E2E_COPY_INTERCEPTION_CA_TO_OGX:-0}" == "1" ]]; then - if ! _verify_interception_ca_mounted_in_llama; then - echo "===== Llama-stack restore FAILED (interception CA not mounted) =====" - return 1 - fi - fi - if ! wait_for_llama_stack_http_health 50; then - echo "===== Llama-stack restore FAILED (HTTP not healthy) =====" - return 1 - fi - else - sed "s|\${LLAMA_STACK_IMAGE}|${LLAMA_STACK_IMAGE:-}|g" "$MANIFEST_DIR/ogx-prow.yaml" | - oc apply -n "$NAMESPACE" -f - - if ! wait_for_pod "llama-stack-service" 24; then - echo "===== Llama-stack restore FAILED (pod not ready) =====" - return 1 - fi - echo "Labeling pod for service..." - oc label pod llama-stack-service pod=llama-stack-service -n "$NAMESPACE" --overwrite - fi - - if ! cmd_restart_llama_port_forward; then - echo "ERROR: Llama pod is up but localhost:${LOCAL_OGX_PORT:-8321} port-forward failed" - e2e_ops_dump_pod_logs "llama-stack-service" 200 - return 1 - fi - - if ! _wait_for_vllm_model_in_ogx_registry; then - e2e_ops_dump_pod_logs "llama-stack-service" 200 - return 1 - fi - - echo "===== Llama-stack restore complete =====" - return 0 -} - -# LCS pod recreate + :8080 port-forward (no cross-service recovery). +# LCS pod recreate + :8080 port-forward. _restart_lightspeed_core() { echo "Restarting lightspeed-stack service..." - if ! _llama_stack_http_health_once 2>/dev/null; then - echo "⚠️ OGX not healthy — restoring before LCS restart..." - if ! _restart_llama_stack_core; then - echo "===== Lightspeed restore FAILED (Llama not healthy) =====" - return 1 - fi - fi - timeout 20 oc delete pod lightspeed-stack-service -n "$NAMESPACE" --ignore-not-found=true --wait=true 2>/dev/null || { oc delete pod lightspeed-stack-service -n "$NAMESPACE" --ignore-not-found=true --force --grace-period=0 2>/dev/null || true sleep 2 @@ -447,6 +313,10 @@ _restart_lightspeed_core() { fi cmd_restart_jwks_port_forward || echo "⚠️ Mock JWKS port-forward failed (RBAC tests may fail)" + if ! _wait_for_vllm_model_in_lcs_registry; then + return 1 + fi + if [[ "$pod_ready" == "false" ]]; then echo "⚠️ Lightspeed restart completed but pod was slow to become ready" return 1 @@ -455,27 +325,6 @@ _restart_lightspeed_core() { return 0 } -# Full stack reset: Llama first (LCS depends on it), then LCS + port-forwards. -cmd_restart_both_services() { - echo "===== Full restart: llama-stack then lightspeed-stack =====" - local rc=0 - if ! _restart_llama_stack_core; then - rc=1 - elif ! _restart_lightspeed_core; then - rc=1 - fi - if [[ $rc -eq 0 ]]; then - echo "===== Full both-services restart complete =====" - else - echo "===== Full both-services restart FAILED =====" - fi - return $rc -} - -cmd_restart_llama_stack() { - _restart_llama_stack_core -} - cmd_restart_lightspeed() { _restart_lightspeed_core } @@ -545,111 +394,6 @@ cmd_restart_port_forward() { return 1 } -verify_llama_local_forward() { - local max_attempts="${1:-15}" - local http_code="" - local attempt - - for ((attempt=1; attempt<=max_attempts; attempt++)); do - http_code=$(curl -s -o /dev/null -w '%{http_code}' --max-time 5 "http://127.0.0.1:8321/v1/health" 2>/dev/null) || http_code="000" - if [[ "$http_code" == "200" ]]; then - return 0 - fi - if [[ $attempt -lt $max_attempts ]]; then - sleep 2 - fi - done - echo "OGX localhost:8321 connectivity check failed (HTTP: ${http_code:-unknown})" - return 1 -} - -# RHEL AI: OGX /v1/health can be 200 while vLLM registration is still pending (or failed once). -_wait_for_vllm_model_in_ogx_registry() { - if ! oc get secret vllm-url-secret -n "$NAMESPACE" &>/dev/null; then - return 0 - fi - local model_id - model_id="$(oc get secret vllm-model-secret -n "$NAMESPACE" -o jsonpath='{.data.key}' 2>/dev/null | base64 -d 2>/dev/null || true)" - if [[ -z "$model_id" ]]; then - return 0 - fi - local needle="vllm/${model_id}" - local local_port="${LOCAL_OGX_PORT:-8321}" - echo "[e2e-ops] Waiting for ${needle} in OGX GET /v1/models..." - local attempt - for ((attempt=1; attempt<=60; attempt++)); do - if curl -sf --max-time 15 "http://127.0.0.1:${local_port}/v1/models" 2>/dev/null | grep -Fq "$needle"; then - echo "[e2e-ops] OGX registry lists ${needle} (attempt ${attempt})" - return 0 - fi - sleep 5 - done - echo "[e2e-ops] ERROR: ${needle} not registered in OGX after llama restart (5m)" - return 1 -} - -cmd_restart_llama_port_forward() { - local local_port="${LOCAL_OGX_PORT:-8321}" - local remote_port="${REMOTE_OGX_PORT:-8321}" - local max_attempts=6 - local pf_pid - local pf_resource - local llama_pf_log="/tmp/port-forward-llama.log" - - echo "Re-establishing OGX port-forward on $local_port:$remote_port..." - - for ((attempt=1; attempt<=max_attempts; attempt++)); do - kill_stale_llama_forward "$local_port" - sleep 3 - - if [[ $attempt -le 2 ]]; then - pf_resource="svc/llama-stack-service-svc" - else - pf_resource="pod/llama-stack-service" - fi - echo "Llama port-forward attempt $attempt/$max_attempts -> $pf_resource" - - : >"$llama_pf_log" - nohup oc port-forward "$pf_resource" "$local_port:$remote_port" -n "$NAMESPACE" \ - "$llama_pf_log" 2>&1 & - pf_pid=$! - disown "$pf_pid" 2>/dev/null || true - sleep 3 - - if ! kill -0 "$pf_pid" 2>/dev/null; then - echo "Llama port-forward process exited immediately:" - if [[ -s "$llama_pf_log" ]]; then - tail -25 "$llama_pf_log" 2>/dev/null | sed 's/^/[e2e-ops] /' || true - fi - kill_stale_llama_forward "$local_port" - sleep 2 - continue - fi - sleep 4 - - if verify_llama_local_forward 12; then - echo "$pf_pid" >"$E2E_OGX_PORT_FORWARD_PID_FILE" - echo "[e2e-ops] Llama through port-forward: GET http://127.0.0.1:$local_port/v1/health -> OK" - echo "✓ OGX port-forward established (PID: $pf_pid, $pf_resource)" - return 0 - fi - - if [[ $attempt -lt $max_attempts ]]; then - echo "Llama forward attempt $attempt failed, retrying..." - kill -9 "$pf_pid" 2>/dev/null || true - sleep 2 - fi - done - - echo "Failed to establish OGX port-forward on :$local_port" - if [[ -s "$llama_pf_log" ]]; then - echo "[e2e-ops] $llama_pf_log (tail 30):" - tail -30 "$llama_pf_log" 2>/dev/null | sed 's/^/[e2e-ops] /' || true - fi - e2e_ops_dump_pod_logs "llama-stack-service" 200 - return 1 -} - cmd_restart_jwks_port_forward() { local local_port="${LOCAL_JWKS_PORT:-8000}" local remote_port="${REMOTE_JWKS_PORT:-8000}" @@ -748,301 +492,30 @@ cmd_get_configmap_content() { -o "go-template={{index .data \"$configmap_key\"}}" } -cmd_tunnel_proxy_stats() { - local pod_name - pod_name=$(oc get pod -n "$NAMESPACE" -l app=e2e-tunnel-proxy \ - -o jsonpath='{.items[0].metadata.name}' 2>/dev/null) || pod_name="" - - if [[ -z "$pod_name" ]]; then - echo "ERROR: no e2e-tunnel-proxy pod in namespace $NAMESPACE" >&2 - return 1 - fi - - oc exec -n "$NAMESPACE" "$pod_name" -- \ - python3 -c "import urllib.request; print(urllib.request.urlopen('http://127.0.0.1:8887/stats', timeout=5).read().decode())" -} - -cmd_interception_proxy_stats() { - local pod_name - pod_name=$(oc get pod -n "$NAMESPACE" -l app=e2e-interception-proxy \ - -o jsonpath='{.items[0].metadata.name}' 2>/dev/null) || pod_name="" - - if [[ -z "$pod_name" ]]; then - echo "ERROR: no e2e-interception-proxy pod in namespace $NAMESPACE" >&2 - return 1 - fi - - oc exec -n "$NAMESPACE" "$pod_name" -- \ - python3 -c "import urllib.request; print(urllib.request.urlopen('http://127.0.0.1:8886/stats', timeout=5).read().decode())" -} - -cmd_sync_interception_proxy_ca_secret() { - local proxy_pod_name tmp - proxy_pod_name=$(oc get pod -n "$NAMESPACE" -l app=e2e-interception-proxy \ - -o jsonpath='{.items[0].metadata.name}' 2>/dev/null) || proxy_pod_name="" - - if [[ -z "$proxy_pod_name" ]]; then - echo "ERROR: no e2e-interception-proxy pod in namespace $NAMESPACE" >&2 - return 1 - fi - - tmp=$(mktemp) - if ! oc exec -n "$NAMESPACE" "$proxy_pod_name" -- \ - cat /tmp/interception-proxy-ca.pem >"$tmp"; then - rm -f "$tmp" - echo "ERROR: failed to read CA from e2e-interception-proxy pod" >&2 - return 1 - fi - if [[ ! -s "$tmp" ]]; then - rm -f "$tmp" - echo "ERROR: interception-proxy CA PEM is empty" >&2 - return 1 - fi - - if ! oc create secret generic e2e-interception-proxy-ca \ - --from-file=ca.pem="$tmp" \ - -n "$NAMESPACE" \ - --dry-run=client -o yaml | oc apply -n "$NAMESPACE" -f -; then - rm -f "$tmp" - echo "ERROR: failed to apply e2e-interception-proxy-ca secret" >&2 - return 1 - fi - rm -f "$tmp" - echo "✓ Secret e2e-interception-proxy-ca updated (ca.pem)" -} - -_verify_interception_ca_mounted_in_llama() { - local llama_pod_name="llama-stack-service" - if oc exec -n "$NAMESPACE" "$llama_pod_name" -c llama-stack-container -- \ - test -s /tmp/interception-proxy-ca.pem; then - echo "✓ interception-proxy CA present at /tmp/interception-proxy-ca.pem in llama-stack" - return 0 - fi - echo "ERROR: /tmp/interception-proxy-ca.pem missing or empty in llama-stack pod" >&2 - oc exec -n "$NAMESPACE" "$llama_pod_name" -c llama-stack-container -- \ - ls -la /tmp/interception-proxy-ca.pem 2>&1 || true - return 1 -} - -cmd_copy_interception_proxy_ca_to_llama() { - # Legacy name: publish CA via Secret (mounted by ogx-openai.yaml). - cmd_sync_interception_proxy_ca_secret -} - -_e2e_repo_root() { - cd "$SCRIPT_DIR/../../../.." && pwd -} - -cmd_deploy_e2e_tunnel_proxy() { - local repo_root - repo_root="$(_e2e_repo_root)" - echo "Deploying e2e-tunnel-proxy in namespace $NAMESPACE..." - oc create configmap e2e-tunnel-proxy-script -n "$NAMESPACE" \ - --from-file=tunnel_proxy.py="$repo_root/tests/e2e/proxy/tunnel_proxy.py" \ - --dry-run=client -o yaml | oc apply -f - - oc apply -n "$NAMESPACE" -f "$MANIFEST_DIR/e2e-tunnel-proxy.yaml" - if ! oc wait pod/e2e-tunnel-proxy -n "$NAMESPACE" --for=condition=Ready --timeout=120s; then - echo "ERROR: e2e-tunnel-proxy failed to become ready" >&2 - oc describe pod e2e-tunnel-proxy -n "$NAMESPACE" 2>/dev/null | tail -25 || true - return 1 - fi - echo "✓ e2e-tunnel-proxy ready at http://e2e-tunnel-proxy.${NAMESPACE}.svc.cluster.local:8888" -} - -cmd_deploy_e2e_interception_proxy() { - local repo_root - repo_root="$(_e2e_repo_root)" - echo "Deploying e2e-interception-proxy in namespace $NAMESPACE..." - oc create configmap e2e-interception-proxy-script -n "$NAMESPACE" \ - --from-file=interception_proxy.py="$repo_root/tests/e2e/proxy/interception_proxy.py" \ - --dry-run=client -o yaml | oc apply -f - - oc apply -n "$NAMESPACE" -f "$MANIFEST_DIR/e2e-interception-proxy.yaml" - if ! oc wait pod/e2e-interception-proxy -n "$NAMESPACE" --for=condition=Ready --timeout=180s; then - echo "ERROR: e2e-interception-proxy failed to become ready" >&2 - e2e_ops_dump_pod_logs "e2e-interception-proxy" 80 - return 1 - fi - echo "✓ e2e-interception-proxy ready at http://e2e-interception-proxy.${NAMESPACE}.svc.cluster.local:8889" -} - -_MOCK_TLS_CERT_FILES=( - ca.crt client.crt client.key untrusted-ca.crt expired-ca.crt - untrusted-client.crt untrusted-client.key expired-client.crt -) - -# Copy one PEM from the mock pod; retries oc exec when kubelet returns transient EOF. -_mock_tls_copy_cert_from_pod() { - local mock_pod="$1" - local cert_name="$2" - local dest="$3" - local max_attempts="${4:-6}" - local attempt - - for ((attempt=1; attempt<=max_attempts; attempt++)); do - if oc exec -n "$NAMESPACE" "$mock_pod" -c e2e-mock-tls-inference --request-timeout=60s -- \ - cat "/certs/${cert_name}" >"$dest" 2>/dev/null && [[ -s "$dest" ]]; then - return 0 - fi - rm -f "$dest" - if [[ $attempt -lt $max_attempts ]]; then - echo "[e2e-ops] WARN: oc exec /certs/${cert_name} failed (attempt $attempt/$max_attempts); retrying..." - sleep $((attempt * 2)) - fi - done - return 1 -} - -# Read all mock /certs into a temp dir (caller removes tmpdir). -_sync_mock_tls_certs_from_running_pod() { - local mock_pod="e2e-mock-tls-inference" - local f tmpdir from_args - - tmpdir=$(mktemp -d) - for f in "${_MOCK_TLS_CERT_FILES[@]}"; do - if ! _mock_tls_copy_cert_from_pod "$mock_pod" "$f" "${tmpdir}/${f}"; then - echo "ERROR: failed to read /certs/${f} from $mock_pod after retries" >&2 - rm -rf "$tmpdir" - return 1 - fi - done - from_args=() - for f in "${_MOCK_TLS_CERT_FILES[@]}"; do - from_args+=(--from-file="${f}=${tmpdir}/${f}") - done - oc create secret generic e2e-mock-tls-certs \ - "${from_args[@]}" -n "$NAMESPACE" \ - --dry-run=client -o yaml | oc apply -n "$NAMESPACE" -f - - rm -rf "$tmpdir" - return 0 -} - -# Apply mock TLS manifest and wait for Ready (no Secret sync). -_deploy_e2e_mock_tls_inference_pod() { - local repo_root server_py - repo_root="$(_e2e_repo_root)" - server_py="$repo_root/tests/e2e/mock_tls_inference_server/server.py" - if [[ ! -f "$server_py" ]]; then - echo "ERROR: missing $server_py" >&2 - return 1 - fi - echo "Deploying e2e-mock-tls-inference pod in namespace $NAMESPACE..." - oc create configmap e2e-mock-tls-inference-script -n "$NAMESPACE" \ - --from-file=server.py="$server_py" \ - --dry-run=client -o yaml | oc apply -f - - oc apply -n "$NAMESPACE" -f "$MANIFEST_DIR/e2e-mock-tls-inference.yaml" - if ! oc wait pod/e2e-mock-tls-inference -n "$NAMESPACE" --for=condition=Ready --timeout=240s; then - echo "ERROR: e2e-mock-tls-inference failed to become ready" >&2 - e2e_ops_dump_pod_logs "e2e-mock-tls-inference" 80 - return 1 - fi - return 0 -} - -cmd_sync_mock_tls_certs_secret() { - local mock_pod="e2e-mock-tls-inference" - local pass - - for pass in 1 2; do - if ! oc get pod "$mock_pod" -n "$NAMESPACE" &>/dev/null; then - echo "[e2e-ops] WARN: $mock_pod not found — deploying mock TLS inference..." - if ! _deploy_e2e_mock_tls_inference_pod; then - return 1 - fi - elif ! oc wait pod/"$mock_pod" -n "$NAMESPACE" --for=condition=Ready --timeout=120s; then - echo "[e2e-ops] WARN: $mock_pod not Ready — redeploying mock TLS inference..." - cmd_delete_e2e_mock_tls_inference - if ! _deploy_e2e_mock_tls_inference_pod; then - return 1 - fi - fi - - if _sync_mock_tls_certs_from_running_pod; then - echo "✓ Secret e2e-mock-tls-certs updated" - return 0 - fi - - if [[ $pass -eq 1 ]]; then - echo "[e2e-ops] WARN: mock TLS cert sync failed (oc exec/kubelet) — redeploying mock pod and retrying..." - cmd_delete_e2e_mock_tls_inference - if ! _deploy_e2e_mock_tls_inference_pod; then - return 1 - fi - continue - fi - - e2e_ops_dump_pod_logs "$mock_pod" 80 - return 1 - done - return 1 -} - -cmd_delete_e2e_mock_tls_inference() { - echo "Removing e2e-mock-tls-inference from namespace $NAMESPACE..." - timeout 60 oc delete pod e2e-mock-tls-inference -n "$NAMESPACE" --ignore-not-found=true --wait=true 2>/dev/null || { - oc delete pod e2e-mock-tls-inference -n "$NAMESPACE" --ignore-not-found=true --force --grace-period=0 2>/dev/null || true - sleep 2 - } - oc delete svc e2e-mock-tls-inference -n "$NAMESPACE" --ignore-not-found=true 2>/dev/null || true - echo "✓ e2e-mock-tls-inference removed" -} - -cmd_deploy_e2e_mock_tls_inference() { - if ! _deploy_e2e_mock_tls_inference_pod; then - return 1 - fi - if ! cmd_sync_mock_tls_certs_secret; then - return 1 - fi - echo "✓ e2e-mock-tls-inference ready" -} - -cmd_restart_e2e_mock_tls_inference() { - echo "Restarting e2e-mock-tls-inference (delete + deploy)..." - cmd_delete_e2e_mock_tls_inference - cmd_deploy_e2e_mock_tls_inference -} - cmd_dump_pod_logs() { e2e_ops_dump_pod_logs "${1:?pod name required}" "${2:-150}" } -cmd_disrupt_ogx() { - local pod_name="llama-stack-service" - - local phase - phase=$(oc get pod "$pod_name" -n "$NAMESPACE" -o jsonpath='{.status.phase}' 2>/dev/null || echo "NotFound") - - if [[ "$phase" == "Running" ]]; then - oc delete pod "$pod_name" -n "$NAMESPACE" --wait=true - sleep 2 - echo "OGX connection disrupted successfully (pod deleted)" - exit 0 - else - echo "OGX pod was not running (phase: $phase)" - exit 2 - fi -} - # Prove OGX can reach Solr in-cluster (same path as okp-solr.yaml probes). # /solr and /solr/ are the Solr Admin UI; current OKP/Mimir images return HTTP 404 there. cmd_check_okp_solr_from_llama() { - local pod="llama-stack-service" - local ctr="llama-stack-container" + local pod="lightspeed-stack-service" + local ctr="lightspeed-stack-container" local url="http://okp-solr-service-svc:8080/solr/portal-rag/select?q=*:*&rows=0" - echo "Checking OKP Solr from OGX pod at ${url}..." + echo "Checking OKP Solr from cluster at ${url} (pod=$pod)..." if oc exec -n "$NAMESPACE" "$pod" -c "$ctr" -- \ curl -sf --max-time 10 -o /dev/null "$url" 2>/dev/null; then - echo "✓ OGX pod can reach OKP Solr" + echo "✓ Pod can reach OKP Solr" return 0 fi if oc exec -n "$NAMESPACE" "$pod" -c "$ctr" -- \ - /opt/app-root/.venv/bin/python -c \ + python3 -c \ "import urllib.request; urllib.request.urlopen('${url}', timeout=10).read()"; then - echo "✓ OGX pod can reach OKP Solr" + echo "✓ Pod can reach OKP Solr" return 0 fi - echo "ERROR: OGX pod cannot reach OKP Solr at $url" + echo "ERROR: Pod cannot reach OKP Solr at $url" return 1 } @@ -1146,15 +619,6 @@ case "$COMMAND" in restart-lightspeed) cmd_restart_lightspeed ;; - restart-ogx) - cmd_restart_llama_stack - ;; - restart-both-services) - cmd_restart_both_services - ;; - restart-ogx-port-forward) - cmd_restart_llama_port_forward - ;; restart-jwks-port-forward) cmd_restart_jwks_port_forward ;; @@ -1170,39 +634,6 @@ case "$COMMAND" in get-configmap-content) cmd_get_configmap_content "$@" ;; - disrupt-ogx) - cmd_disrupt_ogx - ;; - tunnel-proxy-stats) - cmd_tunnel_proxy_stats - ;; - interception-proxy-stats) - cmd_interception_proxy_stats - ;; - copy-interception-proxy-ca-to-llama) - cmd_copy_interception_proxy_ca_to_llama - ;; - sync-interception-proxy-ca-secret) - cmd_sync_interception_proxy_ca_secret - ;; - deploy-e2e-tunnel-proxy) - cmd_deploy_e2e_tunnel_proxy - ;; - deploy-e2e-interception-proxy) - cmd_deploy_e2e_interception_proxy - ;; - deploy-e2e-mock-tls-inference) - cmd_deploy_e2e_mock_tls_inference - ;; - delete-e2e-mock-tls-inference) - cmd_delete_e2e_mock_tls_inference - ;; - restart-e2e-mock-tls-inference) - cmd_restart_e2e_mock_tls_inference - ;; - sync-mock-tls-certs-secret) - cmd_sync_mock_tls_certs_secret - ;; dump-pod-logs) cmd_dump_pod_logs "$@" ;; @@ -1226,30 +657,17 @@ case "$COMMAND" in echo "" echo "Commands:" echo " restart-lightspeed - Restart lightspeed-stack pod and port-forward" - echo " restart-ogx - Restart/restore llama-stack pod" - echo " restart-both-services - Full llama-stack + lightspeed-stack restart (explicit)" - echo " restart-ogx-port-forward - Re-establish port-forward for OGX (8321)" echo " restart-port-forward - Re-establish port-forward for lightspeed" + echo " restart-jwks-port-forward - Re-establish JWKS port-forward" echo " wait-for-pod [attempts] - Wait for a pod to be ready" echo " update-configmap - Update ConfigMap from file" echo " get-configmap-content - Get ConfigMap content (outputs to stdout)" - echo " disrupt-ogx - Delete llama-stack pod to disrupt connection" - echo " tunnel-proxy-stats - JSON stats from in-cluster e2e-tunnel-proxy" - echo " interception-proxy-stats - JSON stats from in-cluster e2e-interception-proxy" - echo " copy-interception-proxy-ca-to-llama - Alias for sync-interception-proxy-ca-secret" - echo " sync-interception-proxy-ca-secret - Publish trustme CA to Secret for llama mount" - echo " deploy-e2e-tunnel-proxy - Deploy in-cluster tunnel proxy pod" - echo " deploy-e2e-interception-proxy - Deploy in-cluster interception proxy pod" - echo " deploy-e2e-mock-tls-inference - Deploy mock HTTPS inference (tls-*.feature)" - echo " delete-e2e-mock-tls-inference - Remove mock TLS pod + Service" - echo " check-okp-solr-from-llama - GET Solr portal-rag select from inside the OGX pod" - echo " deploy-okp-solr - Deploy OKP Solr (idempotent; @cfg_okp before_feature)" - echo " delete-okp-solr - Delete OKP Solr pod" - echo " disrupt-okp-solr - Delete OKP Solr pod to disrupt connection" - echo " restore-okp-solr - Restore OKP Solr pod" - echo " restart-e2e-mock-tls-inference - Delete then deploy mock TLS (recovery)" - echo " sync-mock-tls-certs-secret - Publish mock TLS /certs to Secret" - echo " dump-pod-logs [tail-lines] - Print init + container logs" + echo " dump-pod-logs [tail-lines] - Print init + container logs" + echo " check-okp-solr-from-llama - GET Solr from inside lightspeed-stack-service" + echo " deploy-okp-solr - Deploy OKP Solr (idempotent; @cfg_okp before_feature)" + echo " delete-okp-solr - Delete OKP Solr pod" + echo " disrupt-okp-solr - Delete OKP Solr pod to disrupt connection" + echo " restore-okp-solr - Restore OKP Solr pod" exit 1 ;; esac diff --git a/tests/e2e/configuration/library-mode/lightspeed-stack-rhelai.yaml b/tests/e2e/configuration/library-mode/lightspeed-stack-rhelai.yaml new file mode 100644 index 0000000000..17a6da6631 --- /dev/null +++ b/tests/e2e/configuration/library-mode/lightspeed-stack-rhelai.yaml @@ -0,0 +1,44 @@ +name: Lightspeed Core Service (LCS) +service: + host: 0.0.0.0 + port: 8080 + auth_enabled: false + workers: 1 + color_log: true + access_log: true +ogx: + use_as_library_client: true + config: + profile: run.yaml +user_data_collection: + feedback_enabled: true + feedback_storage: "/tmp/data/feedback" + transcripts_enabled: true + transcripts_storage: "/tmp/data/transcripts" +authentication: + module: "noop" +inference: + default_provider: vllm + default_model: ${env.VLLM_MODEL} + providers: + - type: vllm + id: vllm + skip_model_discovery: true + allowed_models: + - name: ${env.VLLM_MODEL} + provider_model_id: ${env.VLLM_MODEL} + model_type: llm +rag: + byok: + stores: + - rag_id: e2e-test-docs + backend: faiss + embedding_model: sentence-transformers/all-mpnet-base-v2 + embedding_dimension: 768 + vector_db_id: ${env.FAISS_VECTOR_STORE_ID} + db_path: ${env.KV_RAG_PATH:=~/.llama/storage/rag/kv_store.db} + score_multiplier: 1.0 + retrieval: + tool: + sources: + - e2e-test-docs \ No newline at end of file diff --git a/tests/e2e/features/environment.py b/tests/e2e/features/environment.py index 7942f5e67f..ffeec807df 100644 --- a/tests/e2e/features/environment.py +++ b/tests/e2e/features/environment.py @@ -97,7 +97,9 @@ def before_all(context: Context) -> None: "e2e-test-secret-do-not-use-in-production" ) - # Detect deployment mode from environment variable + # Konflux always runs library mode (single LCS pod, OGX in-process). + if is_konflux_environment(): + os.environ["E2E_DEPLOYMENT_MODE"] = "library" context.deployment_mode = os.getenv("E2E_DEPLOYMENT_MODE", "server").lower() context.is_library_mode = context.deployment_mode == "library" @@ -271,8 +273,7 @@ def _dump_pod_logs_on_failure( """Dump container logs when a scenario fails in Prow.""" if scenario.status != "failed": return - # Pod names match tests/e2e-prow manifests (legacy llama-stack-service id). - pods: tuple[str, ...] = ("llama-stack-service", "lightspeed-stack-service") + pods: tuple[str, ...] = ("lightspeed-stack-service",) feature = getattr(context, "feature", None) feat_tags = getattr(feature, "tags", []) if feature else [] if "cfg_okp" in feat_tags: diff --git a/tests/e2e/features/steps/common.py b/tests/e2e/features/steps/common.py index afc0364b4c..6bd83adca9 100644 --- a/tests/e2e/features/steps/common.py +++ b/tests/e2e/features/steps/common.py @@ -9,6 +9,7 @@ from tests.e2e.utils.utils import ( absolute_repo_path, create_config_backup, + is_e2e_library_cluster, is_prow_environment, restart_container, switch_config, @@ -65,10 +66,16 @@ def service_is_started_locally(context: Context) -> None: context.hostname = os.getenv("E2E_LSC_HOSTNAME", "localhost") context.port = os.getenv("E2E_LSC_PORT", "8080") if is_prow_environment(): - context.hostname_ogx = os.getenv("E2E_OGX_HOSTNAME", "localhost") + if is_e2e_library_cluster(): + # Library/Konflux: OGX is in-process; hooks target LCS on :8080 only. + context.hostname_ogx = context.hostname + context.port_ogx = context.port + else: + context.hostname_ogx = os.getenv("E2E_OGX_HOSTNAME", "localhost") + context.port_ogx = os.getenv("E2E_OGX_PORT", "8321") else: context.hostname_ogx = "localhost" - context.port_ogx = os.getenv("E2E_OGX_PORT", "8321") + context.port_ogx = "8321" _ogx_endpoint["hostname"] = context.hostname_ogx _ogx_endpoint["port"] = context.port_ogx diff --git a/tests/e2e/utils/README.md b/tests/e2e/utils/README.md index 611738ad2a..e33bbcafa2 100644 --- a/tests/e2e/utils/README.md +++ b/tests/e2e/utils/README.md @@ -1,9 +1,5 @@ # List of source files stored in `tests/e2e/utils` directory -## [ogx_prow_utils.py](ogx_prow_utils.py) - -Thin Prow/OpenShift wrappers for OGX run.yaml ConfigMap operations. - ## [prow_utils.py](prow_utils.py) Prow/OpenShift-specific utility functions for E2E tests. diff --git a/tests/e2e/utils/ogx_prow_utils.py b/tests/e2e/utils/ogx_prow_utils.py deleted file mode 100644 index f3247a8456..0000000000 --- a/tests/e2e/utils/ogx_prow_utils.py +++ /dev/null @@ -1,42 +0,0 @@ -"""Thin Prow/OpenShift wrappers for OGX run.yaml ConfigMap operations.""" - -from tests.e2e.utils.prow_utils import ( - backup_configmap_to_memory, - get_configmap_content, - remove_configmap_backup, - update_config_configmap, -) - -# OpenShift ConfigMap name (legacy K8s resource id in Prow manifests). -_OGX_CONFIGMAP_NAME = "llama-stack-config" -_OGX_CONFIGMAP_KEY = "run.yaml" - - -def get_ogx_run_config_content() -> str: - """Return OGX run.yaml ConfigMap content in Prow/OpenShift.""" - return get_configmap_content( - configmap_name=_OGX_CONFIGMAP_NAME, - configmap_key=_OGX_CONFIGMAP_KEY, - ) - - -def backup_ogx_run_config_to_memory() -> str: - """Backup OGX run.yaml ConfigMap into in-memory backup storage.""" - return backup_configmap_to_memory( - configmap_name=_OGX_CONFIGMAP_NAME, - configmap_key=_OGX_CONFIGMAP_KEY, - ) - - -def update_ogx_run_configmap(source: str) -> None: - """Update or restore OGX run.yaml ConfigMap from file or backup key.""" - update_config_configmap( - source, - configmap_name=_OGX_CONFIGMAP_NAME, - configmap_key=_OGX_CONFIGMAP_KEY, - ) - - -def remove_ogx_run_config_backup(backup_key: str) -> None: - """Remove an OGX run.yaml ConfigMap backup from in-memory storage.""" - remove_configmap_backup(backup_key) diff --git a/tests/e2e/utils/prow_utils.py b/tests/e2e/utils/prow_utils.py index b7b3817b5a..7be4d5e4b7 100644 --- a/tests/e2e/utils/prow_utils.py +++ b/tests/e2e/utils/prow_utils.py @@ -17,17 +17,20 @@ def get_namespace() -> str: return os.getenv("NAMESPACE", "e2e-rhoai-dsc") -# Mapping from container names (used in tests) to pod names (used in OpenShift) +# Mapping from logical container names (used in tests) to OpenShift pod names. _POD_NAME_MAP = { "lightspeed-stack": "lightspeed-stack-service", - "ogx": "llama-stack-service", - "llama-stack": "llama-stack-service", # legacy alias + "ogx": "lightspeed-stack-service", + "llama-stack": "lightspeed-stack-service", "okp-solr": "okp-solr-service", } +_LEGACY_SERVICE_ALIASES = frozenset({"ogx", "llama-stack", "llama-stack-service"}) def get_pod_name(container_name: str) -> str: - """Map container name to OpenShift pod name.""" + """Map container name to OpenShift pod name (OGX aliases → lightspeed-stack-service).""" + if container_name in _LEGACY_SERVICE_ALIASES: + return "lightspeed-stack-service" return _POD_NAME_MAP.get(container_name, container_name) @@ -90,61 +93,51 @@ def wait_for_pod_health(pod_name: str, max_attempts: int = 60) -> None: raise -_OGX_RESTART_NAMES = frozenset({"ogx", "llama-stack", "llama-stack-service"}) -_LIGHTSPEED_RESTART_NAMES = frozenset({"lightspeed-stack", "lightspeed-stack-service"}) +_LIGHTSPEED_RESTART_NAMES = frozenset( + { + "lightspeed-stack", + "lightspeed-stack-service", + "ogx", + "llama-stack", + "llama-stack-service", + } +) +_RESTART_POD_TIMEOUT_SECONDS = 420 -# e2e-ops Konflux ``restart-ogx``: up to 360×3s pod wait, then health, port-forward, vLLM poll. -_KONFLUX_RESTART_OGX_E2E_OPS_TIMEOUT = 2700 - -def _restart_ogx_e2e_ops_timeout_seconds() -> int: - """Subprocess cap for ``restart-ogx``; must cover e2e-ops internal poll budgets.""" - if os.environ.get("E2E_COPY_MOCK_TLS_CERTS_TO_OGX") == "1": - return _KONFLUX_RESTART_OGX_E2E_OPS_TIMEOUT - if os.environ.get("E2E_KONFLUX_E2E") == "1": - return _KONFLUX_RESTART_OGX_E2E_OPS_TIMEOUT - return 420 +def assert_prow_cluster_sidecars_supported() -> None: + """Raise when proxy/TLS tests expect removed in-cluster e2e-ops deploy commands.""" + raise AssertionError( + "In-cluster proxy/TLS sidecars are not deployed via e2e-ops " + "(Konflux library mode). Run those suites with Docker Compose (@skip-in-prow)." + ) def restart_pod(container_name: str) -> None: - """Restart OGX or Lightspeed pod in OpenShift/Prow (not Docker). - - Maps ``container_name`` to the correct e2e-ops command: ``restart-ogx`` - vs ``restart-lightspeed``. Unknown names default to Lightspeed with a warning. + """Restart lightspeed-stack-service in OpenShift/Prow (not Docker). - For Lightspeed restarts, e2e-ops ensures OGX is running first. OGX pod logs - may look unchanged after apply (no-op when healthy); that is expected. + Legacy names ``ogx`` / ``llama-stack`` map to the same pod (OGX in-process). + Unknown names default to ``restart-lightspeed`` with a warning. CI failures with healthy pod logs are often **localhost port-forward** contention (pipeline forward vs hook restart), not application crashes—see e2e-ops.sh header. """ - if container_name in _OGX_RESTART_NAMES: - op = "restart-ogx" - timeout = _restart_ogx_e2e_ops_timeout_seconds() - elif container_name in _LIGHTSPEED_RESTART_NAMES: + if container_name in _LIGHTSPEED_RESTART_NAMES: op = "restart-lightspeed" - # e2e-ops may restore OGX first when unhealthy (same shell waits as restart-ogx). - if ( - os.environ.get("E2E_KONFLUX_E2E") == "1" - or os.environ.get("E2E_COPY_MOCK_TLS_CERTS_TO_OGX") == "1" - ): - timeout = _restart_ogx_e2e_ops_timeout_seconds() - else: - timeout = 320 + timeout = _RESTART_POD_TIMEOUT_SECONDS else: print( f"Warning: restart_pod({container_name!r}) unknown; " "using restart-lightspeed" ) op = "restart-lightspeed" - timeout = 200 + timeout = 320 try: result = run_e2e_ops(op, timeout=timeout) print(result.stdout, end="") if result.returncode != 0: print(result.stderr, end="") combined = f"{result.stdout or ''}\n{result.stderr or ''}".strip() - # Prefer full e2e-ops output when diagnostics were printed (TLS/Llama failures). if "========== failure logs:" in combined: detail = combined else: @@ -161,47 +154,70 @@ def restart_pod(container_name: str) -> None: def restore_ogx_pod() -> None: - """Restore OGX pod in Prow/OpenShift environment. + """Recreate lightspeed-stack-service after disruption (legacy name: restore OGX). Raises: subprocess.CalledProcessError: If oc/e2e-ops restore fails. subprocess.TimeoutExpired: If the operation times out. """ - timeout = _restart_ogx_e2e_ops_timeout_seconds() - result = run_e2e_ops("restart-ogx", timeout=timeout) + result = run_e2e_ops("restart-lightspeed", timeout=_RESTART_POD_TIMEOUT_SECONDS) print(result.stdout, end="") if result.returncode != 0: print(result.stderr, end="") raise subprocess.CalledProcessError( - result.returncode, "restart-ogx", result.stderr + result.returncode, "restart-lightspeed", result.stderr ) - print("✓ OGX pod restored successfully") + print("✓ lightspeed-stack-service restored") def disrupt_ogx_pod() -> bool: - """Disrupt OGX connection in Prow/OpenShift environment. + """Disrupt the stack by deleting lightspeed-stack-service in Prow/OpenShift. Returns: True if the pod was running and has been disrupted, False otherwise. """ + pod_name = "lightspeed-stack-service" + namespace = get_namespace() try: - result = run_e2e_ops("disrupt-ogx", timeout=90) - print(result.stdout, end="") + phase_result = subprocess.run( + [ + "oc", + "get", + "pod", + pod_name, + "-n", + namespace, + "-o", + "jsonpath={.status.phase}", + ], + capture_output=True, + text=True, + timeout=30, + check=False, + ) + phase = (phase_result.stdout or "").strip() or "NotFound" + if phase != "Running": + print(f"lightspeed-stack-service was not running (phase: {phase})") + return False - # Exit code 0 = disrupted (was running), exit code 2 = was not running - match result.returncode: - case 0: - return True - case 2: - return False - case _: - print(result.stderr, end="") - return False + delete_result = subprocess.run( + ["oc", "delete", "pod", pod_name, "-n", namespace, "--wait=true"], + capture_output=True, + text=True, + timeout=90, + check=False, + ) + print(delete_result.stdout, end="") + if delete_result.returncode != 0: + print(delete_result.stderr, end="") + return False + print("Connection disrupted successfully (lightspeed-stack-service deleted)") + return True except subprocess.TimeoutExpired: - print("Warning: Timeout while disrupting OGX connection") + print("Warning: Timeout while disrupting connection") return False @@ -314,12 +330,10 @@ def update_config_configmap( """ temp_path: Optional[str] = None - # Check if source is a backup key (restore from memory) if source in _configmap_backups: config_content = _apply_inference_overrides(_configmap_backups[source]) print(f"Restoring ConfigMap {configmap_name} from memory backup...") - # Write content to temp file (oc create configmap requires a file) with tempfile.NamedTemporaryFile(mode="w", suffix=".yaml", delete=False) as f: f.write(config_content) temp_path = f.name @@ -335,7 +349,6 @@ def update_config_configmap( os.remove(temp_path) return - # Otherwise, source is a file path — apply inference overrides if needed print(f"Updating ConfigMap {configmap_name} with config from {source}...") source_to_apply = source @@ -363,10 +376,9 @@ def update_config_configmap( def assert_okp_reachable_from_ogx() -> None: - """Fail unless the OGX pod can HTTP GET in-cluster OKP Solr. + """Fail unless lightspeed-stack-service can HTTP GET in-cluster OKP Solr. - This is the Konflux health check: Solr is reached in-cluster from the - OGX pod. Behave does not port-forward Solr to the runner. + Konflux library mode: Solr is reached from the LCS pod, not a separate OGX pod. Raises: subprocess.CalledProcessError: If the in-cluster GET fails. @@ -393,11 +405,8 @@ def ensure_okp_solr_ready() -> None: subprocess.TimeoutExpired: If the operation times out. """ - # 300 wait_for_pod attempts × 3s = 900s, plus oc apply. 1080s leaves margin. try: result = run_e2e_ops("deploy-okp-solr", timeout=1080) - # Print to the real stdout: before_feature's hook output is captured and - # dropped on success, which would otherwise hide this every run. print(result.stdout, end="", file=sys.__stdout__, flush=True) if result.returncode != 0: print(result.stderr, end="") @@ -405,7 +414,6 @@ def ensure_okp_solr_ready() -> None: result.returncode, "deploy-okp-solr", result.stderr ) except subprocess.TimeoutExpired as exc: - # Forward captured output before re-raising print(exc.stdout or "", end="", file=sys.__stdout__, flush=True) print(exc.stderr or "", end="", file=sys.__stdout__, flush=True) raise @@ -423,7 +431,6 @@ def disrupt_okp_solr_pod() -> bool: print(result.stdout, end="") print(f"disrupt-okp-solr exit code: {result.returncode}") - # Exit code 0 = disrupted (was running), exit code 2 = was not running if result.returncode == 0: return True if result.returncode == 2: @@ -446,8 +453,6 @@ def restore_okp_solr_pod() -> None: subprocess.TimeoutExpired: If the operation times out. """ - # restore-okp-solr can spend 180 seconds in wait_for_pod, plus oc apply time. - # Use a timeout with margin (240s) so we fail instead of hanging forever. result = run_e2e_ops("restore-okp-solr", timeout=240) print(result.stdout, end="") if result.returncode != 0: diff --git a/tests/e2e/utils/utils.py b/tests/e2e/utils/utils.py index 410cdc235f..9c334ea360 100644 --- a/tests/e2e/utils/utils.py +++ b/tests/e2e/utils/utils.py @@ -20,6 +20,7 @@ ) _DEFAULT_CLUSTER_LIGHTSPEED_CONFIG_DIR = "tests/e2e/configuration/server-mode" +_DEFAULT_KONFLUX_LIGHTSPEED_CONFIG_DIR = "tests/e2e/configuration/library-mode" def _e2e_repo_root() -> str: @@ -74,6 +75,17 @@ def is_konflux_environment() -> bool: return os.getenv("E2E_KONFLUX_E2E") == "1" +def is_e2e_library_cluster() -> bool: + """Return True when cluster E2E runs LCS with in-process OGX (Konflux today). + + Classic ``pipeline.sh`` remains server mode until it is rewired; only Konflux + forces library mode in the pipeline and test harness. + """ + if is_konflux_environment(): + return True + return os.getenv("E2E_DEPLOYMENT_MODE", "server").strip().lower() == "library" + + # Transient connection resets (e.g. errno 104) after container restarts in CI/Docker. E2E_HTTP_TRANSIENT_MAX_ATTEMPTS: int = 3 E2E_HTTP_TRANSIENT_DELAY_S: float = 0.5 @@ -117,15 +129,17 @@ def cluster_lightspeed_config_dir() -> str: Paths are relative to the repository root. Pipelines set ``E2E_LIGHTSPEED_CONFIG_DIR`` explicitly so local and CI agree on one variable; - when unset, defaults to ``tests/e2e/configuration/server-mode``. + Konflux defaults to ``tests/e2e/configuration/library-mode``; classic Prow + defaults to ``server-mode``. Returns: Non-empty repo-relative directory path. """ - raw = os.getenv("E2E_LIGHTSPEED_CONFIG_DIR", _DEFAULT_CLUSTER_LIGHTSPEED_CONFIG_DIR) + default = _DEFAULT_KONFLUX_LIGHTSPEED_CONFIG_DIR + raw = os.getenv("E2E_LIGHTSPEED_CONFIG_DIR", default) stripped = raw.strip() - return stripped or _DEFAULT_CLUSTER_LIGHTSPEED_CONFIG_DIR + return stripped or default def cluster_lightspeed_config_path(filename: str) -> str: From 58bec6d20c9f35376f79e07cd50648152266bd67 Mon Sep 17 00:00:00 2001 From: Radovan Fuchs Date: Wed, 25 Nov 2026 16:21:46 +0100 Subject: [PATCH 2/2] update perms --- .../e2e-prow/rhoai/manifests/lightspeed/lightspeed-stack.yaml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/e2e-prow/rhoai/manifests/lightspeed/lightspeed-stack.yaml b/tests/e2e-prow/rhoai/manifests/lightspeed/lightspeed-stack.yaml index 9e9ad780dc..9b10225459 100644 --- a/tests/e2e-prow/rhoai/manifests/lightspeed/lightspeed-stack.yaml +++ b/tests/e2e-prow/rhoai/manifests/lightspeed/lightspeed-stack.yaml @@ -74,7 +74,9 @@ spec: capabilities: drop: ["ALL"] runAsNonRoot: true - runAsUser: 1000 + # Match Konflux/Containerfile USER 1001 so library-mode synthesis can write + # ./.generated under /app-root (DEFAULT_SYNTHESIZED_CONFIG_PATH). + runAsUser: 1001 seccompProfile: type: RuntimeDefault env: