Compare commits

...

1 Commits

Author SHA1 Message Date
Stefan Agner
6e6d0d3700 Skip system-checks fan-out in test_events_on_issue_changes
The test asserts that apply_suggestion fires an ISSUE_REMOVED event.
ISSUE_REMOVED is fired by dismiss_issue inside FixupBase.__call__, before
apply_suggestion calls healthcheck. The healthcheck call afterwards is
incidental to this test's intent, but it fans out into check_system()
which runs CheckDNSServer (A and AAAA) - real aiodns query_dns() probes
against the NetworkManager mock's stub nameserver 192.168.30.1 that each
hit the default ~10 s aiodns timeout. The file took ~21 s to run.

The slowness has been latent since #3818 (Aug 2022), which added the
apply_suggestion step at the end of test_events_on_issue_changes two
days after the DNS check landed in its current form (#3811). The default
24 h JobThrottle on CheckDNSServer.run_check tends to mask the cost in
full-suite runs once any earlier test has tripped the throttle, which is
likely why this slipped through.

Mock coresys.resolution.healthcheck for just this one apply_suggestion
call rather than introducing a file-wide DNS mock. The patch is local to
the slow call site and the test's assertion is unaffected. The file
drops from ~21 s to ~2.5 s.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-27 19:47:43 +02:00

View File

@@ -273,9 +273,15 @@ async def test_events_on_issue_changes(
"issue_changed", issue_expected | {"suggestions": [suggestion_expected]}
) in [call.args[0] for call in ha_ws_client.async_send_command.call_args_list]
# Applying a suggestion should only fire an issue removed event
# Applying a suggestion should only fire an issue removed event.
# Mock healthcheck to avoid running the system-checks fan-out, which is
# not relevant to this assertion (ISSUE_REMOVED is fired by dismiss_issue
# inside the fixup, before apply_suggestion calls healthcheck).
ha_ws_client.async_send_command.reset_mock()
with patch("shutil.disk_usage", return_value=(42, 42, 2 * (1024.0**3))):
with (
patch("shutil.disk_usage", return_value=(42, 42, 2 * (1024.0**3))),
patch.object(coresys.resolution, "healthcheck", new_callable=AsyncMock),
):
await coresys.resolution.apply_suggestion(suggestion)
await asyncio.sleep(0)