Skip to content

Commit

Permalink
Merge pull request #1091 from nolar/fix-liveness-tests
Browse files Browse the repository at this point in the history
Satisfy aiohttp's deprecation of shutdown timeout kwargs
  • Loading branch information
nolar authored Jan 19, 2024
2 parents 290491a + 1b7f4e8 commit 3a23dde
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
4 changes: 2 additions & 2 deletions kopf/_core/engines/probing.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,10 @@ async def get_health(
app = aiohttp.web.Application()
app.add_routes([aiohttp.web.get(path, get_health)])

runner = aiohttp.web.AppRunner(app, handle_signals=False)
runner = aiohttp.web.AppRunner(app, handle_signals=False, shutdown_timeout=1.0)
await runner.setup()

site = aiohttp.web.TCPSite(runner, host, port, shutdown_timeout=1.0)
site = aiohttp.web.TCPSite(runner, host, port)
await site.start()

# Log with the actual URL: normalised, with hostname/port set.
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ pre-commit
pyngrok
pytest>=6.0.0
pytest-aiohttp
pytest-asyncio
pytest-asyncio<0.22 # until the "event_loop" deprecation is solved
pytest-cov
pytest-mock
pytest-timeout
Expand Down
4 changes: 3 additions & 1 deletion tests/test_liveness.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,10 @@ async def liveness_url(settings, liveness_registry, unused_tcp_port_factory):
)
)

# Generally there is no or minimal timeout, except if the runner/server raise on start up.
# In that case, escalate their error from the task instead of hanging here forever.
try:
await ready_flag.wait()
await asyncio.wait_for(ready_flag.wait(), timeout=1)
yield f'http://localhost:{port}/xyz'
finally:
server.cancel()
Expand Down

0 comments on commit 3a23dde

Please sign in to comment.