mirror of
https://tangled.org/tranquil.farm/tranquil-pds
synced 2026-09-24 19:24:15 +00:00
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:
@@ -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"
|
||||
|
||||
@@ -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()))
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user