fix(tests): ensure test isolation in server mode (#3737)

Propagate test IDs from client to server via HTTP headers to maintain
proper test isolation when running with server-based stack configs.
Without
this, recorded/replayed inference requests in server mode would leak
across
tests.

Changes:
- Patch client _prepare_request to inject test ID into provider data
header
- Sync test context from provider data on server side before storage
operations
- Set LLAMA_STACK_TEST_STACK_CONFIG_TYPE env var based on stack config
- Configure console width for cleaner log output in CI
- Add SQLITE_STORE_DIR temp directory for test data isolation
This commit is contained in:
Ashwin Bharambe 2025-10-08 12:03:36 -07:00 committed by GitHub
parent 96886afaca
commit 79bed44b04
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
419 changed files with 106801 additions and 35909 deletions

View file

@ -35,6 +35,18 @@ def pytest_sessionstart(session):
if "LLAMA_STACK_TEST_INFERENCE_MODE" not in os.environ:
os.environ["LLAMA_STACK_TEST_INFERENCE_MODE"] = "replay"
stack_config = session.config.getoption("--stack-config", default=None)
if stack_config and stack_config.startswith("server:"):
os.environ["LLAMA_STACK_TEST_STACK_CONFIG_TYPE"] = "server"
logger.info(f"Test stack config type: server (stack_config={stack_config})")
else:
os.environ["LLAMA_STACK_TEST_STACK_CONFIG_TYPE"] = "library_client"
logger.info(f"Test stack config type: library_client (stack_config={stack_config})")
from llama_stack.testing.inference_recorder import patch_httpx_for_test_id
patch_httpx_for_test_id()
@pytest.fixture(autouse=True)
def _track_test_context(request):