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
This commit is contained in:
Johanna Larsson
2026-09-23 17:24:44 +00:00
committed by Tangled
parent eebce28926
commit 06b1255733
4 changed files with 22 additions and 4 deletions
+1
View File
@@ -46,6 +46,7 @@ test-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"
+12
View File
@@ -267,10 +267,16 @@ impl StorageIO for RealIO {
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())
}
@@ -291,10 +297,16 @@ impl StorageIO for RealIO {
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()))
+8 -3
View File
@@ -42,6 +42,11 @@ use 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,
@@ -243,14 +248,14 @@ impl Metastore {
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(())
}
}
@@ -427,7 +432,7 @@ impl Metastore {
pub fn persist(&self) -> Result<(), MetastoreError> {
self.db
.persist(fjall::PersistMode::SyncData)
.persist(METASTORE_PERSIST_MODE)
.map_err(MetastoreError::Fjall)
}
+1 -1
View File
@@ -98,7 +98,7 @@ test-store-asan:
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