Add MutexPool for recorder tests (#69410)

* Add MutexPool for recorder tests

* Fix get_schema_version

* Update test test_last_run_was_recently_clean

* Update test test_shutdown_before_startup_finishes

* Revert comments in test_write_lock_db

* Make the MutexPool lock a class variable

* Remove stale comment

* Move MutexPool

* Tweak debug prints
This commit is contained in:
Erik Montnemery
2022-04-12 19:41:46 +02:00
committed by GitHub
parent f8870c6364
commit eb3458a3d2
6 changed files with 360 additions and 166 deletions

View File

@@ -84,12 +84,18 @@ def _default_recorder(hass):
)
async def test_shutdown_before_startup_finishes(hass):
async def test_shutdown_before_startup_finishes(hass, tmp_path):
"""Test shutdown before recorder starts is clean."""
# On-disk database because this test does not play nice with the
# MutexPool
config = {
recorder.CONF_DB_URL: "sqlite:///" + str(tmp_path / "pytest.db"),
recorder.CONF_COMMIT_INTERVAL: 1,
}
hass.state = CoreState.not_running
await async_init_recorder_component(hass)
await async_init_recorder_component(hass, config)
await hass.data[DATA_INSTANCE].async_db_ready
await hass.async_block_till_done()