Skip to content

Commit 94f1c37

Browse files
are-cesclaude
andcommitted
LCORE-1422: Replace @InlineRAG magic tag with explicit Background step
Replace the implicit @InlineRAG feature tag (handled in environment.py hooks) with a parameterized Background step "The service uses the {config_name} configuration" that switches config and restarts the container. The step is reusable for any config file and idempotent within a feature run via backup file existence check. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 4fc705b commit 94f1c37

3 files changed

Lines changed: 39 additions & 13 deletions

File tree

tests/e2e/features/environment.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -439,12 +439,6 @@ def before_feature(context: Context, feature: Feature) -> None:
439439
switch_config(context.feature_config)
440440
restart_container("lightspeed-stack")
441441

442-
if "InlineRAG" in feature.tags:
443-
context.feature_config = _get_config_path("inline-rag", mode_dir)
444-
context.default_config_backup = create_config_backup("lightspeed-stack.yaml")
445-
switch_config(context.feature_config)
446-
restart_container("lightspeed-stack")
447-
448442
if "MCPFileAuth" in feature.tags:
449443
context.feature_config = _get_config_path("mcp-file-auth", mode_dir)
450444
context.default_config_backup = create_config_backup("lightspeed-stack.yaml")
@@ -479,11 +473,6 @@ def after_feature(context: Context, feature: Feature) -> None:
479473
response = requests.delete(url, timeout=10)
480474
assert response.status_code == 200, f"{url} returned {response.status_code}"
481475

482-
if "InlineRAG" in feature.tags:
483-
switch_config(context.default_config_backup)
484-
restart_container("lightspeed-stack")
485-
remove_config_backup(context.default_config_backup)
486-
487476
if "MCP" in feature.tags:
488477
switch_config(context.default_config_backup)
489478
restart_container("lightspeed-stack")

tests/e2e/features/inline_rag.feature

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
@InlineRAG
21
Feature: Inline RAG (BYOK) support tests
32

43
Background:
54
Given The service is started locally
65
And REST API service prefix is /v1
6+
And The service uses the lightspeed-stack-inline-rag.yaml configuration
77

88
Scenario: Check if inline RAG source is registered
99
Given The system is in default state

tests/e2e/features/steps/common.py

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,17 @@
11
"""Implementation of common test steps."""
22

3+
import os
4+
35
from behave import given # pyright: ignore[reportAttributeAccessIssue]
46
from behave.runner import Context
5-
import os
7+
8+
from tests.e2e.utils.utils import (
9+
create_config_backup,
10+
is_prow_environment,
11+
restart_container,
12+
switch_config,
13+
wait_for_container_health,
14+
)
615

716

817
@given("The service is started locally")
@@ -22,6 +31,34 @@ def service_is_started_locally(context: Context) -> None:
2231
context.port_llama = os.getenv("E2E_LLAMA_PORT", "8321")
2332

2433

34+
@given("The service uses the {config_name} configuration") # type: ignore
35+
def configure_service(context: Context, config_name: str) -> None:
36+
"""Switch to the given configuration if not already active.
37+
38+
On first call creates a backup of the current config, switches to the
39+
named config, and restarts the container. Subsequent calls within
40+
the same feature are no-ops (detected by backup file existence in Docker
41+
or backup key presence in Prow).
42+
43+
Parameters:
44+
context (Context): Behave context.
45+
config_name (str): Config filename (e.g. lightspeed-stack-inline-rag.yaml).
46+
"""
47+
if not is_prow_environment() and os.path.exists("lightspeed-stack.yaml.backup"):
48+
return
49+
50+
mode_dir = "library-mode" if context.is_library_mode else "server-mode"
51+
if is_prow_environment():
52+
config_path = f"tests/e2e-prow/rhoai/configs/{config_name}"
53+
else:
54+
config_path = f"tests/e2e/configuration/{mode_dir}/{config_name}"
55+
create_config_backup("lightspeed-stack.yaml")
56+
switch_config(config_path)
57+
restart_container("lightspeed-stack")
58+
# Library mode needs extra time to load embedding models after restart
59+
wait_for_container_health("lightspeed-stack", max_attempts=12)
60+
61+
2562
@given("The system is in default state")
2663
def system_in_default_state(context: Context) -> None:
2764
"""Check the default system state.

0 commit comments

Comments
 (0)