Skip to content

test: graceful-shutdown tests with delay=10.0 may cause CI timeout #480

@mvillmow

Description

@mvillmow

Problem

Three tests in tests/test_graceful_shutdown.py use SlowTaskClaimer(delay=10.0):

  • TestDrainTimeout.test_drain_timeout_returns_false (line 145)
  • TestDrainTimeout.test_drain_timeout_logs_warning (line 159)
  • TestNATSListenerShutdown.test_stop_called_even_when_drain_times_out (line 277)

Each creates an asyncio task that sleeps for 10 seconds, then cancels it. If the cancel+await doesn't fully suppress the dangling task in the current pytest-asyncio version (1.3.0), the event loop stays alive for up to 10s per test, totalling 30+ seconds of overhead — contributing to the CI Python Tests job exceeding its 10-minute timeout.

Recommended Fix

Replace delay=10.0 with delay=60.0 only if you want to simulate a truly unreachable timeout scenario, but use a asyncio.wait_for guard in the test itself. Or reduce to delay=5.0 and verify the cancel path works correctly.

Alternatively, install pytest-timeout and add per-test @pytest.mark.timeout(2) markers so these tests are killed quickly if they hang instead of causing the whole suite to time out.

Context

Discovered during investigation of Python Tests job hitting the 10-minute timeout-minutes gate in CI (PR #451). The primary cause was pytest.ini shadowing pyproject.toml (fixed in PR #451), but these tests remain a latent risk.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions