Fix recorder setup hanging if non live schema migration fails (#122207)
This commit is contained in:
parent
d1d2ce1270
commit
153b69c971
3 changed files with 37 additions and 7 deletions
|
@ -1394,6 +1394,8 @@ async def _async_init_recorder_component(
|
|||
hass: HomeAssistant,
|
||||
add_config: dict[str, Any] | None = None,
|
||||
db_url: str | None = None,
|
||||
*,
|
||||
expected_setup_result: bool,
|
||||
) -> None:
|
||||
"""Initialize the recorder asynchronously."""
|
||||
# pylint: disable-next=import-outside-toplevel
|
||||
|
@ -1408,10 +1410,13 @@ async def _async_init_recorder_component(
|
|||
with patch("homeassistant.components.recorder.ALLOW_IN_MEMORY_DB", True):
|
||||
if recorder.DOMAIN not in hass.data:
|
||||
recorder_helper.async_initialize_recorder(hass)
|
||||
assert await async_setup_component(
|
||||
hass, recorder.DOMAIN, {recorder.DOMAIN: config}
|
||||
setup_task = asyncio.ensure_future(
|
||||
async_setup_component(hass, recorder.DOMAIN, {recorder.DOMAIN: config})
|
||||
)
|
||||
assert recorder.DOMAIN in hass.config.components
|
||||
# Wait for recorder integration to setup
|
||||
setup_result = await setup_task
|
||||
assert setup_result == expected_setup_result
|
||||
assert (recorder.DOMAIN in hass.config.components) == expected_setup_result
|
||||
_LOGGER.info(
|
||||
"Test recorder successfully started, database location: %s",
|
||||
config[recorder.CONF_DB_URL],
|
||||
|
@ -1527,10 +1532,16 @@ async def async_test_recorder(
|
|||
hass: HomeAssistant,
|
||||
config: ConfigType | None = None,
|
||||
*,
|
||||
expected_setup_result: bool = True,
|
||||
wait_recorder: bool = True,
|
||||
) -> AsyncGenerator[recorder.Recorder]:
|
||||
"""Setup and return recorder instance.""" # noqa: D401
|
||||
await _async_init_recorder_component(hass, config, recorder_db_url)
|
||||
await _async_init_recorder_component(
|
||||
hass,
|
||||
config,
|
||||
recorder_db_url,
|
||||
expected_setup_result=expected_setup_result,
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
instance = hass.data[recorder.DATA_INSTANCE]
|
||||
# The recorder's worker is not started until Home Assistant is running
|
||||
|
@ -1557,12 +1568,18 @@ async def async_setup_recorder_instance(
|
|||
hass: HomeAssistant,
|
||||
config: ConfigType | None = None,
|
||||
*,
|
||||
expected_setup_result: bool = True,
|
||||
wait_recorder: bool = True,
|
||||
) -> AsyncGenerator[recorder.Recorder]:
|
||||
"""Set up and return recorder instance."""
|
||||
|
||||
return await stack.enter_async_context(
|
||||
async_test_recorder(hass, config, wait_recorder=wait_recorder)
|
||||
async_test_recorder(
|
||||
hass,
|
||||
config,
|
||||
expected_setup_result=expected_setup_result,
|
||||
wait_recorder=wait_recorder,
|
||||
)
|
||||
)
|
||||
|
||||
yield async_setup_recorder
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue