Skip to content

Run documents route tests against Postgres in CI so they cannot skip silently - #868

Merged
WaylandYang merged 1 commit into
devfrom
ci/documents-routes-against-postgres
Sep 23, 2026
Merged

WaylandYang merged 1 commit into
devfrom
ci/documents-routes-against-postgres

Conversation

@WaylandYang

Copy link
Copy Markdown
Contributor

Why

crates/utopia-server/src/api/documents_routes_tests.rs gates every test on utopia_store::test_db::url(). The backend job has no Postgres, so there they skip and report green; the migrations job (the one with Postgres) only ran the api::mcp::tests, api::chat:: and retrieval:: filters. Result: the documents route tests — including the five added by #860 (PAT scoping, purged → 410, ledger-referenced missing blob → 500) — never executed in CI. This is exactly the silent-skip failure mode called out in #248 and in the comments inside ci.yml.

What

One step added to the migrations job, modelled on the "Chat module against Postgres" step from #845:

- name: Documents routes against Postgres
  run: "cargo test -p utopia-server api::documents_routes::"
  env:
    UTOPIA_DATABASE_URL: postgres://utopia:utopia@localhost:5432/utopia
    UTOPIA_TEST_REQUIRE_DB: "1"

The workflow-level permissions: contents: read is untouched; no per-job permissions block added.

Verification

Filter matches the module declared via #[path = "documents_routes_tests.rs"] (cargo test -p utopia-server api::documents_routes:: -- --list):

api::documents_routes::tests::a_ledger_referenced_missing_blob_is_an_invariant_failure: test
api::documents_routes::tests::content_reads_keep_viewer_access_pat_scope_and_reject_source_tokens: test
api::documents_routes::tests::date_detection_keeps_upload_access_and_folder_checks: test
api::documents_routes::tests::deleted_bytes_stay_readable_and_purged_tombstones_answer_gone: test
api::documents_routes::tests::document_content_serves_the_current_and_recorded_versions: test
api::documents_routes::tests::each_upload_keeps_its_own_date_before_processing_and_extraction: test
api::documents_routes::tests::fallback_restore_and_other_ingest_dates_do_not_change: test
api::documents_routes::tests::header_decoding_is_bounded_and_never_accepts_a_truncated_line: test
api::documents_routes::tests::only_a_complete_opening_dateline_sets_the_date: test
api::documents_routes::tests::versions_ledger_names_what_content_can_serve: test

10 tests, 0 benchmarks

Local run against the docker compose Postgres (host port 1517, see #866) with UTOPIA_TEST_REQUIRE_DB=1:

running 10 tests
test api::documents_routes::tests::only_a_complete_opening_dateline_sets_the_date ... ok
test api::documents_routes::tests::header_decoding_is_bounded_and_never_accepts_a_truncated_line ... ok
test api::documents_routes::tests::date_detection_keeps_upload_access_and_folder_checks ... ok
test api::documents_routes::tests::a_ledger_referenced_missing_blob_is_an_invariant_failure ... ok
test api::documents_routes::tests::versions_ledger_names_what_content_can_serve ... ok
test api::documents_routes::tests::document_content_serves_the_current_and_recorded_versions ... ok
test api::documents_routes::tests::deleted_bytes_stay_readable_and_purged_tombstones_answer_gone ... ok
test api::documents_routes::tests::content_reads_keep_viewer_access_pat_scope_and_reject_source_tokens ... ok
test api::documents_routes::tests::each_upload_keeps_its_own_date_before_processing_and_extraction ... ok
test api::documents_routes::tests::fallback_restore_and_other_ingest_dates_do_not_change ... ok

test result: ok. 10 passed; 0 failed; 0 ignored; 0 measured; 375 filtered out; finished in 1.43s

Note on the local run: against the shared dev database (.../utopia) each_upload_keeps_its_own_date_before_processing_and_extraction failed deterministically with "no rows returned", because a utopia-server dev process was running against the same database and claimed the test's queued process_document job before the test's own UPDATE … RETURNING id could. The passing run above is against a fresh database in the same container (utopia_ci_check, migrated by the fixture, dropped afterwards). CI has no such worker, so the step is unaffected; it is only a caveat for anyone reproducing locally with cargo run still up.

cargo fmt --all --check passes.

Follow-ups (not bundled here)

Other utopia-server test modules are gated on test_db::url() the same way and are still not covered by any filter in the migrations job, so they also skip silently in CI:

  • api::jobs_routes::tests (api/jobs_routes_tests.rs)
  • api::rule_metadata_tests, api::rule_expression_tests (declared in api/mod.rs)
  • pipeline::pipeline_tests
  • ingest_sources::{source_checkpoint_tests, rss_sync_contract_tests, source_filename_tests}
  • type_alignment::tests
  • extraction::tests
  • query_engine::postgres::tests

Already covered by the existing filters: api::chat::chat_empty_reply_tests and its nested fallback_tests (via api::chat::), api::mcp::tests, retrieval::retrieval_tests. A broader fix would be to run the whole utopia-server crate in the migrations job with UTOPIA_TEST_REQUIRE_DB=1, the way utopia-store already is, instead of maintaining a filter list.

🤖 Generated with Claude Code

…silently

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Signed-off-by: WaylandYang <145302500+WaylandYang@users.noreply.github.com>
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