Repository navigation
Integration tests run as four parts and an isolation gates part, each on its own stack - #290
Merged
Merged
Conversation
This was referenced Nov 6, 2026
zlareb1
force-pushed
the
ci/integration-shards
branch
from
November 6, 2026 15:44
0e15a42 to
0b1ea32
Compare
… on its own stack One runner took 62 minutes for the suite and 8 for the auth-on gates. LOOM_TEST_SHARD=k/n keeps the k-th part, whole files dealt by test count (tests/_shards.py, called from tests/conftest.py). The isolation gates part runs the provider staging tests, the auth-on gates and the analyzer corpus as independent checks. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
zlareb1
force-pushed
the
ci/integration-shards
branch
from
November 6, 2026 17:04
f5ee233 to
b02b3f3
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changelog category (leave one):
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
pytest integration (ClickHouse service)was the longest job onmain: 54 to 62 minutes forpytest tests/integration, then 8 minutes for the tenant-isolation gates against an auth-on server, after 2 minutes of setup. The tests wait on refresh cycles, lease lapses and the server far more than they use the runner's CPU, so the suite splits across runners with little lost to setup.The job is now a matrix of five parts. Each part has its own runner, ClickHouse, migrations and extractor:
pytest tests/integration, chosen byLOOM_TEST_SHARD=k/4, against an auth-off server and an S3 store of their own.tests/_shards.pydoes the split, called fromtests/conftest.py, soLOOM_TEST_SHARDsplits whatever suite pytest collected. It deals whole files, heaviest first by test count, to the lightest part. Whole files keep every module-scoped fixture in one part. The split depends only on the collected file names and counts, so the four parts cover every collected test exactly once. The conftest deselects the other parts' tests, which pytest reports asdeselected. A malformed or out-of-rangeLOOM_TEST_SHARDis a usage error (exit 4), never a silent empty run.Separate stacks are safer here than
pytest-xdistagainst one server. Thedestructivetests stop merges or runOPTIMIZE, and other tests change runtime overrides, so a test running beside them on a shared ClickHouse could see their effects. In separate stacks the parts share nothing.Each part's server logs upload as
server-log-<part>(server-log-isolationfor the gates part), and the parts list their 20 slowest tests (--durations=20), so the next split can be checked against real times. The job timeout drops from 90 to 45 minutes.Scope and risk
CI configuration, the root test conftest, a split helper with a unit test (
tests/unit/test_test_shards.py), and the testing docs. No server code changes. WithoutLOOM_TEST_SHARDa local run collects and runs everything, as before.The split is weighted by test count, not time, so parts can differ in duration. This PR's run measures the spread. If one part runs far longer than the others, the next step is to weight by the
--durationsthe parts print.Compatibility, rollout and rollback
Tests
tests/unit/test_test_shards.py: the spec parser acceptsk/nand refuses out-of-range or malformed specs;keepdeselects the other parts' files, leaves a run without the variable whole, and turns a bad spec intopytest.UsageError. Every file lands in exactly one part. The parts stay within one file's weight of each other. The split ignores input order.pytest tests/integration --collect-onlyon a migrated private stack): 1,942 tests in total, and the parts hold 486, 486, 485 and 485. They sum to 1,942.LOOM_TEST_SHARD=5/4exits 4.test_test_inventory.py,test_doc_links.py,test_public_copy.py,test_agent_instructions.pyandtest_package_contracts.pypass.Measured on this PR's CI run at 7452425, the parts' totals add up to
main's single run exactly:main, one jobNeither of these two timings includes the analyzer corpus, which then still followed the failing gates and was skipped. The isolation gates part took 10:01 at 7452425, which still started the auth-off server and S3 store, and 10:41 at e4de5c2, which does not. The auth-on pass inside it took 8:00 and 8:52, against 8:01 on
mainin run 41961513217, the lastmainrun whose suite passed. In run 42190790932 the suite failed, somainskipped the auth-on pass and the analyzer corpus: its 63:38 leaves them out.One behaviour changes: the provider staging tests, the auth-on gates and the analyzer corpus now run whatever the suite or the check before them did. In the isolation gates part, the end-user issuer, the extractor, the analyzer corpus and the auth-on boot run unless the migrations failed or the run was cancelled (
!cancelled()); the boot also needs the issuer and the extractor, whose settings the server reads, and the gates run only when the auth-on server booted. In every part, the issuer and the extractor run unless the migrations failed or the run was cancelled; the numbered parts' boot, S3 store and pytest steps keep the default, so any failure before them skips them. Before, a failure in the suite skipped the auth-on gates and the analyzer corpus, and a provider staging failure skipped everything after it. Onmaintoday the three leakage cases would also skip the analyzer corpus. Run 42237393836 at a4e2970 shows the new order: the gates fail on the three leakage cases, and the analyzer corpus runs after them. The corpus failstest_shapes_file_matches_builders(19 new shapes, 1 gone), a drift onmainthe skipped step had hidden, since fixed by regeneratingtests/analyzer/shapes.txtonmain. The longest part sets the job's wall clock at 18.7 minutes, down from 63.6.The five failures are the ones
mainalready has. In run 42190790932,main's pytest step fails these five with the same assertions:test_cross_principal_leakage.py::test_every_read_op_against_a_collection_leaks_nothingcases (429s on the@menamespace);test_knowledge_inspect_ingest.py::test_backlog_a_missing_extractor_and_missing_access_are_kept_apart;test_namespace_tune_documents.py::test_tune_cuts_the_documents_again_and_writes_nothing.The isolation gates part hits the same three leakage cases against the auth-on server. This PR changes no server code or test.
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. The author checked the collected counts per part and the CI step conditions.
I can explain every line of this diff and how it interacts with the rest of Loom.
Checklist
make format-check,make lint,make typecheckandmake test-unitpass; the integration suite passes if server behaviour changed.main; no merged migration is edited.frontend/changed.docs/describe the system as it now is.git commit -s).🤖 Generated with Claude Code