Test that recorder is not promoted to earlier stage in bootstrap (#142695)

Test that recorder is not promoted to earlier stage
pull/145682/head
Artur Pragacz 2025-05-27 08:23:39 +02:00 committed by GitHub
parent b36b591ccf
commit 6fc064fa6a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 33 additions and 2 deletions

View File

@ -171,8 +171,6 @@ FRONTEND_INTEGRATIONS = {
# Stage 0 is divided into substages. Each substage has a name, a set of integrations and a timeout.
# The substage containing recorder should have no timeout, as it could cancel a database migration.
# Recorder freezes "recorder" timeout during a migration, but it does not freeze other timeouts.
# The substages preceding it should also have no timeout, until we ensure that the recorder
# is not accidentally promoted as a dependency of any of the integrations in them.
# If we add timeouts to the frontend substages, we should make sure they don't apply in recovery mode.
STAGE_0_INTEGRATIONS = (
# Load logging and http deps as soon as possible

View File

@ -1618,3 +1618,36 @@ async def test_no_base_platforms_loaded_before_recorder(hass: HomeAssistant) ->
assert not problems, (
f"Integrations that are setup before recorder implement base platforms: {problems}"
)
async def test_recorder_not_promoted(hass: HomeAssistant) -> None:
"""Verify that recorder is not promoted to earlier than its own stage."""
integrations_before_recorder: set[str] = set()
for _, integrations, _ in bootstrap.STAGE_0_INTEGRATIONS:
if "recorder" in integrations:
break
integrations_before_recorder |= integrations
else:
pytest.fail("recorder not in stage 0")
integrations_or_excs = await loader.async_get_integrations(
hass, integrations_before_recorder
)
integrations: dict[str, Integration] = {}
for domain, integration in integrations_or_excs.items():
assert not isinstance(integrations_or_excs, Exception)
integrations[domain] = integration
integrations_all_dependencies = (
await loader.resolve_integrations_after_dependencies(
hass, integrations.values(), ignore_exceptions=True
)
)
all_integrations = integrations.copy()
all_integrations.update(
(domain, loader.async_get_loaded_integration(hass, domain))
for domains in integrations_all_dependencies.values()
for domain in domains
)
assert "recorder" not in all_integrations