fix(openapi): harden story 2.1 production lifecycle
This commit is contained in:
@@ -3,6 +3,7 @@ use std::{
|
||||
os::unix::fs::{MetadataExt, PermissionsExt},
|
||||
path::PathBuf,
|
||||
sync::atomic::{AtomicU64, Ordering},
|
||||
sync::{Mutex, OnceLock},
|
||||
time::{Duration, SystemTime},
|
||||
};
|
||||
|
||||
@@ -19,8 +20,6 @@ use crank_artifacts::test_support::{
|
||||
FaultAction, checkpoint_hits, clear_checkpoint, reset_traversal_calls, set_checkpoint,
|
||||
set_checkpoint_on_hit, traversal_calls, wait_until_held,
|
||||
};
|
||||
#[cfg(debug_assertions)]
|
||||
use std::sync::{Mutex, OnceLock};
|
||||
|
||||
static NEXT_ROOT: AtomicU64 = AtomicU64::new(0);
|
||||
const FULL_SCAN_BUDGET: usize = 2048;
|
||||
@@ -47,7 +46,6 @@ impl Drop for TestRoot {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(debug_assertions)]
|
||||
fn fault_guard() -> std::sync::MutexGuard<'static, ()> {
|
||||
static GUARD: OnceLock<Mutex<()>> = OnceLock::new();
|
||||
GUARD.get_or_init(|| Mutex::new(())).lock().unwrap()
|
||||
@@ -55,6 +53,7 @@ fn fault_guard() -> std::sync::MutexGuard<'static, ()> {
|
||||
|
||||
#[test]
|
||||
fn paginates_final_entries_without_disclosing_locations() {
|
||||
let _guard = fault_guard();
|
||||
let root = TestRoot::new("pages");
|
||||
let store = ArtifactStore::open(&root.0).unwrap();
|
||||
store.put(b"reconciliation first").unwrap();
|
||||
@@ -116,6 +115,7 @@ fn paginates_final_entries_without_disclosing_locations() {
|
||||
|
||||
#[test]
|
||||
fn classifies_malformed_and_unsafe_entries_with_a_usable_page() {
|
||||
let _guard = fault_guard();
|
||||
let root = TestRoot::new("malformed");
|
||||
let store = ArtifactStore::open(&root.0).unwrap();
|
||||
let stored = store.put(b"reconciliation valid").unwrap();
|
||||
@@ -157,6 +157,7 @@ fn classifies_malformed_and_unsafe_entries_with_a_usable_page() {
|
||||
|
||||
#[test]
|
||||
fn skips_a_valid_publish_temp_without_classifying_it_as_malformed() {
|
||||
let _guard = fault_guard();
|
||||
let root = TestRoot::new("valid-temp");
|
||||
let store = ArtifactStore::open(&root.0).unwrap();
|
||||
let stored = store.put(b"reconciliation with concurrent temp").unwrap();
|
||||
@@ -181,6 +182,7 @@ fn skips_a_valid_publish_temp_without_classifying_it_as_malformed() {
|
||||
|
||||
#[test]
|
||||
fn unsafe_canonical_shard_does_not_starve_later_shards() {
|
||||
let _guard = fault_guard();
|
||||
let root = TestRoot::new("unsafe-shard");
|
||||
let store = ArtifactStore::open(&root.0).unwrap();
|
||||
let sha = root.0.join("sha256");
|
||||
@@ -212,6 +214,7 @@ fn unsafe_canonical_shard_does_not_starve_later_shards() {
|
||||
#[test]
|
||||
#[cfg(debug_assertions)]
|
||||
fn traversal_never_exceeds_the_exact_syscall_budget() {
|
||||
let _guard = fault_guard();
|
||||
let root = TestRoot::new("syscall-budget");
|
||||
let store = ArtifactStore::open(&root.0).unwrap();
|
||||
store.put(b"bounded traversal syscall accounting").unwrap();
|
||||
@@ -237,6 +240,7 @@ fn traversal_never_exceeds_the_exact_syscall_budget() {
|
||||
|
||||
#[test]
|
||||
fn rejects_a_cursor_from_another_store() {
|
||||
let _guard = fault_guard();
|
||||
let first_root = TestRoot::new("foreign-cursor-first");
|
||||
let second_root = TestRoot::new("foreign-cursor-second");
|
||||
let first = ArtifactStore::open(&first_root.0).unwrap();
|
||||
@@ -276,6 +280,7 @@ fn disappearing_entry_after_readdir_is_skipped() {
|
||||
|
||||
#[test]
|
||||
fn quarantine_and_delete_are_idempotent() {
|
||||
let _guard = fault_guard();
|
||||
let root = TestRoot::new("mutation");
|
||||
let store = ArtifactStore::open(&root.0).unwrap();
|
||||
let stored = store.put(b"reconciliation mutation").unwrap();
|
||||
@@ -320,6 +325,7 @@ fn quarantine_and_delete_are_idempotent() {
|
||||
|
||||
#[test]
|
||||
fn quarantine_preserves_old_inode_when_the_digest_is_republished() {
|
||||
let _guard = fault_guard();
|
||||
let root = TestRoot::new("no-clobber");
|
||||
let store = ArtifactStore::open(&root.0).unwrap();
|
||||
let stored = store.put(b"reconciliation no-clobber").unwrap();
|
||||
@@ -358,6 +364,7 @@ fn quarantine_preserves_old_inode_when_the_digest_is_republished() {
|
||||
|
||||
#[test]
|
||||
fn quarantine_refuses_to_replace_an_unrelated_inode() {
|
||||
let _guard = fault_guard();
|
||||
let root = TestRoot::new("unrelated-collision");
|
||||
let store = ArtifactStore::open(&root.0).unwrap();
|
||||
let stored = store.put(b"canonical final survives collision").unwrap();
|
||||
@@ -394,6 +401,7 @@ fn quarantine_refuses_to_replace_an_unrelated_inode() {
|
||||
|
||||
#[test]
|
||||
fn delete_fails_closed_for_a_replaced_or_hardlinked_quarantined_inode() {
|
||||
let _guard = fault_guard();
|
||||
let root = TestRoot::new("quarantine-replaced");
|
||||
let store = ArtifactStore::open(&root.0).unwrap();
|
||||
let stored = store
|
||||
@@ -431,6 +439,7 @@ fn delete_fails_closed_for_a_replaced_or_hardlinked_quarantined_inode() {
|
||||
|
||||
#[test]
|
||||
fn delete_revalidates_a_post_scan_hardlink_without_inode_replacement() {
|
||||
let _guard = fault_guard();
|
||||
let root = TestRoot::new("quarantine-hardlink");
|
||||
let store = ArtifactStore::open(&root.0).unwrap();
|
||||
let stored = store.put(b"same quarantined inode gains a link").unwrap();
|
||||
@@ -496,6 +505,7 @@ fn delete_fsync_ambiguity_is_retryable_and_recovers_as_absent() {
|
||||
|
||||
#[test]
|
||||
fn rejects_a_replaced_final_inode() {
|
||||
let _guard = fault_guard();
|
||||
let root = TestRoot::new("replaced");
|
||||
let store = ArtifactStore::open(&root.0).unwrap();
|
||||
let stored = store.put(b"reconciliation original").unwrap();
|
||||
@@ -773,6 +783,7 @@ fn crash_windows_are_recoverable() {
|
||||
|
||||
#[test]
|
||||
fn registration_revalidates_content_and_enforces_grace_without_candidate_identity_access() {
|
||||
let _guard = fault_guard();
|
||||
let root = TestRoot::new("registration");
|
||||
let store = ArtifactStore::open(&root.0).unwrap();
|
||||
let stored = store.put(b"reconciliation registration").unwrap();
|
||||
@@ -820,6 +831,7 @@ fn registration_revalidates_content_and_enforces_grace_without_candidate_identit
|
||||
|
||||
#[test]
|
||||
fn namespace_scan_can_finish_quarantine_recovery_before_final_sweep() {
|
||||
let _guard = fault_guard();
|
||||
let root = TestRoot::new("namespace-order");
|
||||
let store = ArtifactStore::open(&root.0).unwrap();
|
||||
store.put(b"quarantine-first recovery").unwrap();
|
||||
@@ -856,6 +868,7 @@ fn namespace_scan_can_finish_quarantine_recovery_before_final_sweep() {
|
||||
|
||||
#[test]
|
||||
fn namespace_scan_rejects_a_cursor_from_a_broader_scan() {
|
||||
let _guard = fault_guard();
|
||||
let root = TestRoot::new("namespace-cursor-scope");
|
||||
let store = ArtifactStore::open(&root.0).unwrap();
|
||||
let (report, _) = store.scan_reconciliation(None, 0, 1).unwrap();
|
||||
@@ -876,6 +889,7 @@ fn namespace_scan_rejects_a_cursor_from_a_broader_scan() {
|
||||
|
||||
#[test]
|
||||
fn full_scan_rejects_a_quarantine_only_cursor() {
|
||||
let _guard = fault_guard();
|
||||
let root = TestRoot::new("namespace-cursor-narrow");
|
||||
let store = ArtifactStore::open(&root.0).unwrap();
|
||||
let (report, _) = store
|
||||
@@ -893,6 +907,7 @@ fn full_scan_rejects_a_quarantine_only_cursor() {
|
||||
|
||||
#[test]
|
||||
fn presence_probe_distinguishes_final_quarantine_and_absent_without_disclosure() {
|
||||
let _guard = fault_guard();
|
||||
let root = TestRoot::new("presence");
|
||||
let store = ArtifactStore::open(&root.0).unwrap();
|
||||
let stored = store.put(b"presence probe").unwrap();
|
||||
|
||||
Reference in New Issue
Block a user