Files
supervisor/tests
b63b43da78 Fix flaky test_adjust_system_datetime_if_time_behind (#7061)
The test started the _adjust_system_datetime() task and used a fixed
asyncio.sleep(0.1) before emitting the systemd-timesyncd PropertiesChanged
signal that wait_for_active_state() waits on. On a busy CI runner the task
could still be short of installing its D-Bus signal subscription when the
signal fired, so the signal was broadcast to no subscriber and lost.
wait_for_signal() then blocked until the 10s pytest-timeout killed it.

Replace the sleep with a deterministic handshake: the SystemdUnit mock now
exposes an active_state_read Event, set whenever ActiveState is queried.
Inside wait_for_active_state() that read happens only after the
PropertiesChanged subscription is installed, so awaiting the Event before
emitting guarantees the signal cannot be missed.

Verified under full CPU load: the old sleep-based sync point timed out 10/10,
the Event-based version passed 30/30.

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-29 16:17:15 +02:00
..