521 Commits

Author SHA1 Message Date
Erik Montnemery
9970b7eece
Refactor recorder data migration (#121009)
* Refactor recorder data migration

* Fix stale docstrings

* Don't store a session object in BaseRunTimeMigration instances

* Simplify logic in EntityIDMigration.migration_done

* Fix tests
2024-07-16 21:50:19 +02:00
Erik Montnemery
d8440e809a
Avoid mutating database schema definitions during schema migration (#122012)
* Avoid mutating database schema definitions during schema migration

* Adjust test when using mysql

* Address review comment
2024-07-16 20:27:49 +02:00
Erik Montnemery
336740dbfa
Add recorder migration test starting with schema version 9 (#122011) 2024-07-16 15:12:23 +02:00
J. Nick Koston
73f6e3c07b
Narrow sqlite database corruption check to ensure disk image is malformed (#121947)
* Narrow sqlite database corruption check to ensure disk image is malformed

The database corruption check would also replace the database when it
locked externally instead of only when its malformed.

This was discovered in https://github.com/home-assistant/core/issues/121909#issuecomment-2227409124
when a user did a manual index creation while HA was online

* tweak

* tweak

* fix

* fix
2024-07-14 23:23:07 +02:00
J. Nick Koston
19d2d023ab
Ensure states table rebuild still happens if the event_id index was removed (#121938)
* Ensure states table rebuild still happens if the event_id index was removed

If ix_states_event_id was removed by the foreign key still
exists, the states table would not get rebuilt. This should
not happen under normal circumstances and seems to only be
possible if the index was removed manually or Home
Assistant was restarted forcefully in the middle
of a previous migration from years ago.

* cover

* fix tests

* mysql wont allow at that point but thats ok as long as its gone at the end
2024-07-14 23:20:52 +02:00
J. Nick Koston
43596f22a4
Fix recorder max backlog calculation being too small (#121739) 2024-07-11 09:09:35 +02:00
J. Nick Koston
c81d5a1ac2
Handle empty entity_id in the recorder filter (#121681)
fixes #111745
2024-07-10 09:53:38 -05:00
epenet
bff663b3c1
Improve type hints in recorder result_processor (#121593) 2024-07-09 21:12:03 +02:00
J. Nick Koston
89ffee9ad5
Update ulid-transform to 0.10.1 (#121321) 2024-07-05 14:07:39 -05:00
Erik Montnemery
6eeb70151d
Use BIGINT SQL type for ID columns (#121025) 2024-07-05 10:42:39 -05:00
Erik Montnemery
e47cbf3cf7
Use async_setup_recorder_instance fixture in recorder v32_migration tests (#121081)
Co-authored-by: J. Nick Koston <nick@koston.org>
2024-07-04 17:49:51 -05:00
Erik Montnemery
6df15ad8fc
Drop use of async_setup_recorder_instance fixture in recorder purge tests (#121193) 2024-07-04 10:39:24 -05:00
Erik Montnemery
a1e6f8c2ec
Drop use of async_setup_recorder_instance fixture in recorder migration tests (#121196) 2024-07-04 10:39:13 -05:00
Erik Montnemery
f1d6ad9073
Add test fixture to control recorder migration (#121180)
* Add test fixture to control recorder migration

* Update tests/components/recorder/conftest.py

Co-authored-by: J. Nick Koston <nick@koston.org>

* Update tests/components/recorder/conftest.py

---------

Co-authored-by: J. Nick Koston <nick@koston.org>
2024-07-04 13:10:08 +02:00
Erik Montnemery
255778d0c7
Use recorder test fixtures in recorder init tests (#121176) 2024-07-04 04:54:40 -05:00
Erik Montnemery
d55d02623a
Add recorder test fixture to enable persistent SQLite database (#121137)
* Add recorder test fixture to enable persistent SQLite database

* Fix tests directly using async_test_home_assistant context manager
2024-07-04 09:59:37 +02:00
Erik Montnemery
cc2782edc7
Use async_test_recorder fixture in recorder auto_repairs tests (#121125) 2024-07-04 01:38:01 +02:00
Erik Montnemery
408e524551
Add recorder test fixture for skipping tests by DB engine (#121118)
* Add recorder test fixture for skipping tests by DB engine

* Fix mistake
2024-07-04 00:02:46 +02:00
Erik Montnemery
5029da6919
Make the async_setup_recorder_instance fixture a context manager (#121086) 2024-07-03 14:05:34 -05:00
J. Nick Koston
44c89e6c3b
Cleanup v32 recorder migration test (#121083) 2024-07-03 10:45:19 -05:00
Erik Montnemery
46a488d871
Use async_setup_recorder_instance fixture in recorder auto_repairs tests (#121077) 2024-07-03 17:04:39 +02:00
Erik Montnemery
87f7703f3c
Use async_setup_recorder_instance fixture in recorder migration tests (#121050) 2024-07-03 08:56:05 -05:00
Marc Mueller
f11b316dac
Import Generator from collections.abc (4) (#120917) 2024-07-01 11:54:42 +02:00
J. Nick Koston
c5804d362c
Remove legacy foreign key constraint from sqlite states table (#120779) 2024-06-29 07:50:53 -05:00
Joost Lekkerkerker
c13786c952
Fix ruff manual-dict-comprehension PERF403 in tests (#120738)
Fix PERF403 in tests
2024-06-28 12:14:24 +02:00
G Johansson
753ab08b5e
Add capability to exclude all attributes from recording (#119725) 2024-06-22 19:30:28 +02:00
epenet
83b97d3218
Add missing argument type hints to recorder tests (#119672) 2024-06-14 09:25:26 +02:00
epenet
2f5f372f63
Remove pointless TODO in recorder tests (#119490) 2024-06-12 18:08:01 +02:00
epenet
0f0c2f0553
Fix redefined-argument-from-local pylint warning in tests (#119475) 2024-06-12 17:58:58 +02:00
epenet
7388271689
Fix unspecified-encoding warnings in tests (#119405) 2024-06-11 17:58:40 +02:00
epenet
2c7022950c
Fix import-outside-toplevel pylint warnings in tests (#119389) 2024-06-11 14:57:50 +02:00
Erik Montnemery
def9d5b101
Fix statistic_during_period after core restart (#119323) 2024-06-10 21:44:55 +02:00
karwosts
aa419686cb
Fix statistic_during_period wrongly prioritizing ST statistics over LT (#115291)
* Fix statistic_during_period wrongly prioritizing ST statistics over LT

* comment

* start of a test

* more testcases

* fix sts insertion range

* update from review

* remove unneeded comments

* update logic

* min/mean/max testing
2024-06-10 20:23:21 +02:00
epenet
ac588ddc75
Use relative imports in tests [j-r] (#119282) 2024-06-10 13:32:31 +02:00
Sid
721b2c2ca8
Enable Ruff PT012 (#113957) 2024-06-08 17:59:08 +02:00
Marc Mueller
837ee7c4fb
Import Generator from typing_extensions (4) (#118992) 2024-06-06 17:41:37 +02:00
epenet
b54a68750b
Add type hints for FixtureRequest in tests (#118779) 2024-06-04 10:37:54 +02:00
J. Nick Koston
35a1ecea27
Speed up statistics_during_period websocket api (#118672) 2024-06-03 18:08:46 -05:00
epenet
8772a59f5c
Add type hints for Recorder in test fixtures (#118685) 2024-06-03 10:17:51 +02:00
J. Nick Koston
134088e1f6
Revert "Add websocket API to get list of recorded entities (#92640)" (#118644)
Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
2024-06-03 10:11:24 +02:00
epenet
1317837986
Improve type hints in tests (q-z) (#118381) 2024-05-30 08:48:02 +02:00
J. Nick Koston
0888233f06
Make Recorder dialect_name a cached_property (#117922) 2024-05-29 09:23:40 +02:00
Jan Bouwhuis
c616fc036e
Move recorder chunk utils to shared collection utils (#118065) 2024-05-24 12:49:39 -10:00
epenet
44f715bd02
Use issue_registry fixture in component tests (#118041) 2024-05-24 15:54:20 +02:00
J. Nick Koston
5a609c34bb
Fix blocking I/O in the event loop when loading timezones (#117721) 2024-05-20 11:06:03 +02:00
J. Nick Koston
3f053eddbd
Add websocket API to get list of recorded entities (#92640)
* Add API to get list of recorded entities

* update for latest codebase

* ruff

* Update homeassistant/components/recorder/websocket_api.py

* Update homeassistant/components/recorder/websocket_api.py

* Update homeassistant/components/recorder/websocket_api.py

* add suggested test
2024-05-15 08:41:56 +02:00
J. Nick Koston
d06932bbc2
Refactor asyncio loop protection to improve performance (#117295) 2024-05-13 07:01:55 +09:00
Sid
ac54cdcdb4
Enable Ruff RUF010 (#115371)
Co-authored-by: J. Nick Koston <nick@koston.org>
2024-05-08 23:54:49 +02:00
Erik Montnemery
1cea22b8ba
Fix search/replace mistake in recorder tests (#116933) 2024-05-06 09:03:21 -05:00
Erik Montnemery
2e945aed54
Convert recorder auto_repairs tests to use async API (#116927) 2024-05-06 08:25:48 -05:00