fix(tests): ensure test isolation in server mode

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 11:00:49 -07:00
parent bba9957edd
commit d5296a35f6
4 changed files with 219 additions and 106 deletions

View file

@ -124,12 +124,6 @@ echo ""
echo "Checking llama packages"
uv pip list | grep llama
# Check storage and memory before tests
echo "=== System Resources Before Tests ==="
free -h 2>/dev/null || echo "free command not available"
df -h
echo ""
# Set environment variables
export LLAMA_STACK_CLIENT_TIMEOUT=300
@ -144,6 +138,17 @@ echo "=== Applying Setup Environment Variables ==="
# the server needs this
export LLAMA_STACK_TEST_INFERENCE_MODE="$INFERENCE_MODE"
export SQLITE_STORE_DIR=$(mktemp -d)
echo "Setting SQLITE_STORE_DIR: $SQLITE_STORE_DIR"
# Determine stack config type for api_recorder test isolation
if [[ "$STACK_CONFIG" == server:* ]]; then
export LLAMA_STACK_TEST_STACK_CONFIG_TYPE="server"
echo "Setting stack config type: server"
else
export LLAMA_STACK_TEST_STACK_CONFIG_TYPE="library_client"
echo "Setting stack config type: library_client"
fi
SETUP_ENV=$(PYTHONPATH=$THIS_DIR/.. python "$THIS_DIR/get_setup_env.py" --suite "$TEST_SUITE" --setup "$TEST_SETUP" --format bash)
echo "Setting up environment variables:"
@ -186,6 +191,8 @@ if [[ "$STACK_CONFIG" == *"server:"* ]]; then
echo "Llama Stack Server is already running, skipping start"
else
echo "=== Starting Llama Stack Server ==="
# Set a reasonable log width for better readability in server.log
export LLAMA_STACK_LOG_WIDTH=120
nohup llama stack run ci-tests --image-type venv > server.log 2>&1 &
echo "Waiting for Llama Stack Server to start..."
@ -277,11 +284,5 @@ else
exit 1
fi
# Check storage and memory after tests
echo ""
echo "=== System Resources After Tests ==="
free -h 2>/dev/null || echo "free command not available"
df -h
echo ""
echo "=== Integration Tests Complete ==="