Skip to content

Ingestion integration tests run their own job, not whichever the shared queue offers - #256

Merged
zlareb1 merged 10 commits into
mainfrom
fix/ingest-tests-own-job
Nov 4, 2026
Merged

zlareb1 merged 10 commits into
mainfrom
fix/ingest-tests-own-job

Conversation

@zlareb1

@zlareb1 zlareb1 commented Nov 4, 2026 •

Copy link
Copy Markdown
Member

Related: #157

A second failure in the same job, on main since the inspect tests landed: test_knowledge_inspect_ingest.py::test_with_the_extractor_bad_content_lost_structure_and_a_refused_token asserts that knowledge.inspect reports an extractor configured (ingestions.extractor_configured). That is the server's own setting, and CI started the reference extractor after the servers booted, so only the test process had its URL.

Changelog category (leave one):

  • CI Fix or Improvement (changelog entry is not required)

Changelog entry (one or two sentences a user of Loom can read without the diff; the release pull request collects these into the release notes):

...

Why

tests/integration/test_knowledge_ingest_live.py fails intermittently in the integration job. Which tests fail changes from run to run:

  • test_revisions_count_up_and_an_expected_revision_guards_the_publish reads revision 1 where it expects 2;
  • test_an_uploaded_sql_file_is_parsed_published_and_cited and test_a_mislabelled_upload_is_stored_and_the_extractor_refuses_it read their job still pending.

In every failure, the job the test created was never run. Each test calls knowledge_ingest's run_pass() once and then reads the result, but a pass runs exactly one job, chosen from the whole queue. ingestions.due orders that queue fairly across namespaces, namespaces never served first. The integration job runs every test file against one ClickHouse, and other files (the inspect tests among them) leave jobs in it. So the one pass often takes another test's job.

Change

  • Each helper reads the test's own job and runs it through ingest_run.take_and_run. That is the call a worker pass makes once it has taken a job, so the test exercises the same lease, re-read and stages, and no longer depends on what else is queued.
  • In test_knowledge_ingest_live.py, _work now takes the job's org, namespace and id.
  • test_namespace_tune_documents.py's helper, which looped over up to ten passes, runs its own job the same way.
  • In test_knowledge_inspect_ingest.py, the bounded loop of passes in _work is replaced by the same own-job run; with more than ten jobs queued ahead, that loop failed the same way.
  • The same file's _end cleanup cancels its open jobs and runs each one, which ends it. A run does not wait for a retried job's next attempt. The cleanup used to poll up to 60 passes of the shared queue.
  • docs/development/testing.md says how a worker whose pass reads a cross-tenant queue is exercised, and that the publishing tests run their own job.
  • Each helper asserts that its run ran (take_and_run returns None when it ran nothing), so a job not run reads as that, not as a wrong state later.
  • .github/workflows/ci.yml starts the reference extractor before both servers boot, so they read LOOM_DOCUMENT_EXTRACTOR_URL and its token from the job's environment as the test process does.
  • The worker's queue order is unchanged. tests/integration/test_knowledge_ingest_queue.py already reads ingestions.due directly; test_each_namespace_offers_one_due_job_at_the_head_of_its_source joins it, built from rows as its neighbours are: one candidate per namespace, the job due longest among its sources' first open jobs, and a source's later job held behind the earlier one even while that one waits out a retry delay (the per-namespace rule, which the backlog test there cannot tell from the per-source one, included). Removing either LIMIT 1 BY from due fails it. Its rows are ended after, so it leaves nothing on the queue.

Compatibility, rollout and rollback

  • Tests, the CI workflow and the testing guide only. Rollback: revert.

Tests

  • Reproduced locally against a server, a migrated ClickHouse and the reference extractor, built from main.
    • With six ingests queued in other namespaces, test_knowledge_ingest_live.py as on main fails three tests, the way the CI runs do.
    • With this change and twelve, fifteen and then about thirty jobs queued, test_knowledge_ingest_live.py, test_knowledge_inspect_ingest.py, test_namespace_tune_documents.py and test_knowledge_ingest_queue.py pass: 11 passed.
  • The PR's CI run before the last rebase: the integration job 1,853 passed and 0 failed, the inspect test included; the unit job passed. The frontend job missed its Playwright LCP budget (1,932 ms against 1,500 ms at 4x CPU); this PR changes no frontend.
  • make format-check and make lint pass.

AI assistance in the code (leave one; writing this description with AI is fine):

  • AI-generated (an agent wrote most of the diff): Claude Code.

  • I can explain every line of this diff and how it interacts with the rest of Loom.

Checklist

  • make format-check, make lint, make typecheck and make test-unit pass; the integration suite passes if server behaviour changed. (Test-only; the two files pass locally under a queued backlog, and the integration job on this PR runs them.)
  • Docs under docs/ describe the system as it now is, and this description names any operator steps and wire changes.
  • Repository text has no dates, people, host names, internal namespaces, ticket or decision numbers; the history goes in this description (tests/unit/test_public_copy.py).
  • Commits are signed off (git commit -s), as CONTRIBUTING.md asks.

🤖 Generated with Claude Code

@zlareb1
zlareb1 force-pushed the fix/ingest-tests-own-job branch 4 times, most recently from e78cb03 to 450322d Compare November 4, 2026 11:18
zlareb1 and others added 10 commits November 4, 2026 11:40
…ed queue offers

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
… queue directly

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…ow a cross-tenant worker is tested

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…'s lease

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…spect sees it configured

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
… inspect test's assertion

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…elper names a job that did not run

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
@zlareb1
zlareb1 force-pushed the fix/ingest-tests-own-job branch from 450322d to 3f52f8d Compare November 4, 2026 11:43
@zlareb1
zlareb1 merged commit d7bcbe9 into main Nov 4, 2026
18 checks passed
@zlareb1
zlareb1 deleted the fix/ingest-tests-own-job branch November 4, 2026 11:45
@pufit pufit mentioned this pull request Nov 4, 2026
9 tasks done
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