mirror of
https://github.com/meta-llama/llama-stack.git
synced 2025-10-25 17:11:12 +00:00
test: suppress expected error logs in SSE test (#3886)
Our unit test outputs are filled with all kinds of obscene logs. This makes it really hard to spot real issues quickly. The problem is that these logs are necessary to output at the given logging level when the server is operating normally. It's just that we don't want to see some of them (especially the noisy ones) during tests. This PR begins the cleanup. We pytest's caplog fixture to for suppression.
This commit is contained in:
parent
f8eaa40580
commit
7b90e0e9c8
5 changed files with 60 additions and 17 deletions
|
|
@ -4,6 +4,7 @@
|
|||
# This source code is licensed under the terms described in the LICENSE file in
|
||||
# the root directory of this source tree.
|
||||
|
||||
import logging # allow-direct-logging
|
||||
from uuid import uuid4
|
||||
|
||||
import pytest
|
||||
|
|
@ -17,6 +18,12 @@ from llama_stack.core.storage.datatypes import KVStoreReference, SqliteKVStoreCo
|
|||
from llama_stack.providers.utils.kvstore import register_kvstore_backends
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def suppress_quota_warnings(caplog):
|
||||
"""Suppress expected WARNING logs for SQLite backend and quota exceeded"""
|
||||
caplog.set_level(logging.CRITICAL, logger="llama_stack.core.server.quota")
|
||||
|
||||
|
||||
class InjectClientIDMiddleware(BaseHTTPMiddleware):
|
||||
"""
|
||||
Middleware that injects 'authenticated_client_id' to mimic AuthenticationMiddleware.
|
||||
|
|
@ -70,13 +77,13 @@ def auth_app(tmp_path, request):
|
|||
return app
|
||||
|
||||
|
||||
def test_authenticated_quota_allows_up_to_limit(auth_app):
|
||||
def test_authenticated_quota_allows_up_to_limit(auth_app, suppress_quota_warnings):
|
||||
client = TestClient(auth_app)
|
||||
assert client.get("/test").status_code == 200
|
||||
assert client.get("/test").status_code == 200
|
||||
|
||||
|
||||
def test_authenticated_quota_blocks_after_limit(auth_app):
|
||||
def test_authenticated_quota_blocks_after_limit(auth_app, suppress_quota_warnings):
|
||||
client = TestClient(auth_app)
|
||||
client.get("/test")
|
||||
client.get("/test")
|
||||
|
|
@ -85,7 +92,7 @@ def test_authenticated_quota_blocks_after_limit(auth_app):
|
|||
assert resp.json()["error"]["message"] == "Quota exceeded"
|
||||
|
||||
|
||||
def test_anonymous_quota_allows_up_to_limit(tmp_path, request):
|
||||
def test_anonymous_quota_allows_up_to_limit(tmp_path, request, suppress_quota_warnings):
|
||||
inner_app = FastAPI()
|
||||
|
||||
@inner_app.get("/test")
|
||||
|
|
@ -107,7 +114,7 @@ def test_anonymous_quota_allows_up_to_limit(tmp_path, request):
|
|||
assert client.get("/test").status_code == 200
|
||||
|
||||
|
||||
def test_anonymous_quota_blocks_after_limit(tmp_path, request):
|
||||
def test_anonymous_quota_blocks_after_limit(tmp_path, request, suppress_quota_warnings):
|
||||
inner_app = FastAPI()
|
||||
|
||||
@inner_app.get("/test")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue