Skip to content

Commit deff5ab

Browse files
kingpanther13claude
andcommitted
test(e2e): remove #1389 cadence-measurement infra retired by this refactor
The #1389/#1398 work added an e2e test (``test_poll_cadence_measurement.py``) plus xdist plumbing in ``tests/src/e2e/conftest.py`` (``record_poll_cadence_measurement``, ``_POLL_CADENCE_MEASUREMENTS`` + xdist worker handoff, terminal-summary section) to empirically validate ``_POLL_CADENCE``'s p50/p99/worst percentiles. That test consumed the ``entity-registration-elapsed`` DEBUG log line emitted by ``_poll_for_automation_entity`` on each successful registration. This PR removes both ``_POLL_CADENCE`` and the elapsed-time instrumentation: the cadence loop is replaced by the WS event-driven discovery helper, which resolves sub-second on the happy path without any cadence tuning needed. The measurement test is therefore consuming a log signal that no longer exists — CI fail signature is "No 'entity-registration-elapsed' DEBUG records captured after 10 automation creations." Deletes: - ``tests/src/e2e/workflows/automation/test_poll_cadence_measurement.py`` (207 lines) — entire test file. The cadence tuple it validates is gone. - ``record_poll_cadence_measurement()`` + ``_POLL_CADENCE_MEASUREMENTS`` / ``_ALL_POLL_CADENCE_MEASUREMENTS`` + xdist worker handoff in ``pytest_sessionfinish`` / ``pytest_testnodedown`` + the ``#1389 _POLL_CADENCE measurement`` terminal section in ``pytest_terminal_summary``. Also updates the ``NOT_VERIFIED_WARNING_PREFIX`` comment in ``tools_config_automations.py`` from "exhausts ``_POLL_CADENCE``" to "exhausts its budget (``_POLL_BUDGET_S``)" and drops the test-file reference, since the test that consumed the export is gone. Per Patch76's #1406 review note: "the deletion wins" — extending that to the e2e measurement infra that consumed the deleted instrumentation. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 1381851 commit deff5ab

3 files changed

Lines changed: 4 additions & 250 deletions

File tree

src/ha_mcp/tools/tools_config_automations.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,10 @@
5656

5757
# Distinctive prefix of the soft-failure warning emitted by
5858
# ``ha_config_set_automation`` when ``_poll_for_automation_entity``
59-
# exhausts ``_POLL_CADENCE`` without matching the new automation.
60-
# Exported so tests (e.g. ``test_poll_cadence_measurement.py``) can
61-
# detect a missed registration without hard-coding the literal —
62-
# rewording the warning becomes a compile-time coupling rather than
63-
# a silent test drift.
59+
# exhausts its budget (``_POLL_BUDGET_S``) without resolving the new
60+
# automation's entity_id. Exported so future tests can detect a missed
61+
# registration without hard-coding the literal — rewording the warning
62+
# becomes a compile-time coupling rather than a silent test drift.
6463
NOT_VERIFIED_WARNING_PREFIX = (
6564
"Automation was submitted to Home Assistant but the entity was not found"
6665
)

tests/src/e2e/conftest.py

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -89,21 +89,6 @@
8989
_READINESS_TIMINGS: list[dict[str, Any]] = []
9090
_ALL_READINESS_TIMINGS: list[dict[str, Any]] = []
9191

92-
# Parallel channel for the #1389 ``_POLL_CADENCE`` measurement —
93-
# mirrors the xdist round-trip used by ``_READINESS_TIMINGS`` above.
94-
_POLL_CADENCE_MEASUREMENTS: list[dict[str, Any]] = []
95-
_ALL_POLL_CADENCE_MEASUREMENTS: list[dict[str, Any]] = []
96-
97-
98-
def record_poll_cadence_measurement(measurement: dict[str, Any]) -> None:
99-
"""Record a single #1389 measurement run from a test method.
100-
101-
See the call site in
102-
``workflows/automation/test_poll_cadence_measurement.py`` for the
103-
measurement dict shape — that file owns the schema.
104-
"""
105-
_POLL_CADENCE_MEASUREMENTS.append(measurement)
106-
10792

10893
def _log_readiness_timing(gate: str, elapsed_s: float, **extras: Any) -> None:
10994
"""Record a fixture-side readiness-gate timing data point.
@@ -193,8 +178,6 @@ def pytest_sessionfinish(session, exitstatus):
193178
workeroutput = getattr(session.config, "workeroutput", None)
194179
if workeroutput is not None and _READINESS_TIMINGS:
195180
workeroutput["readiness_timings"] = list(_READINESS_TIMINGS)
196-
if workeroutput is not None and _POLL_CADENCE_MEASUREMENTS:
197-
workeroutput["poll_cadence_measurements"] = list(_POLL_CADENCE_MEASUREMENTS)
198181

199182

200183
def pytest_testnodedown(node, error):
@@ -206,9 +189,6 @@ def pytest_testnodedown(node, error):
206189
"""
207190
workeroutput = getattr(node, "workeroutput", {})
208191
_ALL_READINESS_TIMINGS.extend(workeroutput.get("readiness_timings", []))
209-
_ALL_POLL_CADENCE_MEASUREMENTS.extend(
210-
workeroutput.get("poll_cadence_measurements", [])
211-
)
212192

213193

214194
def pytest_terminal_summary(terminalreporter, exitstatus, config):
@@ -251,24 +231,6 @@ def pytest_terminal_summary(terminalreporter, exitstatus, config):
251231
f"follow-up gate justified."
252232
)
253233

254-
# #1389 _POLL_CADENCE measurement section — same xdist-aware plumbing
255-
# as the readiness gates above. Falls back to the local list when running
256-
# without xdist (no ``pytest_testnodedown`` fires in that mode).
257-
poll_measurements = _ALL_POLL_CADENCE_MEASUREMENTS or _POLL_CADENCE_MEASUREMENTS
258-
if poll_measurements:
259-
terminalreporter.section("#1389 _POLL_CADENCE measurement")
260-
for m in poll_measurements:
261-
terminalreporter.write_line(
262-
f"[POLL_CADENCE_1389] N={m['n']}/{m.get('attempts', m['n'])} "
263-
f"p50={m['p50']:.1f}ms p90={m['p90']:.1f}ms "
264-
f"worst={m['worst']:.1f}ms "
265-
f"min={m['min']:.1f}ms max={m['max']:.1f}ms "
266-
f"not_verified={m['not_verified']} VERDICT={m['verdict']}"
267-
)
268-
terminalreporter.write_line(
269-
f"[POLL_CADENCE_1389] samples_ms={m['samples']}"
270-
)
271-
272234

273235
def _is_missing_column_or_table_error(exc: sqlite3.OperationalError) -> bool:
274236
"""Return True only for benign 'schema drift' errors (column/table missing).

tests/src/e2e/workflows/automation/test_poll_cadence_measurement.py

Lines changed: 0 additions & 207 deletions
This file was deleted.

0 commit comments

Comments
 (0)