Add CI job which runs recorder tests on PostgreSQL (#80614)
Co-authored-by: Franck Nijhof <git@frenck.dev> Co-authored-by: J. Nick Koston <nick@koston.org>
This commit is contained in:
parent
3a83b2f66f
commit
720f51657d
10 changed files with 187 additions and 41 deletions
|
@ -16,7 +16,10 @@ from homeassistant.components import recorder
|
|||
from homeassistant.components.recorder import history, util
|
||||
from homeassistant.components.recorder.const import DOMAIN, SQLITE_URL_PREFIX
|
||||
from homeassistant.components.recorder.db_schema import RecorderRuns
|
||||
from homeassistant.components.recorder.models import UnsupportedDialect
|
||||
from homeassistant.components.recorder.models import (
|
||||
UnsupportedDialect,
|
||||
process_timestamp,
|
||||
)
|
||||
from homeassistant.components.recorder.util import (
|
||||
end_incomplete_runs,
|
||||
is_second_sunday,
|
||||
|
@ -44,8 +47,8 @@ def test_session_scope_not_setup(hass_recorder):
|
|||
|
||||
def test_recorder_bad_commit(hass_recorder, recorder_db_url):
|
||||
"""Bad _commit should retry 3 times."""
|
||||
if recorder_db_url.startswith("mysql://"):
|
||||
# This test is specific for SQLite: mysql does not raise an OperationalError
|
||||
if recorder_db_url.startswith(("mysql://", "postgresql://")):
|
||||
# This test is specific for SQLite: mysql/postgresql does not raise an OperationalError
|
||||
# which triggers retries for the bad query below, it raises ProgrammingError
|
||||
# on which we give up
|
||||
return
|
||||
|
@ -696,7 +699,7 @@ async def test_no_issue_for_mariadb_with_MDEV_25020(hass, caplog, mysql_version)
|
|||
|
||||
def test_basic_sanity_check(hass_recorder, recorder_db_url):
|
||||
"""Test the basic sanity checks with a missing table."""
|
||||
if recorder_db_url.startswith("mysql://"):
|
||||
if recorder_db_url.startswith(("mysql://", "postgresql://")):
|
||||
# This test is specific for SQLite
|
||||
return
|
||||
|
||||
|
@ -714,7 +717,7 @@ def test_basic_sanity_check(hass_recorder, recorder_db_url):
|
|||
|
||||
def test_combined_checks(hass_recorder, caplog, recorder_db_url):
|
||||
"""Run Checks on the open database."""
|
||||
if recorder_db_url.startswith("mysql://"):
|
||||
if recorder_db_url.startswith(("mysql://", "postgresql://")):
|
||||
# This test is specific for SQLite
|
||||
return
|
||||
|
||||
|
@ -780,24 +783,23 @@ def test_end_incomplete_runs(hass_recorder, caplog):
|
|||
assert run_info.closed_incorrect is False
|
||||
|
||||
now = dt_util.utcnow()
|
||||
now_without_tz = now.replace(tzinfo=None)
|
||||
end_incomplete_runs(session, now)
|
||||
run_info = run_information_with_session(session)
|
||||
assert run_info.closed_incorrect is True
|
||||
assert run_info.end == now_without_tz
|
||||
assert process_timestamp(run_info.end) == now
|
||||
session.flush()
|
||||
|
||||
later = dt_util.utcnow()
|
||||
end_incomplete_runs(session, later)
|
||||
run_info = run_information_with_session(session)
|
||||
assert run_info.end == now_without_tz
|
||||
assert process_timestamp(run_info.end) == now
|
||||
|
||||
assert "Ended unfinished session" in caplog.text
|
||||
|
||||
|
||||
def test_periodic_db_cleanups(hass_recorder, recorder_db_url):
|
||||
"""Test periodic db cleanups."""
|
||||
if recorder_db_url.startswith("mysql://"):
|
||||
if recorder_db_url.startswith(("mysql://", "postgresql://")):
|
||||
# This test is specific for SQLite
|
||||
return
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue