oliver-zehentleitner / maity

hub tests: one statement counter (the PRAGMA rule in tests/statements.py) and the list-row tests' shared fixtures in list_rows.py

Sign in to report

tsk-nx6k6yph7ep3 Proposed

Audit round 4 (tsk-hgnbapyw7hnh), read at 0a1b832e. Kind: duplication.

What is wrong

  • tests/list_rows.same_for_3_and_30 counts statements with its own listener (hub/tests/list_rows.py:93-107) because it must skip SQLite's PRAGMA query_only that db.read_transaction switches on a pooled connection. tests/statements.count_statements (hub/tests/statements.py:71-80), which test_view_batching, the request, bell, chat and memory tests and test_stars.py use, counts the PRAGMA. The flake the comment in list_rows.py describes can hit those tests too.
  • Two more private counters of the same kind: _statements in hub/tests/test_load_card_paging.py:40-48 and hub/tests/test_load_overview.py:50-56 (identical, with identical _peak_kib at 52-60 and 60-68).
  • The five new list-row test files repeat helpers: the owner fixture (test_list_rows_account.py:24-28, test_list_rows_project.py:43-47), _project_id (test_list_rows_account.py:31-36, test_list_rows_project.py:50-53), and _under (test_list_rows_account.py:318-326) vs _keyed (test_list_rows_project.py:519-528), which is _under with one key.

Proposal

  • Move the PRAGMA skip into statements.count_statements (or a flag on it) and let same_for_3_and_30 and the two load tests call it; one _peak_kib helper next to it.
  • Put owner, _project_id and rows_under(*keys) into tests/list_rows.py (or the conftest) and drop the copies.

Effort / risk: S. Low; test code only. Check that the older count-based tests keep their numbers on PostgreSQL and MariaDB (no PRAGMA there).