Skip to content

test(suite) :: share helpers, close pools deterministically, slim OIDC harness - #1529

Queued
lovasoa wants to merge 7 commits into
mainfrom
codex/test-suite-cleanup
Queued

lovasoa wants to merge 7 commits into
mainfrom
codex/test-suite-cleanup

Conversation

@lovasoa

@lovasoa lovasoa commented Oct 6, 2026

Copy link
Copy Markdown
Collaborator

What

Cleans up the integration test suite while fixing the Oracle CI exit hang at its root cause. Net -39 LOC (696+/735-).

Why the Oracle job hangs (root cause)

  1. Every test request built with TestRequest::to_srv_request() leaks its Data<AppState>: actix-web recycles the HttpRequestInner allocation into a per-request pool on drop, and that pool is only drained by a real server — never on the test path. The leaked AppState pins its database pool (and pooled connections) until process exit. Pure actix-web behavior; reproduced standalone (every built request leaks its app_data, 10/10).
  2. The ODBC backend prepares and caches a native statement for every distinct parameterized query, so leaked pools hold native handles.
  3. Oracle's client deadlocks in finiSqora → bccFreeProcess when statements are outstanding at exit (verified: 1 leaked statement exits, 2 hang) — after all 89 tests pass.
  4. pool.close() alone is insufficient: it only closes idle connections, so a still-checked-out connection keeps its cached statements alive (verified: close-only hangs 2/2). The teardown acquires every connection, clears its statement cache, then closes — while the runtime is alive, including after panics.

What changed

  • tests/common: new TestSystem runner (pool registry + deterministic drain + panic safety + unit test), plus shared helpers (read_body_string, supports_database, make_app_data_with_env, unified request building).
  • All tests creating AppState run on TestSystem and funnel creation through the registry (including OIDC/core direct AppState::init sites).
  • OIDC: one config builder on top of test_config (no more hand-written JSON triplicates) + shared login-flow helpers.
  • requests/webhook/uploads/data_formats/errors/server_timing/cookies/core: shared request builders, table-driven 404s, shared AppState per test where trivially safe (fewer pools, fewer inits).
  • CI: forward extra args to test binaries; Oracle runs with --test-threads=2. CONTRIBUTING documents the pattern.

Validation

  • cargo fmt, cargo clippy --all-targets --all-features -- -D warnings: clean.
  • sqlite full suite: 88 passed, exit 0, ~8.2s (was ~9.5s).
  • Oracle full suite (odbc-static build, - -test-threads=2): 88 passed with clean exit, 3/3 runs (previously hung every run: all tests passed, then deadlock in bccFreeProcess).

Follow-up for upstream: actix-web issue about test-path HttpRequestPool recycling (draft ready); if fixed there, the per-test drain could eventually go away.

…C harness

Integration tests leaked every request's AppState: actix-web recycles
test-built HttpRequestInner allocations into a per-request pool that the
test path never drains, pinning database pools until process exit. Pooled
ODBC connections keep cached prepared statements alive, which deadlocks
Oracle's client at process exit. Close every test pool (clearing statement
caches first, since close() alone leaves checked-out connections behind)
while the test runtime is still alive, including after panics.

Consolidate the suite around shared helpers (read_body_string,
supports_database, request builders, OIDC login/config builders,
multipart/webhook request builders) and share one AppState per test
where possible, cutting duplication across oidc/uploads/requests/
data_formats/errors/server_timing/cookies/core. Net negative LOC.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 6, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-07T11:15:54.109025Z 7df0d5a New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 10c33b6131

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread tests/common/mod.rs Outdated
Give test requests an Actix service-owned pool so dropping the service releases application state. Centralize request setup with response_for, response_with, and helpers for custom requests and shared state, while keeping standard actix_web tests.

Cover state release on success, errors, and unwinding. Validate with the full Rust suite, all-feature Clippy, formatting, and the SQLite ODBC prepared-statement test.
Use create_app inside the shared request helper so existing concise test calls exercise production routes and middleware. Update the prefix redirect assertion to check the actual 308 response and preserved request path.
@lovasoa
lovasoa enabled auto-merge October 7, 2026 10:25
* refactor: centralize variable lookup and enumeration

* Reuse request and immutable-variable fixtures for lookup coverage
@lovasoa
lovasoa added this pull request to the merge queue Oct 7, 2026
Any commits made after this event will not be merged.
Merge the queued squash commit for PR #1535. Preserve its array and null-value assertions alongside PR #1529 production-app request helpers.
@lovasoa
lovasoa removed this pull request from the merge queue due to a manual request Oct 7, 2026
@lovasoa
lovasoa enabled auto-merge October 7, 2026 11:31
@lovasoa
lovasoa added this pull request to the merge queue Oct 7, 2026
Any commits made after this event will not be merged.
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to invalid changes in the merge commit Oct 7, 2026
@lovasoa
lovasoa added this pull request to the merge queue Oct 7, 2026
Any commits made after this event will not be merged.
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.

1 participant