49 lines
2.4 KiB
Plaintext
49 lines
2.4 KiB
Plaintext
Container mtusi-lab7-student-tests-run-54f28d9aaf76 Creating
|
|
Container mtusi-lab7-student-tests-run-54f28d9aaf76 Created
|
|
F [100%]
|
|
=================================== FAILURES ===================================
|
|
____________ test_slow_cache_dns_does_not_delay_authorized_profile _____________
|
|
|
|
client = <starlette.testclient.TestClient object at 0xffff860d6510>
|
|
monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0xffff85f49480>
|
|
|
|
def test_slow_cache_dns_does_not_delay_authorized_profile(client, monkeypatch):
|
|
"""Cache socket timeouts must not let a stalled resolver hold the profile API."""
|
|
import socket
|
|
import threading
|
|
account, body = user(client)
|
|
headers, _ = login(client, body)
|
|
client.app.state.db.cache.connection_pool.disconnect()
|
|
original = socket.getaddrinfo
|
|
release = threading.Event()
|
|
entered = threading.Event()
|
|
|
|
def slow_cache_dns(host, *args, **kwargs):
|
|
if host == 'redis':
|
|
entered.set()
|
|
release.wait(2)
|
|
return original(host, *args, **kwargs)
|
|
|
|
monkeypatch.setattr(socket, 'getaddrinfo', slow_cache_dns)
|
|
try:
|
|
start = time.monotonic()
|
|
response = client.get('/api/v1/users/me', headers=headers)
|
|
elapsed = time.monotonic() - start
|
|
assert response.status_code == 200 and response.json() == account
|
|
assert entered.is_set(), 'The cache resolver fault was not exercised'
|
|
> assert elapsed < 1, f'Optional cache stalled the profile for {elapsed:.3f}s'
|
|
E AssertionError: Optional cache stalled the profile for 2.031s
|
|
E assert 2.0308806670000195 < 1
|
|
|
|
student-tests/test_api.py:168: AssertionError
|
|
=============================== warnings summary ===============================
|
|
../usr/local/lib/python3.13/site-packages/fastapi/testclient.py:1
|
|
/usr/local/lib/python3.13/site-packages/fastapi/testclient.py:1: StarletteDeprecationWarning: Using `httpx` with `starlette.testclient` is deprecated; install `httpx2` instead.
|
|
from starlette.testclient import TestClient as TestClient # noqa
|
|
|
|
-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
|
|
=========================== short test summary info ============================
|
|
FAILED student-tests/test_api.py::test_slow_cache_dns_does_not_delay_authorized_profile
|
|
1 failed, 1 warning in 2.48s
|
|
|