Skip to content

Commit

Permalink
chore(ci): Apply pytest-timeout to test_bgtask (#3226) (#3229)
Browse files Browse the repository at this point in the history
Co-authored-by: Joongi Kim <[email protected]>
  • Loading branch information
lablup-octodog and achimnol authored Dec 9, 2024
1 parent 3eb2c04 commit 1eb3424
Show file tree
Hide file tree
Showing 3 changed files with 440 additions and 268 deletions.
8 changes: 6 additions & 2 deletions tests/manager/api/test_bgtask.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
from ai.backend.manager.server import background_task_ctx, event_dispatcher_ctx, shared_config_ctx


@pytest.mark.timeout(60)
@pytest.mark.asyncio
async def test_background_task(etcd_fixture, create_app_and_client) -> None:
app, client = await create_app_and_client(
Expand Down Expand Up @@ -79,11 +80,13 @@ async def _mock_task(reporter):
assert done_handler_ctx["event_name"] == "bgtask_done"
assert done_handler_ctx["message"] == "hooray"
finally:
await redis_helper.execute(producer.redis_client, lambda r: r.flushdb())
await root_ctx.background_task_manager.shutdown()
await producer.close()
await dispatcher.close()
await redis_helper.execute(producer.redis_client, lambda r: r.flushdb())


@pytest.mark.timeout(60)
@pytest.mark.asyncio
async def test_background_task_fail(etcd_fixture, create_app_and_client) -> None:
app, client = await create_app_and_client(
Expand Down Expand Up @@ -119,6 +122,7 @@ async def _mock_task(reporter):
assert fail_handler_ctx["message"] is not None
assert "ZeroDivisionError" in fail_handler_ctx["message"]
finally:
await redis_helper.execute(producer.redis_client, lambda r: r.flushdb())
await root_ctx.background_task_manager.shutdown()
await producer.close()
await dispatcher.close()
await redis_helper.execute(producer.redis_client, lambda r: r.flushdb())
5 changes: 3 additions & 2 deletions tools/pytest-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ pytest-asyncio>=0.23.2
pytest-aiohttp>=1.0.5
pytest-cov>=4.1
pytest-custom_exit_code>=0.3.0
pytest-dependency>=0.5.1
pytest-mock>=3.12.0
pytest-dependency>=0.6.0
pytest-mock>=3.14.0
pytest-timeout>=2.3.1
aioresponses>=0.7.6
Loading

0 comments on commit 1eb3424

Please sign in to comment.