Ensure frontend is available if integrations fail to start - Part 1 of 2 (#36093)
Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
This commit is contained in:
parent
9c45115468
commit
fbe7b4ddfa
13 changed files with 173 additions and 63 deletions
|
@ -201,6 +201,43 @@ async def test_setup_after_deps_not_present(hass, caplog):
|
|||
assert order == ["root", "second_dep"]
|
||||
|
||||
|
||||
async def test_setup_continues_if_blocked(hass, caplog):
|
||||
"""Test we continue after timeout if blocked."""
|
||||
caplog.set_level(logging.DEBUG)
|
||||
order = []
|
||||
|
||||
def gen_domain_setup(domain):
|
||||
async def async_setup(hass, config):
|
||||
order.append(domain)
|
||||
return True
|
||||
|
||||
return async_setup
|
||||
|
||||
mock_integration(
|
||||
hass, MockModule(domain="root", async_setup=gen_domain_setup("root"))
|
||||
)
|
||||
mock_integration(
|
||||
hass,
|
||||
MockModule(
|
||||
domain="second_dep",
|
||||
async_setup=gen_domain_setup("second_dep"),
|
||||
partial_manifest={"after_dependencies": ["first_dep"]},
|
||||
),
|
||||
)
|
||||
|
||||
with patch.object(bootstrap, "TIMEOUT_EVENT_BOOTSTRAP", 0):
|
||||
hass.async_create_task(asyncio.sleep(2))
|
||||
await bootstrap._async_set_up_integrations(
|
||||
hass, {"root": {}, "first_dep": {}, "second_dep": {}}
|
||||
)
|
||||
|
||||
assert "root" in hass.config.components
|
||||
assert "first_dep" not in hass.config.components
|
||||
assert "second_dep" in hass.config.components
|
||||
assert order == ["root", "second_dep"]
|
||||
assert "blocking Home Assistant from wrapping up" in caplog.text
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def mock_is_virtual_env():
|
||||
"""Mock enable logging."""
|
||||
|
@ -261,7 +298,9 @@ async def test_setup_hass(
|
|||
with patch(
|
||||
"homeassistant.config.async_hass_config_yaml",
|
||||
return_value={"browser": {}, "frontend": {}},
|
||||
), patch.object(bootstrap, "LOG_SLOW_STARTUP_INTERVAL", 5000):
|
||||
), patch.object(bootstrap, "LOG_SLOW_STARTUP_INTERVAL", 5000), patch(
|
||||
"homeassistant.components.http.start_http_server_and_save_config"
|
||||
):
|
||||
hass = await bootstrap.async_setup_hass(
|
||||
config_dir=get_test_config_dir(),
|
||||
verbose=verbose,
|
||||
|
@ -338,7 +377,7 @@ async def test_setup_hass_invalid_yaml(
|
|||
"""Test it works."""
|
||||
with patch(
|
||||
"homeassistant.config.async_hass_config_yaml", side_effect=HomeAssistantError
|
||||
):
|
||||
), patch("homeassistant.components.http.start_http_server_and_save_config"):
|
||||
hass = await bootstrap.async_setup_hass(
|
||||
config_dir=get_test_config_dir(),
|
||||
verbose=False,
|
||||
|
@ -391,7 +430,9 @@ async def test_setup_hass_safe_mode(
|
|||
hass.config_entries._async_schedule_save()
|
||||
await flush_store(hass.config_entries._store)
|
||||
|
||||
with patch("homeassistant.components.browser.setup") as browser_setup:
|
||||
with patch("homeassistant.components.browser.setup") as browser_setup, patch(
|
||||
"homeassistant.components.http.start_http_server_and_save_config"
|
||||
):
|
||||
hass = await bootstrap.async_setup_hass(
|
||||
config_dir=get_test_config_dir(),
|
||||
verbose=False,
|
||||
|
@ -421,7 +462,7 @@ async def test_setup_hass_invalid_core_config(
|
|||
with patch(
|
||||
"homeassistant.config.async_hass_config_yaml",
|
||||
return_value={"homeassistant": {"non-existing": 1}},
|
||||
):
|
||||
), patch("homeassistant.components.http.start_http_server_and_save_config"):
|
||||
hass = await bootstrap.async_setup_hass(
|
||||
config_dir=get_test_config_dir(),
|
||||
verbose=False,
|
||||
|
@ -451,7 +492,7 @@ async def test_setup_safe_mode_if_no_frontend(
|
|||
with patch(
|
||||
"homeassistant.config.async_hass_config_yaml",
|
||||
return_value={"map": {}, "person": {"invalid": True}},
|
||||
):
|
||||
), patch("homeassistant.components.http.start_http_server_and_save_config"):
|
||||
hass = await bootstrap.async_setup_hass(
|
||||
config_dir=get_test_config_dir(),
|
||||
verbose=verbose,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue