Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 11 additions & 14 deletions docs/testing/e2e_testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,8 @@ uv run behave tests/e2e/features/query.feature --tags=-skip
# Scenarios with a given tag (e.g. Authorized)
uv run behave tests/e2e/features/query.feature --tags=Authorized

# Exclude a tag
uv run behave tests/e2e/features/health.feature --tags=-skip-in-library-mode
# Exclude skipped scenarios
uv run behave tests/e2e/features/health.feature --tags=-skip
```

---
Expand Down Expand Up @@ -287,7 +287,7 @@ 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 under `configuration/server-mode/` vs `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). |
Expand All @@ -310,8 +310,8 @@ For local Docker runs, defaults are usually enough. Override when the stack is o

## Deployment Modes: Server vs Library

- **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).
- **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.
- **Library mode** (`E2E_DEPLOYMENT_MODE=library`): OGX runs **in-process** with the app. Configs under `configuration/library-mode/` are used.

Mode is set in `before_all` from `E2E_DEPLOYMENT_MODE` and stored as `context.is_library_mode`.

Expand All @@ -328,7 +328,6 @@ All tag behaviour is implemented in **`features/environment.py`**: the hooks (`b
| `@skip` | Scenario is skipped (reason: "Marked with @skip"). Use for broken or WIP scenarios. |
| `@konflux-only` | Skipped unless `E2E_KONFLUX_E2E=1`. Used by `okp_rag.feature`. |
| `@cfg_okp` | OKP Solr RAG. Konflux deploys OKP in `before_feature`. Local: [Running OKP RAG tests locally](#running-okp-rag-tests-locally). |
| `@skip-in-library-mode` | Scenario is skipped when `E2E_DEPLOYMENT_MODE=library`. Used for tests that require a separate OGX (e.g. connection disruption). |
| `@local` | Skipped unless running in "local" mode (context flag). |
| `@InvalidFeedbackStorageConfig` | Before scenario: switch to invalid-feedback-storage config and restart container. After: restore feature config and restart. |
| `@NoCacheConfig` | Before scenario: switch to no-cache config and restart. After: restore and restart. |
Expand All @@ -349,17 +348,15 @@ All tag behaviour is implemented in **`features/environment.py`**: the hooks (`b
You can put several tags on one scenario. To document why a scenario is skipped, add a Gherkin comment above the tags:

```gherkin
# Only in server mode; OGX is in-process in library mode
@skip-in-library-mode
@skip
Scenario: Check if service report proper readiness when OGX is not available
@skip @cfg_authorized
Scenario: V2 conversations endpoint WITHOUT no_tools (known bug - empty vector DB)
```

### Hooks (environment.py)

- **before_all**: Sets `deployment_mode`, `is_library_mode`, detects or overrides `default_model` / `default_provider`, sets `faiss_vector_store_id`.
- **before_feature**: Applies feature-level config and restarts container for `Authorized`, `RBAC`, `RHIdentity`, `Feedback`, `MCP`.
- **before_scenario**: Skips scenarios for `@skip`, `@local`, `@skip-in-library-mode`; applies scenario config for `InvalidFeedbackStorageConfig` / `NoCacheConfig`.
- **before_scenario**: Skips scenarios for `@skip`, `@local`, `@konflux-only`, and `@skip-in-prow`; applies scenario config for `InvalidFeedbackStorageConfig` / `NoCacheConfig`.
- **after_scenario**: Restores OGX if it was disrupted; restores config and restarts for scenario config tags.
- **after_feature**: Restores config and restarts for `Authorized`, `RBAC`, `RHIdentity`, `MCP`; deletes feedback conversations for `Feedback`.

Expand Down Expand Up @@ -476,7 +473,7 @@ Here, **Given** sets state, **When** performs the HTTP call, **Then** and **And*

| Syntax | Meaning | Example |
|---------------|--------------------------------------------------------------------------------------------------------------|-------------------------------------------------|
| **@tag** | Tag for filtering or hooks. Above Feature (applies to all scenarios) or above Scenario (that scenario only). | `@Authorized`, `@skip`, `@skip-in-library-mode` |
| **@tag** | Tag for filtering or hooks. Above Feature (applies to all scenarios) or above Scenario (that scenario only). | `@Authorized`, `@skip`, `@skip-in-prow` |
| **# comment** | Gherkin comment. Ignored by Behave. Use to explain why a scenario is skipped or to document a scenario. | `# Only in server mode` above a scenario |


Expand Down Expand Up @@ -536,7 +533,7 @@ The integration side of this boundary is described in
## Writing New Scenarios

1. **Confirm the scenario is e2e at all** — see [Choosing the Test Layer](#choosing-the-test-layer-e2e-or-integration). Then **choose or add a feature file** under `tests/e2e/features/` and use existing steps where possible. If you add a new file, **add it to `tests/e2e/test_list.txt`** so the suite runs it.
2. **Use tags** for mode-dependent or config-dependent behavior (`@skip-in-library-mode`, `@Authorized`, etc.). **Adding a tag that switches configuration** (e.g. a new feature-level or scenario-level config) usually means you must also add or change a **Lightspeed Stack config** file under `configuration/server-mode/` or `library-mode/` and wire the tag in `environment.py` (e.g. in `before_feature` / `after_feature` or `before_scenario` / `after_scenario`) so the config is applied and the container restarted when the tag is active.
2. **Use tags** for config-dependent behavior (`@Authorized`, `@cfg_*`, etc.). **Adding a tag that switches configuration** (e.g. a new feature-level or scenario-level config) usually means you must also add or change a **Lightspeed Stack config** file under `configuration/server-mode/` or `library-mode/` and wire the tag in `environment.py` (e.g. in `before_feature` / `after_feature` or `before_scenario` / `after_scenario`) so the config is applied and the container restarted when the tag is active.
3. **Use placeholders** `{MODEL}` and `{PROVIDER}` in request bodies so the same scenario works with different backends.
4. **Add step definitions** in the appropriate `features/steps/*.py` if you need new steps; reuse `context` for host, port, auth, and responses.
5. **Optional**: If the scenario needs a dedicated config, add a new YAML under `configuration/server-mode/` (and optionally `library-mode/`), add an entry to `_CONFIG_PATHS` in `environment.py`, and handle the tag in the before/after hooks so the config is switched and the lightspeed-stack container is restarted.
Expand All @@ -551,7 +548,7 @@ The integration side of this boundary is described in
- **Readonly database (SQLite) in OGX**: If the RAG KV DB is on a bind-mounted path that becomes read-only (e.g. after restart), move it to a named volume (e.g. via `KV_RAG_PATH` in docker-compose) so writes succeed.
- **ChunkedEncodingError on streaming_query**: The step for streaming_query uses `stream=True` and consumes the stream; if you add new streaming steps, avoid reading the full response with `response.content` and use the same stream-reading pattern so a server close after an error event does not raise.
- **Event loop is closed (httpx/AsyncClient)**: In E2E, any code that creates an `AsyncOgxClient` (e.g. for shields) must close it (e.g. `await client.close()`) in a `finally` block before the event loop is torn down (e.g. before `asyncio.run()` returns).
- **Scenarios skipped**: Check tags (`@skip`, `@skip-in-library-mode`, `@local`, `@konflux-only`) and `E2E_DEPLOYMENT_MODE`; ensure the scenario is not excluded by `--tags=-skip` (or the opposite if you intend to run only skipped scenarios for debugging).
- **Scenarios skipped**: Check tags (`@skip`, `@local`, `@konflux-only`, `@skip-in-prow`) and `E2E_DEPLOYMENT_MODE`; ensure the scenario is not excluded by `--tags=-skip` (or the opposite if you intend to run only skipped scenarios for debugging).
- **Granite Guardian 403 / "Authentication failed"**: CI uses `mock-guardian` and needs no key. For a local real-model run, generate a key from [Models.corp Sandbox API Access](https://redhathub.service-now.com/hub?id=sc_cat_item&sys_id=882ad1b71bebd610b6ccea45624bcb3d&table=sc_cat_item&searchTerm=Models.corp%20Sandbox%20API%20Access) and put it in the shield YAML `api_key` (do not commit it). See [Granite Guardian: mock vs real](#granite-guardian-mock-ci-vs-real-model-local).

For more on test structure and commands, see the main project guide (`CLAUDE.md`) and `tests/e2e/features/steps/README.md`.
2 changes: 1 addition & 1 deletion tests/e2e/features/byok_pdf.feature
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@cfg_byok_pdf @skip-in-server-mode
@cfg_byok_pdf
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
Feature: BYOK PDF support tests

# Validates that a vector store built from a PDF by rag-content's `pdf`
Expand Down
22 changes: 2 additions & 20 deletions tests/e2e/features/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,10 +188,8 @@ def before_scenario(context: Context, scenario: Scenario) -> None:
resetting per-scenario Lightspeed override tracking and skip-restart flags.

Skips the scenario if it has the `skip` tag, if it has the `local` tag
while the test run is not in local mode, if it has `konflux-only` when
``E2E_KONFLUX_E2E`` is not ``1``, if it has `skip-in-library-mode` when
running in library mode, or if it has `skip-in-server-mode` when running
in server mode. Scenario-specific Lightspeed YAML is applied in the
while the test run is not in local mode, or if it has `konflux-only` when
``E2E_KONFLUX_E2E`` is not ``1``. Scenario-specific Lightspeed YAML is applied in the
feature files (``The service uses the ... configuration`` steps).
"""
if "skip" in scenario.effective_tags:
Expand All @@ -204,22 +202,6 @@ def before_scenario(context: Context, scenario: Scenario) -> None:
scenario.skip("Skipped outside Konflux (requires E2E_KONFLUX_E2E=1)")
return

# Skip scenarios that require separate OGX container in library mode
if context.is_library_mode and "skip-in-library-mode" in scenario.effective_tags:
scenario.skip("Skipped in library mode (no separate OGX container)")
return

# Skip scenarios that rely on a non-default BYOK store. Only library mode
# re-enriches the (in-process) OGX with the active config's byok_rag
# on restart; in server mode the external OGX keeps its startup
# config, so a feature-specific store would not be loaded.
if not context.is_library_mode and "skip-in-server-mode" in scenario.effective_tags:
scenario.skip(
"Skipped in server mode (feature-specific BYOK store is not loaded "
"into the external OGX service)"
)
return

# Skip scenarios that depend on services not deployed in Prow/OpenShift
# (e.g. mock-tls-inference, proxy sidecars only available in Docker Compose)
if is_prow_environment() and "skip-in-prow" in scenario.effective_tags:
Expand Down
1 change: 0 additions & 1 deletion tests/e2e/features/mcp_servers_api.feature
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ Feature: MCP Server Management API tests
Then The status code of the response is 422
And The body of the response contains scheme

@skip-in-library-mode
Scenario: Register and delete MCP server lifecycle
When I access REST API endpoint "mcp-servers" using HTTP POST method
"""
Expand Down
59 changes: 1 addition & 58 deletions tests/e2e/features/unified-mode-boot.feature
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ Feature: Unified mode configuration boot
And the Lightspeed stack configuration directory is "tests/e2e/configuration/unified-mode"


# --- library mode (@skip-in-server-mode) ---

@skip-in-server-mode @openai-only
@openai-only
Scenario: Unified config with inference.providers boots and serves requests in library mode
Given The service uses the lightspeed-stack-unified-providers.yaml configuration
And The service is restarted
Expand All @@ -31,7 +29,6 @@ Feature: Unified mode configuration boot
Then The status code of the response is 200


@skip-in-server-mode
Scenario: Unified config with ogx.config only boots and serves requests in library mode
Given The service uses the lightspeed-stack-unified-config-only.yaml configuration
And The service is restarted
Expand All @@ -44,69 +41,15 @@ Feature: Unified mode configuration boot
Then The status code of the response is 200


@skip-in-server-mode
Scenario: Unified config with relative profile path boots in library mode
Given The service uses the lightspeed-stack-unified-relative-profile.yaml configuration
And The service is restarted
When I access endpoint "readiness" using HTTP GET method
Then The status code of the response is 200


@skip-in-server-mode
Scenario: Unified config with absolute profile path boots in library mode
Given The service uses the lightspeed-stack-unified-absolute-profile.yaml configuration
And The service is restarted
When I access endpoint "readiness" using HTTP GET method
Then The status code of the response is 200


# --- server mode (@skip-in-library-mode) ---

@skip-in-library-mode @openai-only
Scenario: Unified config with inference.providers boots and serves requests in server mode
Given The service uses the lightspeed-stack-unified-providers.yaml configuration
And Lightspeed Stack is restarted
When I access endpoint "readiness" using HTTP GET method
Then The status code of the response is 200
And The body of the response has the following schema
"""
{
"ready": "bool",
"reason": "str",
"providers": "list[str]"
}
"""
When I use "query" to ask question
"""
{"query": "Say hello", "model": "{MODEL}", "provider": "{PROVIDER}"}
"""
Then The status code of the response is 200


@skip-in-library-mode
Scenario: Unified config with ogx.config only boots and serves requests in server mode
Given The service uses the lightspeed-stack-unified-config-only.yaml configuration
And Lightspeed Stack is restarted
When I access endpoint "readiness" using HTTP GET method
Then The status code of the response is 200
When I use "query" to ask question
"""
{"query": "Say hello", "model": "{MODEL}", "provider": "{PROVIDER}"}
"""
Then The status code of the response is 200


@skip-in-library-mode
Scenario: Unified config with relative profile path boots in server mode
Given The service uses the lightspeed-stack-unified-relative-profile.yaml configuration
And Lightspeed Stack is restarted
When I access endpoint "readiness" using HTTP GET method
Then The status code of the response is 200


@skip-in-library-mode
Scenario: Unified config with absolute profile path boots in server mode
Given The service uses the lightspeed-stack-unified-absolute-profile.yaml configuration
And Lightspeed Stack is restarted
When I access endpoint "readiness" using HTTP GET method
Then The status code of the response is 200
18 changes: 1 addition & 17 deletions tests/e2e/features/unified-mode-migration.feature
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@ Feature: Legacy to unified configuration migration
# tests/e2e/configs/run-ci.yaml) and guarded against CLI drift by that same
# integration module. It inlines the openai run-ci.yaml, hence @openai-only.

# --- library mode (@skip-in-server-mode) ---

@skip-in-server-mode @openai-only
@openai-only
Scenario: Migrated unified configuration boots and serves queries in library mode
Given The service uses the lightspeed-stack-unified-migrated.yaml configuration
And The service is restarted
Expand All @@ -30,18 +29,3 @@ Feature: Legacy to unified configuration migration
{"query": "Say hello", "model": "{MODEL}", "provider": "{PROVIDER}"}
"""
Then The status code of the response is 200


# --- server mode (@skip-in-library-mode) ---

@skip-in-library-mode @openai-only
Scenario: Migrated unified configuration boots and serves queries in server mode
Given The service uses the lightspeed-stack-unified-migrated.yaml configuration
And Lightspeed Stack is restarted
When I access endpoint "readiness" using HTTP GET method
Then The status code of the response is 200
When I use "query" to ask question
"""
{"query": "Say hello", "model": "{MODEL}", "provider": "{PROVIDER}"}
"""
Then The status code of the response is 200
13 changes: 1 addition & 12 deletions tests/e2e/features/unified-mode-synthesis.feature
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,8 @@ Feature: Unified mode configuration synthesis
# is the one thing only a deployed stack can show: the synthesized path is
# logged at startup (R10).

# --- library mode (@skip-in-server-mode) ---

@skip-in-server-mode @openai-only
@openai-only
Scenario: Synthesized run.yaml path is logged at startup in library mode
Given The service uses the lightspeed-stack-unified-providers.yaml configuration
And The service is restarted
Then the lightspeed-stack container logs contain synthesized run.yaml


# --- server mode (@skip-in-library-mode) ---

@skip-in-library-mode @openai-only
Scenario: Synthesized run.yaml path is logged at startup in server mode
Given The service uses the lightspeed-stack-unified-providers.yaml configuration
And Lightspeed Stack is restarted
Then the lightspeed-stack container logs contain synthesized run.yaml
Loading