Skip to content

Run the live test suite on one event loop - #31

Open
shauneccles wants to merge 1 commit into
HarvsG:masterfrom
shauneccles:upstream/live-test-event-loop
Open

Run the live test suite on one event loop#31
shauneccles wants to merge 1 commit into
HarvsG:masterfrom
shauneccles:upstream/live-test-event-loop

Conversation

@shauneccles

Copy link
Copy Markdown

Problem

The live suite shares one module-level GLinet client (and therefore one aiohttp session), but with current pytest-asyncio (>= 0.26, tested on 1.4.0) the custom session-scoped event_loop fixture is silently ignored and every test gets its own function-scoped loop. The session binds to the first test's loop, so every subsequent test fails with RuntimeError: Event loop is closed — the live suite is unusable beyond test_router_reachable.

Fix

  • Mark the module with pytest.mark.asyncio(loop_scope="module") so all tests share one loop.
  • Remove the obsolete event_loop fixture and the per-test @pytest.mark.asyncio markers (they would override the module loop scope back to function scope).

Test-only change; no library code touched.

Tested on real hardware

GL-MT6000 (Flint 2), firmware 4.9.0, pytest 9.1.1 / pytest-asyncio 1.4.0, non-disruptive tests only (-k "not set_enabled and not wireguard_start and not wireguard_stop and not tailscale_start and not tailscale_stop and not reboot").

Before (master):

test_router_reachable PASSED
test_login FAILED                 RuntimeError: Event loop is closed
test_router_info FAILED           RuntimeError: Event loop is closed
... (all 14 remaining tests fail the same way)
================== 15 failed, 1 passed, 6 deselected in 1.06s ==================

After (this branch):

test_router_reachable PASSED
test_login PASSED
test_router_info PASSED
test_router_get_status PASSED
test_router_get_load PASSED
test_router_mac FAILED            (macclone disabled on this unit)
test_connected_clients PASSED
test_wifi_ifaces_get PASSED
test_connected_to_internet FAILED (fw 4.9 returns {'detected': 0} without 'ip')
test_ping FAILED                  (fw 4.9 ping of 0.0.0.1 returns truthy)
test_wireguard_client_list PASSED
test_wireguard_client_state FAILED (no WireGuard client configured on this unit)
test_tailscale_status FAILED      (tailscale configured but disconnected: status 0)
test_tailscale_connection PASSED
test_tailscale_configured PASSED
test_tailscale_get_config PASSED
================= 5 failed, 11 passed, 6 deselected in 26.41s ==================

The 5 remaining failures are pre-existing assertion mismatches that depend on device configuration/firmware (they fail identically on master once the loop issue is fixed) — happy to follow up on those separately if useful.

🤖 Generated with Claude Code

The module shares one GLinet client and one aiohttp session, but with
pytest-asyncio >= 0.26 the session-scoped event_loop fixture is ignored
and each test gets its own function-scoped loop, so every test after
the first fails with 'RuntimeError: Event loop is closed'. Mark the
module with loop_scope="module" and drop the obsolete fixture and the
now-redundant per-test markers.

Verified against a GL-MT6000 (firmware 4.9.0), logs in the PR.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@shauneccles

Copy link
Copy Markdown
Author

Friendly final ping on this one — it's been open a few months with the rest of my queue, so I'm doing a tidy-up pass. Since filing it, my fork has continued as the independent glinet4 project (https://github.com/glinet4/glinet4, on PyPI as glinet4), which has absorbed this change along with the later work, so I no longer need it merged for my own use. If you'd still like it for gli4py I'm happy to refresh it against master — otherwise I'll close it in a couple of weeks to keep your PR list tidy. Thanks again for the original library!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant