Skip to content

Commit

Permalink
HH-233062 up balancing_client
Browse files Browse the repository at this point in the history
  • Loading branch information
712u3 committed Oct 8, 2024
1 parent 84d98f7 commit c3d2800
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ lxml = '4.9.2'
pydantic = '^2.3.0'
tornado = '6.3.3'
orjson = '*'
http-client = {git = 'https://github.com/hhru/balancing-http-client.git', tag = '2.1.18'}
http-client = {git = 'https://github.com/hhru/balancing-http-client.git', tag = '2.1.19'}
python-consul2-hh = {git = 'https://github.com/hhru/python-consul2', tag = 'v0.2.10'}
opentelemetry-sdk = '1.25.0'
opentelemetry-api = '1.25.0'
Expand Down
32 changes: 32 additions & 0 deletions tests/test_http_client.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
import asyncio
import json

from frontik.handler import PageHandler, get_current_handler
from frontik.loggers import JSON_FORMATTER
from frontik.routing import plain_router
from frontik.testing import FrontikTestBase
from tests.instances import frontik_test_app


Expand Down Expand Up @@ -51,3 +58,28 @@ def test_http_client_method_future(self):
def test_http_raise_error(self):
response = frontik_test_app.get_page('http_client/raise_error')
assert 200 == response.status_code


@plain_router.get('/long_page', cls=PageHandler)
async def long_page() -> None:
await asyncio.sleep(1)


@plain_router.get('/long_request', cls=PageHandler)
async def long_request(handler: PageHandler = get_current_handler()) -> None:
await handler.get_url(handler.get_header('host'), '/long_page')


class TestRequestCancled(FrontikTestBase):
async def test_request_canceled(self, caplog):
caplog.handler.setFormatter(JSON_FORMATTER)
response = await self.fetch('/long_request', request_timeout=0.1)
await asyncio.sleep(2)

assert response.status_code == 599

for log_row in caplog.text.split('\n'):
if log_row == '':
continue
log_obj = json.loads(log_row)
assert log_obj.get('lvl') != 'ERROR', log_obj

0 comments on commit c3d2800

Please sign in to comment.