Skip fsync when running tests
Flushing to disk all the time ensures no partial states when writing to disk during awkwardnesses like crashes in prod risking real user data. That's good! We're also doing it while running tests. Less good! Well, at least not important! Comparing a clean test run (`just test --no-fail-fast`) and a run on this branch, on my MacOS M4 Pro, I get: `**Summary** [ 517.723s] **1424** tests run: **1405** **passed** (**7** **slow**), **19** **failed**, **15** **skipped**` before and `**Summary** [ 326.369s] **1424** tests run: **1405** **passed**, **19** **failed**, **15** **skipped**` after. The reason I run `--no-fail-fast` is that a bunch of tests always fail and time out and stuff
96 unmodified lines97989910010110110210310410595 unmodified lines96 unmodified lines
test-unit: SQLX_OFFLINE=true cargo test --test dpop_unit --test validation_edge_cases --test scope_edge_cases
store_test := "SQLX_OFFLINE=true TRANQUIL_TEST_BACKEND=store TRANQUIL_PDS_ALLOW_INSECURE_SECRETS=1 DISABLE_RATE_LIMITING=1 TRANQUIL_LEXICON_OFFLINE=1 SKIP_IMPORT_VERIFICATION=true cargo nextest run -E 'not package(tranquil-store) and not binary(store_parity)'"store_test := "SQLX_OFFLINE=true TRANQUIL_TEST_BACKEND=store TRANQUIL_PDS_ALLOW_INSECURE_SECRETS=1 DISABLE_RATE_LIMITING=1 TRANQUIL_LEXICON_OFFLINE=1 SKIP_IMPORT_VERIFICATION=true cargo nextest run --features tranquil-store/skip-fsync -E 'not package(tranquil-store) and not binary(store_parity)'"
test-auth: {{store_test}} --test oauth --test oauth_lifecycle --test oauth_scopes --test oauth_security --test jwt_security --test session_management --test change_password --test password_reset
95 unmodified lines44 unmodified lines45464748495051525343 unmodified lines44 unmodified linestest-harness = ["dep:tempfile"]jemalloc = ["dep:tikv-jemallocator"]gauntlet-cli = ["test-harness", "dep:clap", "dep:toml", "dep:tracing-subscriber", "jemalloc"]gauntlet-jemalloc-prof = []skip-fsync = []
[[bin]]name = "tranquil-gauntlet"path = "src/bin/tranquil_gauntlet.rs"43 unmodified lines265 unmodified linesExpand all26626726826927027127227327427527627727827928028128228312 unmodified lines296297298299300301302303304305306307308309310311312313118 unmodified linesExpand all265 unmodified linesExpand all fn write_at(&self, id: FileId, offset: u64, buf: &[u8]) -> io::Result<usize> { self.lookup(id)?.write_at(buf, offset) }
#[cfg(not(feature = "skip-fsync"))] fn sync(&self, id: FileId) -> io::Result<()> { self.lookup(id)?.sync_data() }
#[cfg(feature = "skip-fsync")] fn sync(&self, id: FileId) -> io::Result<()> { self.lookup(id).map(|_| ()) }
fn file_size(&self, id: FileId) -> io::Result<u64> { self.lookup(id)?.metadata().map(|m| m.len()) }
12 unmodified lines fn mkdir(&self, path: &Path) -> io::Result<()> { fs::create_dir_all(path) }
#[cfg(not(feature = "skip-fsync"))] fn sync_dir(&self, path: &Path) -> io::Result<()> { fs::File::open(path)?.sync_all() }
#[cfg(feature = "skip-fsync")] fn sync_dir(&self, path: &Path) -> io::Result<()> { fs::File::open(path).map(|_| ()) }
fn list_dir(&self, path: &Path) -> io::Result<Vec<PathBuf>> { fs::read_dir(path)? .map(|entry| entry.map(|e| e.path())) .collect()118 unmodified linesExpand all40 unmodified lines41424344454647484950515253193 unmodified linesExpand all247248249250246251252253254255256257253258259260261262168 unmodified linesExpand all431432433434430435436437438439469 unmodified linesExpand all40 unmodified linesuse self::user_hash::UserHashMap;
const CURRENT_FORMAT_VERSION: u64 = 3;
#[cfg(feature = "skip-fsync")]const METASTORE_PERSIST_MODE: fjall::PersistMode = fjall::PersistMode::Buffer;#[cfg(not(feature = "skip-fsync"))]const METASTORE_PERSIST_MODE: fjall::PersistMode = fjall::PersistMode::SyncData;
#[derive(Debug, Clone)]pub struct MetastoreConfig { pub cache_size_bytes: u64,}193 unmodified linesExpand all ); repo_data.remove(records::record_by_cid_built_key().as_slice())?; Self::migrate_blob_ownership(db, repo_data)?; repo_data.insert(version_key, version_bytes)?; db.persist(fjall::PersistMode::SyncData)?; db.persist(METASTORE_PERSIST_MODE)?; Ok(()) } } } None => { repo_data.insert(version_key, version_bytes)?; db.persist(fjall::PersistMode::SyncData)?; db.persist(METASTORE_PERSIST_MODE)?; Ok(()) } } }168 unmodified linesExpand all }
pub fn persist(&self) -> Result<(), MetastoreError> { self.db .persist(fjall::PersistMode::SyncData) .persist(METASTORE_PERSIST_MODE) .map_err(MetastoreError::Fjall) }
pub fn major_compact(&self) -> Result<(), MetastoreError> {469 unmodified linesExpand all