Repository navigation
Freeze the mDNS clock in the cache TTL tests - #3014
Conversation
|
ESPHome Bot (@esphbot) review |
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are recorded for the test-only changes making cache age and remaining-TTL assertions deterministic.
No open issues 🎉
What changed in this PR
This test-only change makes mDNS cache age and remaining-TTL assertions deterministic, preventing elapsed time on slow runners from causing failures. Production behavior is unchanged.
Changes:
- Capture one timestamp per test and freeze the helper’s clock at that value.
- Replace tolerance-based assertions with exact checks in three cache tests.
| File | Description |
|---|---|
tests/test_state_monitor_reachability.py |
Adds a shared clock patch target and deterministic age/TTL assertions. |
Review effort: Balanced
|
|
ESPHome Bot (esphbot)
left a comment
There was a problem hiding this comment.
Tip
No blocking issues found — ready to merge.
Merging this PR will not alter performance
Comparing Footnotes
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3014 +/- ##
=======================================
Coverage 99.76% 99.76%
=======================================
Files 300 300
Lines 26388 26388
=======================================
Hits 26326 26326
Misses 62 62
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
|
Addressed in 60d6a80.
ESPHome Bot (@esphbot) review |
Checked at 60d6a80. All five anchors use |
PR Review — Freeze the mDNS clock in the cache TTL testsMerge-ready. Both points from the last review are fixed in 60d6a80, and I found no new issues. What works well:
No outstanding issues. ✅ Resolved since last review (1)Previously-flagged issues verified fixed
Checklist
Automated review by Kōan (Claude) |
ESPHome Bot (esphbot)
left a comment
There was a problem hiding this comment.
Tip
No blocking issues found — ready to merge.
What does this implement/fix?
Make the mDNS cache TTL tests deterministic by freezing the clock the helper reads, so a slow runner can no longer push the remaining TTL outside the old 0.5 s tolerance (it failed esphome/esphome#22288's downstream job with
39.437 == 40.0 ± 0.5).tests/test_state_monitor_reachability.py(get_mdns_a_record_ttl_remainingmin-across-A/AAAA, and the twoget_mdns_cache_infoage/TTL tests) become exact.Related issue or feature (if applicable):
Types of changes
bugfixnew-featureenhancementbreaking-changerefactordocsmaintenancecidependenciesFrontend coordination
Checklist
ruff,codespell, yaml/json/python checks).tests/where applicable.components.index.json/definitions/components/*.jsonhave not been hand-edited (regenerate viascript/sync_components.pyif a sync is needed).docs/ARCHITECTURE.mdand/ordocs/API.md.