Repository navigation
Conversation
fluree-db-server had 28 auto-discovered integration test targets, one per tests/*.rs file. Each is a `bin` that links the full workspace dependency tree, so the crate paid 28 separate link steps on every test build. This takes it to 9. Group them using the pattern fluree-db-api already establishes: `autotests = false` plus explicit [[test]] declarations, with each harness pulling its members in via #[path]/mod. The 28 test files are not moved or edited, so git blame is preserved across all 22k lines. Grouping is by domain (grp_http, grp_query, grp_proxy, grp_policy, grp_search, grp_raft, grp_bolt), not by feature. `raft` is the only non-default feature here (default = native, credential, iceberg, shacl, bolt), so grp_raft is the only harness that compiles to an empty binary on a default build. telemetry_test and multi_query_tracing_integration keep their own binaries. Both install a tracing subscriber and assert on the events captured through it, and tracing's callsite-interest cache is process-global while the capture is thread-local, so those assertions are only reliable when the test is alone in its process under bare `cargo test`. docs/contributing/tests.md already states that rule for fluree-db-api; it now covers this crate too. `autotests = false` also means a new tests/*.rs that nobody wires into a harness never compiles and never runs, with `cargo test` still reporting success. tests/harness_coverage.rs asserts every tests/*.rs is either pulled into a harness or declared as its own [[test]], and names the orphans when it fails. Verified under bare `cargo test`, not just nextest. nextest gives every test its own process and cannot detect the shared-process hazards this layout introduces.
…idate-test-harness
bplatz
left a comment
There was a problem hiding this comment.
One gap worth closing before merge: harness_coverage skips anything named grp_*, and it harvests #[path] lines from the filesystem — so a grp_*.rs that nobody declares as a [[test]] escapes the guard entirely, and the files it references count as covered while nothing compiles or runs them (verified locally with a demo harness). Small fix: also assert every tests/grp_*.rs appears as a [[test]] path in Cargo.toml.
Suggested follow-up (separate PR/issue): port the guard to fluree-db-api — it has the same layout and far more test files, and the docs added here already tell adopters to add one.
The guard skipped anything named grp_*, assuming it must be declared as a [[test]] target, and harvested #[path] lines from every file on disk. An undeclared tests/grp_foo.rs therefore escaped the check while its members counted as covered. A whole harness could go missing with the guard still reporting success. Derive reachability from Cargo.toml instead: parse the [[test]] blocks, harvest The filename special case is removed rather than supplemented. The parser also handles targets that omit `path`, which fluree-db-api uses and a port will need.
This was addressed in fb576f6
Good idea. I'll do this in another branch |
fluree-db-serverhad 28 auto-discovered integration test targets — one pertests/*.rsfile. Every one of them is abinthat links the entire workspace dependency graph, so the crate paid 28 full link steps on every test build. This groups them by domain into 7 harnesses plus 2 deliberately standalone binaries, taking the crate from 28 test binaries to 9, using the same patternfluree-db-apialready established:autotests = false, explicit[[test]]declarations, and each case file pulled in as a module via#[path].No test code moves and no test file is edited. All 338 integration tests are preserved exactly, verified by name rather than by count.
What changed
grp_http,grp_query,grp_proxy,grp_policy,grp_search,grp_raft,grp_bolt. Each is a short list of#[path = "…"] mod …;lines, matching the existing style influree-db-api/tests/grp_*.rs.fluree-db-server/Cargo.toml—autotests = falsein[package], plus 9[[test]]declarations and comments explaining why auto-discovery is off and why two suites stay standalone.tests/harness_coverage.rs— a new guard test (see below).docs/contributing/tests.md— the grouped-binary section now documentsfluree-db-serveralongsidefluree-db-api.How this improves the codebase
Fewer link steps. 19 fewer full links of the workspace dependency tree per test build of this crate. Linking is the dominant cost of building this test suite, and it is work that no incremental-compilation or compiler-cache scheme can avoid —
sccache, for instance, explicitly cannot cache crates that invoke the system linker.Less disk per build. Measured on this branch, each linked server test binary is 436–463 MB (with
split-debuginfo = "unpacked"from the base branch already applied). Removing 19 of them cuts roughly 8 GB of linked output from a full--all-featurestest build. That figure is derived from the measured per-binary size rather than a direct before/after of the whole tree, but every removed binary was a full link, so it is a sound multiplication rather than a guess.The disk saving multiplies across working copies. Each git worktree, CI cache entry, and developer checkout carries its own
target/. Three worktrees previously carried three independent copies of those 19 redundant binaries.Closes a silent-failure hole that
autotests = falseopens. This is the one real hazard the pattern introduces: with auto-discovery off, a newtests/*.rsthat nobody wires into a harness is never compiled and never run — andcargo teststill reports success.tests/harness_coverage.rsasserts that everytests/*.rsis either pulled into a harness or declared as its own[[test]]target, failing with the list of orphans. This is not hypothetical: an untrackedtests/ledger_route_config_defaults.rsexists on another branch and would have silently stopped running once this merged. The guard was verified against a synthetic orphan file — it fails naming the file, and passes once the file is wired up.Brings the crate in line with a documented convention that previously covered only one crate.
docs/contributing/tests.mddescribed the grouping pattern and its standalone rules forfluree-db-apialone. It now coversfluree-db-servertoo, so a contributor adding a server integration test finds the rule instead of discoveringautotests = falseby surprise from aCargo.tomlcomment.Preserves history. The 28 test files are neither moved nor edited, so
git blameis intact across all 22k lines of test code. The entire diff is 193 added lines.Grouping reflects what the code actually does. Harnesses are organised by domain, not by feature flag.
raftis the only non-default feature in this crate (default = ["native", "credential", "iceberg", "shacl", "bolt"]), sogrp_raftis the only harness that compiles to an empty binary on a default build.Two suites intentionally left standalone
telemetry_testandmulti_query_tracing_integrationkeep their own binaries. Both install a tracing subscriber and assert on the events captured through it. Tracing's callsite-interest cache is process-global while the capture is thread-local, so those assertions are only reliable when the test is alone in its process under barecargo test. This is exactly the ruledocs/contributing/tests.mdalready states forfluree-db-api, now applied consistently here.They do pass inside a shared harness today, because their captures happen to sit on
current_threadruntimes — but that is a coincidence of the current test bodies, not a property the tests guarantee, so they are kept isolated by rule rather than by luck.Safety of sharing a process
Grouping means tests that previously had a process each now share one under bare
cargo test. (Undercargo nextest, which CI uses, every test still gets its own process, so CI semantics are unchanged.) All 28 files were audited for process-global hazards:set_var/remove_varanywhere.OnceLock/OnceCell/LazyLock/ lazy statics latching process state.set_current_dir, noRLIMITmanipulation, no self re-exec.raft_multi_node, which isOnce-guarded withtry_init()and therefore idempotent.Filesystem isolation was already sound — the suites use
tempfile/TempDirthroughout — and every real listener binds an ephemeral127.0.0.1:0port, so there are no fixed-port collisions between concurrently running tests.Notes for reviewers and after merge
[[test]]targets and turning off auto-discovery changes which artifacts Cargo produces. The 28 old per-file test binaries linger in existingtarget/directories as unreferenced garbage until acargo clean. Harmless, but worth running once if you care about the disk reclaim this PR is about.fluree-db-apihas the sameautotests = falsesilent-drop exposure and no coverage guard. That is pre-existing and out of scope here, buttests/harness_coverage.rsis written to be portable — dropping a copy into that crate would protect its ~160 test files too.