diff options
| author | aur-build <aur-build@localhost> | 2026-11-20 21:03:58 +0000 |
|---|---|---|
| committer | aur-build <aur-build@localhost> | 2026-11-20 21:03:58 +0000 |
| commit | 2210c934d4a25602318f094e0eca72f42862d44a (patch) | |
| tree | 9bc80f269b05121e28f2465d3e9d1cd6d4457dfd /src/db/mod.rs | |
| parent | 289560d196b65b0b257b59a92c956f088eb29fad (diff) | |
| download | aur-build-2210c934d4a25602318f094e0eca72f42862d44a.tar.gz aur-build-2210c934d4a25602318f094e0eca72f42862d44a.zip | |
db, sandbox: apply the dispositions the table decided
Six db items are now gated behind `test-support`, each with a comment
saying what it is for and why production never calls it:
builds::claim production leases a batch; `claim_batch` is
what the dispatcher runs
settings::set_setting the readers are used, the setter is not
Writer::shutdown the server runs until the process ends
snapshots::snapshot_by_commit
world::world_members production writes world snapshots, never
reads one back member by member
invariants::unapproved_index_entries
gated, not relocated: reading it needs this
module's private helpers, and widening those
to let a test out would be the wrong trade
Gating them exposed three things they were the only user of, and each is
gated with them rather than left compiling into a binary that cannot reach
it: `Msg::Shutdown` and its loop arm, and `model::json_or`.
`arch-census.py --write-budget` also stopped erasing the `test_surface`
section — two writers of one file must not delete each other's axis, or
the ratchet quietly stops checking it.
`steps::touch` is deleted, not narrowed. Nothing called it — not
production, not a test. The census had credited it to `tests/shims.rs`,
where the word appears inside a string.
In sandbox, two tests moved into `src/sandbox/kata.rs`: the container
record a lease provisions, and the TTL expiry of a sandbox that never
dials in. Neither builds a fixture. `KataBackend::shared_for`,
`provision_request`, `sandbox_cr` and `K8sSandboxProvisioner::for_config`
are `pub(crate)` as a result.
`KataBackend::reclaim` is deleted — same story as `touch`. It forwarded to
`self.provisioner.reclaim`, which the reaping site already calls itself,
and the TTL test the census credited it for implements the *trait's*
`reclaim` on a null provisioner. Same word, different function.
Two honest costs, both recorded rather than smoothed over:
- `Provisioner` and `ProvisionRequest` are now named by nobody outside
`sandbox`, yet cannot be narrowed: `LocalAgentProvisioner` is `pub`
because two fixture tests construct it, and Rust forbids a public type
implementing a private trait or taking a private parameter type.
`sandbox.deadonly` therefore rises 0 → 2, with the reason here as the
ratchet demands.
- `agent_sandbox_config()` now exists in both `tests/kata.rs` and
`src/sandbox/kata.rs`. Three of that file's remaining tests still need
it, and a test helper cannot be shared across the crate boundary without
making it public again.
sandbox: 27 pub / 15 dead -> 22 pub / 10 dead.
Suite: 284 passed, 0 failed, 0 ignored. Clippy clean.
Diffstat (limited to 'src/db/mod.rs')
| -rw-r--r-- | src/db/mod.rs | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/src/db/mod.rs b/src/db/mod.rs index 5ac55c9..e42bae4 100644 --- a/src/db/mod.rs +++ b/src/db/mod.rs @@ -26,6 +26,8 @@ mod world; pub use migrations::MIGRATIONS; pub(crate) use model::StateEnum; +/// Its only caller is the test-tier `world_members`, so it is gated with it. +#[cfg(feature = "test-support")] pub(crate) use model::json_or; pub use model::{ @@ -36,7 +38,9 @@ pub use model::{ notice_kind, }; pub use audit::{AuditEntry, audit, audit_in, audit_system, list_audit}; -pub use invariants::{approved_but_unbuilt, unapproved_index_entries}; +pub use invariants::approved_but_unbuilt; +#[cfg(feature = "test-support")] +pub use invariants::unapproved_index_entries; pub use metrics::{ artifact_bytes_served, build_state_counts, count_index_packages, count_pending_reviews, count_published_releases, count_subscriptions, count_unacknowledged_notices, last_gc_age_secs, @@ -63,8 +67,12 @@ pub use retention::{ mark_release_purged, pkgbase_release_pointers, published_release_ids, record_gc_run, release_artifact_paths, serving_release_ids, }; -pub use settings::{all_settings, set_setting, setting, setting_i64}; -pub use snapshots::{SnapshotRow, put_snapshot, snapshot_by_commit, snapshot_by_id}; +pub use settings::{all_settings, setting, setting_i64}; +#[cfg(feature = "test-support")] +pub use settings::set_setting; +pub use snapshots::{SnapshotRow, put_snapshot, snapshot_by_id}; +#[cfg(feature = "test-support")] +pub use snapshots::snapshot_by_commit; pub use stage_b::{stage_b_cache_get, stage_b_cache_put, stage_b_recent}; pub use staleness::{ NewArtifact, approval_note, candidate_snapshot_id, index_recipes, @@ -75,7 +83,9 @@ pub use subscriptions::{ due_subscriptions, get_subscription, list_subscriptions, note_check, set_subscription_state, subscribe, }; -pub use world::{put_world_snapshot, world_members}; +pub use world::put_world_snapshot; +#[cfg(feature = "test-support")] +pub use world::world_members; pub(crate) fn state_col<T: StateEnum>(col: usize, text: &str) -> rusqlite::Result<T> { T::parse(text).ok_or_else(|| { @@ -160,6 +170,9 @@ type BoxedCall = Box<dyn FnOnce(&mut Connection) + Send>; enum Msg { Call(BoxedCall), + /// Only `Writer::shutdown` constructs this, and only the test tier calls + /// that; the server runs until the process ends. + #[cfg(feature = "test-support")] Shutdown, } @@ -184,6 +197,7 @@ impl Writer { for msg in rx.iter() { match msg { Msg::Call(f) => f(&mut conn), + #[cfg(feature = "test-support")] Msg::Shutdown => break, } } @@ -241,6 +255,12 @@ impl Writer { .map_err(|_| Error::db("writer actor gone")) } + /// Stop the writer actor. + /// + /// Test-tier only: the server runs until the process ends and never + /// quiesces the writer deliberately. Tests use it to prove a worker + /// that dies mid-write leaves the database consistent. +#[cfg(feature = "test-support")] pub fn shutdown(&self) { let _ = self.tx.send(Msg::Shutdown); } |
