fix: detect docker/server mode in telemetry tests to properly disable Gunicorn

The telemetry fixture was only checking LLAMA_STACK_TEST_STACK_CONFIG_TYPE
environment variable, which defaults to 'library_client'. In CI, tests run
with --stack-config=docker:ci-tests, which wasn't being detected as server mode.

This commit checks the --stack-config argument and treats both 'server:' and
'docker:' prefixes as server mode, ensuring LLAMA_STACK_DISABLE_GUNICORN is
set when needed for telemetry span collection.
This commit is contained in:
Roy Belio 2025-10-30 18:52:31 +02:00
parent 3e1d0060c1
commit c8f82cad6a

View file

@ -17,8 +17,17 @@ from tests.integration.telemetry.collectors import InMemoryTelemetryManager, Otl
@pytest.fixture(scope="session") @pytest.fixture(scope="session")
def telemetry_test_collector(): def telemetry_test_collector(request):
stack_mode = os.environ.get("LLAMA_STACK_TEST_STACK_CONFIG_TYPE", "library_client") # Determine stack mode from --stack-config argument
stack_config = request.session.config.getoption("--stack-config", default=None)
if not stack_config:
stack_config = os.environ.get("LLAMA_STACK_CONFIG", "")
# Check if running in server or docker mode (both need server-side telemetry)
if stack_config.startswith("server:") or stack_config.startswith("docker:"):
stack_mode = "server"
else:
stack_mode = os.environ.get("LLAMA_STACK_TEST_STACK_CONFIG_TYPE", "library_client")
if stack_mode == "server": if stack_mode == "server":
try: try: