Skip to content

fix(tests): the nightly live tier seeds its rows in the database the stack runs on, and the job can finish (#4620) - #4788

Merged
pavshulin merged 1 commit into
devfrom
feature/4620-tier3-live-fixtures-postgres
Nov 27, 2026
Merged

pavshulin merged 1 commit into
devfrom
feature/4620-tier3-live-fixtures-postgres

Conversation

@pavshulin

Copy link
Copy Markdown
Contributor

Description

The nightly Tier 3 run on dev is red (#4620). The run of 2026-11-24 had 73 failing rows in the live tier, from seven causes. This PR fixes two of them.

1. Fixtures wrote to a SQLite file (52 of the 73).
Every compose file boots the stack on PostgreSQL since #4175. Four live-tier modules still seeded their rows by opening a SQLite file inside the backend container. On a PostgreSQL stack that file has no tables, so the fixtures failed with sqlite3.OperationalError: no such table: users and the tests never ran: 51 errors and 1 failure.

  • New tests/testing_utils/backend_db.py: one statement, sent as JSON on stdin to the backend container and run through the backend's own SQLAlchemy engine, so it lands in whichever database the stack booted on. Values are bound, never formatted into the script or the command line.
  • test_access_control.py, test_ops_clear_all.py, test_operator_queue.py, test_watchdog.py use it. Their assertions are unchanged.
  • The rows are real now, so the helper checks its target before writing: the API has to be local, and the default container has to publish the port of TRINITY_API_URL, or be named in TRINITY_BACKEND_CONTAINER. A second stack on the same machine is refused instead of written to.
  • The three fixtures that create a login now remove it also when their own setup fails.

2. The job could not finish.
Nights that completed took 39.5 to 44.8 minutes against timeout-minutes: 45. The job was cancelled at the limit on 5 of the last 10 nights, and a cancelled job writes no JUnit file, so those nights had no failure list. The limit is now 90; the arithmetic is in the workflow comment.

Also in this PR

  • tests/unit/test_4620_live_tier_db_seam.py: runs the helper's script against the real schema on SQLite and PostgreSQL, pins the transport and the target check, keeps raw SQLite reads of the stack's database out of the live tier, and bounds the job limit (90 to 120).
  • schema-parity.yml: the PostgreSQL tier also runs when the helper or its test changes. Without that, this PR's own CI would skip the PostgreSQL arm of the new test, and the next schema PR would run it for the first time. The workflow's header already names this limit; the two paths are the stated exception.

Not in this PR

  • The other five causes in dev-nightly red: Tier 3 failed on dev #4620: the placeholder model key (10 tests), a stale mock in test_cb_probe_execution_close.py (7), a 500 where 409 is expected in test_event_subscriptions.py (1), three assertions that no longer match the product, and an order-dependent unit test.
  • Four more modules have the same defect and are listed, shrink-only, in the new test: test_public_links.py, test_public_user_memory.py, test_slack_integration.py skip on a PostgreSQL stack (13 tests on 2026-11-24); test_whatsapp_integration.py is in the slow tier.
  • integration-nightly.yml runs the same suite twice per PR under the same 45-minute limit. On 2026-11-24 every leg that really ran was cancelled. It needs its own change (test_1896 holds that limit at 60 on purpose).

Two things a reviewer should know

  • The new limit reaches the scheduled night only once it is on main. A scheduled run takes the workflow file from the default branch. The test fixes take effect right after the merge to dev, because every job checks out dev. Until the next release cut the scheduled night keeps the 45-minute limit; a run started by hand from dev uses 90.
  • An error from the helper can repeat a bound value on PostgreSQL (the server echoes the statement and the conflicting key). The helper is for fixture data only and says so.

Related Issue

Refs #4620

No closing keyword on purpose. #4620 is the nightly's own tracking issue: dev-nightly.yml closes it on the first green night, and this PR fixes two of its seven causes.

Journey Impact

Journey Impact: none: test fixtures, a test helper and two CI workflow settings; no product code and no journey promise changes

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Testing

  • I have tested this locally
  • New tests added (if applicable)
  • All existing tests pass
  • Every new test executes the changed path

Live, on a fresh stack booted the way dev-nightly.yml boots it (PostgreSQL, placeholder model key):

Run Result
The four modules at the base commit 51 errors + 1 failure, no such table: users. The same 52 as the nightly.
The four modules with this change 93 passed, 21 skipped, 0 errors, 0 failures
The whole live selection with this change (-m "not slow" --ignore=unit) 16 failed, 1884 passed, 119 skipped, 7 errors, in 38:54

Compared test by test with the nightly of 2026-11-24: 52 went from red to pass, none went from pass to red, none went from red to skipped. The 21 that stay red are the five causes listed above.

Two of the 7 errors are mine, not the suite's: test_cli_admin_login.py and test_cli_profiles.py did not collect because my environment lacked pip install -e ./src/cli, which the nightly installs. The whole-selection run was made before the review corrections (target check, fixture cleanup); the four modules were rerun after them, which is the second row.

Unit:

  • tests/unit/test_4620_live_tier_db_seam.py: 17 passed on SQLite; 23 passed with TEST_POSTGRES_URL set to a postgres:16-alpine (6 on PostgreSQL). Passes in four shuffled orders.
  • The 82 unit files that read a workflow or the test kit: 1742 passed, 44 skipped.

"All existing tests pass" is left unticked: the full unit suite was not rerun for this change, which touches no product code.

Mutation: each of these, made in a scratch copy, turns test_4620_live_tier_db_seam.py red: one module back to raw SQLite; the helper's script not committing; the script opening another database; INSERT OR IGNORE back in a module; the job limit back to 45; the limit raised to 180; the port check removed; the local-target check removed; docker exec without -i; only the last output line read; a missing admin not reported; a named container ignored. With the fix reverted in the four modules, the live run above is the 51 errors + 1 failure.

Checklist

  • My code follows the project's style guidelines
  • I have updated the documentation (if applicable)
  • I have not committed any sensitive data (API keys, credentials, etc.)
  • My commits are signed off (git commit -s) — required for contributors outside the core team
  • If this PR was written with an AI assistant, I say so above, and I have read and can explain every line
  • I have added appropriate logging for new functionality

Written with Claude Code.

🤖 Generated with Claude Code

…stack runs on, and the job can finish (#4620)

Two of the seven causes behind the red Tier 3 night.

Fixtures wrote to a SQLite file. Every compose file boots the stack on
PostgreSQL since #4175. Four live-tier modules still seeded their rows by
opening a SQLite file inside the backend container, so the fixtures failed
with "no such table: users" and 52 tests never ran (51 errors, 1 failure, of
73 failing rows on 2026-11-24). tests/testing_utils/backend_db.py runs a
statement through the backend's own engine inside the container, so it lands
in whichever database the stack booted on. test_access_control,
test_ops_clear_all, test_operator_queue and test_watchdog now use it.

The rows are real now, so the helper checks its target: the API has to be
local, and the default container has to publish the port of TRINITY_API_URL
(or be named in TRINITY_BACKEND_CONTAINER). The three fixtures that create a
login remove it also when their setup fails.

The job could not finish. Nights that completed took 39.5 to 44.8 minutes
against a limit of 45, and the job was cancelled at the limit on 5 of 10
nights; a cancelled job writes no JUnit file. The limit is now 90.

tests/unit/test_4620_live_tier_db_seam.py runs the helper's script against a
real schema on SQLite and PostgreSQL, pins the transport and the target
check, keeps raw SQLite reads of the stack's database out of the live tier
(four modules still to move are listed, shrink-only), and bounds the limit.
schema-parity.yml runs its PostgreSQL tier when the helper or that test
changes.

Refs #4620

Co-Authored-By: Claude Fable 5.1 <[email protected]>
@github-actions

Copy link
Copy Markdown

⚠️ Nightly unit-suite found regressions when this PR is merged into dev (1 of 3 seeds).

Regression details (head_sha: `1ac8240f912aa50f2ac9c5fefc90f4f1251f018b`)

Seed 99999

Backend unit-suite regression diff

Per-XML totals

Side Path Total Pass Fail Error Skip
base junit-base-pr4788-99999.xml 44309 44203 4 0 102
head junit-head-pr4788-99999.xml 44326 44219 5 0 102

❌ New failures introduced by HEAD (1)

Tests failing under HEAD that did not fail under BASE in any seed:

  • [F] test_ent879_aauth_resource_route::test_resume_by_handle_polls_the_person_server_then_resends_the_stored_request

Legend: [F] = assertion failure, [E] = collection or fixture error.
Identity = (classname, name, kind); union taken across all input XMLs.

Reproduce locally: git merge dev && ( cd tests && python -m pytest unit/ -m "not slow" -p randomly --randomly-seed=99999 )

@obasilakis obasilakis left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/review + /validate-pr — APPROVE

Lane C (.github/workflows/ touched). Scope clean: two of the seven #4620 causes, the other five listed as out of scope.

Execution coverage

changed symbol / test file executed by live consumer verdict
backend_db.RUNNER / create_user / execute / rows / scalar / admin_user_id test_4620_live_tier_db_seam.py seam tests, against the real schema on SQLite (locally) and PostgreSQL (schema-parity arm) the four live-tier modules' fixtures ✅ executed
_backend_container target check test_a_second_stack_on_another_port_is_refused, ..._remote_target_..., ..._named_container_... (docker mocked) every _exec call ✅ executed
no-raw-sqlite3 scan + shrink-only ALLOWED itself CI 🛡 guard
timeout-minutes: 90 bound (90–120) test_the_nightly_live_job_limit_covers_a_measured_night_with_headroom dev-nightly.yml 🛡 guard

Mutations re-run here, on the PR head:

  • tests/test_watchdog.py reverted to base: test_no_live_tier_module_opens_the_stack_database_with_sqlite3 goes red.
  • Limit set back to 45: the limit test goes red.
  • Unmodified: 17 passed on SQLite.

Checks

  • Security greps (keys, emails, IPs, host paths, file modes): clean.
  • Values are bound parameters sent as JSON on stdin. None are formatted into the script. The old fixtures used f-string interpolation; this removes it.
  • users columns are all Text in tables.py, so the utc_now() ISO-Z binds match the column types on both backends.
  • Tier 1 green, including pytest (head), regression diff and schema-parity. journey-smoke green.

Informational (non-blocking)

  • I1 test_operator_queue.py and test_ops_clear_all.py: the finally teardown calls backend_db.execute without a guard. If setup failed because the target check refused, teardown raises the same RuntimeError again. The error is chained, so the cause stays visible, and nothing is written to the wrong stack. test_access_control.py wraps its delete in try/except. The difference is cosmetic.
  • I2 Refs #4620 with no closing keyword. This is deliberate and fine: the nightly closes its own issue. #4620 stays status-in-progress after merge, so set it by hand if you want it tracked.
  • I3 The 90-minute limit reaches the scheduled night only after the next release cut. The PR body states this.
  • I4 frontend-e2e was skipped. The diff has no UI surface, so it is not relevant.

@pavshulin
pavshulin merged commit 2daa1b5 into dev Nov 27, 2026
26 of 44 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants