mirror of
https://github.com/fabro-sh/fabro.git
synced 2026-09-16 23:43:10 +00:00
Reduce slatedb timers
This commit is contained in:
parent
75b0e0879a
commit
f2910c557e
11 changed files with 17 additions and 51 deletions
|
|
@ -14,7 +14,7 @@ pub(crate) fn build_store(storage_dir: &Path) -> Result<Arc<SlateStore>> {
|
|||
Ok(Arc::new(SlateStore::new(
|
||||
object_store,
|
||||
"",
|
||||
Duration::from_millis(5),
|
||||
Duration::from_millis(1),
|
||||
)))
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -396,7 +396,7 @@ fn attach_json_errors_without_prompting_for_human_input() {
|
|||
},
|
||||
"host_repo_path": "[TEMP_DIR]",
|
||||
"labels": {},
|
||||
"run_dir": "[STORAGE_DIR]/runs/20260401-[ULID]",
|
||||
"run_dir": "[RUN_DIR]",
|
||||
"settings": {
|
||||
"goal": "Wait for approval",
|
||||
"llm": {
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ fn build_store(storage_dir: &std::path::Path) -> Arc<fabro_store::SlateStore> {
|
|||
Arc::new(fabro_store::SlateStore::new(
|
||||
object_store,
|
||||
"",
|
||||
std::time::Duration::from_millis(5),
|
||||
std::time::Duration::from_millis(1),
|
||||
))
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ fn build_store(storage_dir: &std::path::Path) -> Arc<fabro_store::SlateStore> {
|
|||
Arc::new(fabro_store::SlateStore::new(
|
||||
object_store,
|
||||
"",
|
||||
std::time::Duration::from_millis(5),
|
||||
std::time::Duration::from_millis(1),
|
||||
))
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -342,7 +342,7 @@ fn json_run_implies_auto_approve_for_human_gates() {
|
|||
},
|
||||
"host_repo_path": "[TEMP_DIR]",
|
||||
"labels": {},
|
||||
"run_dir": "[STORAGE_DIR]/runs/20260401-[ULID]",
|
||||
"run_dir": "[RUN_DIR]",
|
||||
"settings": {
|
||||
"auto_approve": true,
|
||||
"goal": "Route through the default approval path",
|
||||
|
|
|
|||
|
|
@ -59,13 +59,6 @@ pub(crate) fn output_stdout(output: &Output) -> String {
|
|||
stdout(output)
|
||||
}
|
||||
|
||||
pub(crate) fn read_json(path: &Path) -> Value {
|
||||
let content = std::fs::read_to_string(path)
|
||||
.unwrap_or_else(|err| panic!("failed to read {}: {err}", path.display()));
|
||||
serde_json::from_str(&content)
|
||||
.unwrap_or_else(|err| panic!("failed to parse {}: {err}", path.display()))
|
||||
}
|
||||
|
||||
pub(crate) fn read_text(path: &Path) -> String {
|
||||
std::fs::read_to_string(path)
|
||||
.unwrap_or_else(|err| panic!("failed to read {}: {err}", path.display()))
|
||||
|
|
@ -490,7 +483,7 @@ fn run_store(run_dir: &Path) -> Option<Arc<dyn RunStore>> {
|
|||
let storage_dir = runs_dir.parent()?;
|
||||
let run_id: RunId = infer_run_id(run_dir).parse().ok()?;
|
||||
let object_store = Arc::new(LocalFileSystem::new_with_prefix(storage_dir.join("store")).ok()?);
|
||||
let store = Arc::new(SlateStore::new(object_store, "", Duration::from_millis(5)));
|
||||
let store = Arc::new(SlateStore::new(object_store, "", Duration::from_millis(1)));
|
||||
block_on(store.open_run_reader(&run_id)).ok().flatten()
|
||||
}
|
||||
|
||||
|
|
@ -693,13 +686,6 @@ pub(crate) fn compact_git_inspect(output: &Output) -> Value {
|
|||
)
|
||||
}
|
||||
|
||||
fn read_json_if_exists(path: &Path) -> Option<Value> {
|
||||
if !path.exists() {
|
||||
return None;
|
||||
}
|
||||
Some(read_json(path))
|
||||
}
|
||||
|
||||
fn setup_git_backed_run(context: &TestContext, workflow: GitWorkflowKind) -> GitRunSetup {
|
||||
let repo_dir = context.temp_dir.join(match workflow {
|
||||
GitWorkflowKind::Changed => "git-changed",
|
||||
|
|
|
|||
|
|
@ -9,21 +9,12 @@ use std::time::Duration;
|
|||
use fabro_store::{RunSnapshot, RunStore, SlateStore, Store};
|
||||
use fabro_types::RunId;
|
||||
use object_store::local::LocalFileSystem;
|
||||
use serde_json::Value;
|
||||
|
||||
pub(super) fn fixture(name: &str) -> PathBuf {
|
||||
Path::new(env!("CARGO_MANIFEST_DIR"))
|
||||
.join("tests/it/workflow/fixtures")
|
||||
.join(name)
|
||||
}
|
||||
|
||||
pub(super) fn read_json(path: &Path) -> Value {
|
||||
let content = std::fs::read_to_string(path)
|
||||
.unwrap_or_else(|e| panic!("failed to read {}: {e}", path.display()));
|
||||
serde_json::from_str(&content)
|
||||
.unwrap_or_else(|e| panic!("failed to parse {}: {e}", path.display()))
|
||||
}
|
||||
|
||||
fn block_on<T>(future: impl std::future::Future<Output = T>) -> T {
|
||||
tokio::runtime::Builder::new_current_thread()
|
||||
.enable_all()
|
||||
|
|
@ -47,7 +38,7 @@ fn run_store(run_dir: &Path) -> Option<Arc<dyn RunStore>> {
|
|||
.parse()
|
||||
.ok()?;
|
||||
let object_store = Arc::new(LocalFileSystem::new_with_prefix(storage_dir.join("store")).ok()?);
|
||||
let store = Arc::new(SlateStore::new(object_store, "", Duration::from_millis(5)));
|
||||
let store = Arc::new(SlateStore::new(object_store, "", Duration::from_millis(1)));
|
||||
block_on(store.open_run_reader(&run_id)).ok().flatten()
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,6 @@
|
|||
use std::path::{Path, PathBuf};
|
||||
|
||||
use fabro_test::TestContext;
|
||||
use serde_json::Value;
|
||||
|
||||
macro_rules! fabro_json_snapshot {
|
||||
($context:expr, $value:expr, @$snapshot:literal) => {{
|
||||
let mut filters = $context.filters();
|
||||
|
|
@ -18,6 +16,10 @@ macro_rules! fabro_json_snapshot {
|
|||
r#""duration_ms":\s*\d+"#.to_string(),
|
||||
r#""duration_ms": "[DURATION_MS]""#.to_string(),
|
||||
));
|
||||
filters.push((
|
||||
r#""run_dir":\s*"\[STORAGE_DIR\]/runs/\d{8}-\[ULID\]""#.to_string(),
|
||||
r#""run_dir": "[RUN_DIR]""#.to_string(),
|
||||
));
|
||||
let filters: Vec<(&str, &str)> = filters
|
||||
.iter()
|
||||
.map(|(pattern, replacement)| (pattern.as_str(), replacement.as_str()))
|
||||
|
|
@ -38,19 +40,6 @@ pub(crate) fn example_fixture(name: &str) -> PathBuf {
|
|||
.expect("fixture path should exist")
|
||||
}
|
||||
|
||||
pub(crate) fn read_json(path: impl AsRef<Path>) -> Value {
|
||||
serde_json::from_str(&std::fs::read_to_string(path).unwrap()).unwrap()
|
||||
}
|
||||
|
||||
pub(crate) fn read_jsonl(path: impl AsRef<Path>) -> Vec<Value> {
|
||||
std::fs::read_to_string(path)
|
||||
.unwrap()
|
||||
.lines()
|
||||
.map(serde_json::from_str)
|
||||
.collect::<Result<Vec<_>, _>>()
|
||||
.unwrap()
|
||||
}
|
||||
|
||||
pub(crate) fn run_output_filters(context: &TestContext) -> Vec<(String, String)> {
|
||||
let mut filters = context.filters();
|
||||
filters.push((r"\b\d+ms\b".to_string(), "[TIME]".to_string()));
|
||||
|
|
|
|||
|
|
@ -148,7 +148,7 @@ pub async fn serve_command(
|
|||
let store = Arc::new(fabro_store::SlateStore::new(
|
||||
object_store,
|
||||
"",
|
||||
Duration::from_millis(5),
|
||||
Duration::from_millis(1),
|
||||
));
|
||||
let state =
|
||||
create_app_state_with_store(db, Arc::clone(&shared_settings), max_concurrent_runs, store);
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ impl SlateStore {
|
|||
self.object_store.clone(),
|
||||
None,
|
||||
DbReaderOptions {
|
||||
manifest_poll_interval: Duration::from_millis(100),
|
||||
manifest_poll_interval: Duration::from_millis(5),
|
||||
..DbReaderOptions::default()
|
||||
},
|
||||
)
|
||||
|
|
@ -404,7 +404,7 @@ mod tests {
|
|||
|
||||
fn make_store() -> (Arc<dyn ObjectStore>, SlateStore) {
|
||||
let object_store: Arc<dyn ObjectStore> = Arc::new(InMemory::new());
|
||||
let store = SlateStore::new(object_store.clone(), "runs/", Duration::from_millis(5));
|
||||
let store = SlateStore::new(object_store.clone(), "runs/", Duration::from_millis(1));
|
||||
(object_store, store)
|
||||
}
|
||||
|
||||
|
|
@ -531,7 +531,7 @@ mod tests {
|
|||
) -> slatedb::Db {
|
||||
let db = slatedb::Db::builder(record.db_prefix.clone(), object_store)
|
||||
.with_settings(Settings {
|
||||
flush_interval: Some(Duration::from_millis(5)),
|
||||
flush_interval: Some(Duration::from_millis(1)),
|
||||
..Settings::default()
|
||||
})
|
||||
.build()
|
||||
|
|
@ -960,7 +960,7 @@ mod tests {
|
|||
let db_prefix = catalog::db_prefix("runs/", created_at, &test_run_id("run-1"));
|
||||
let db = slatedb::Db::builder(db_prefix.clone(), object_store)
|
||||
.with_settings(Settings {
|
||||
flush_interval: Some(Duration::from_millis(5)),
|
||||
flush_interval: Some(Duration::from_millis(1)),
|
||||
..Settings::default()
|
||||
})
|
||||
.build()
|
||||
|
|
|
|||
|
|
@ -808,7 +808,7 @@ mod tests {
|
|||
std::fs::create_dir_all(storage_dir.join("store")).unwrap();
|
||||
let object_store =
|
||||
Arc::new(LocalFileSystem::new_with_prefix(storage_dir.join("store")).unwrap());
|
||||
let store = Arc::new(SlateStore::new(object_store, "", Duration::from_millis(5)));
|
||||
let store = Arc::new(SlateStore::new(object_store, "", Duration::from_millis(1)));
|
||||
let created = create(
|
||||
store.as_ref(),
|
||||
CreateRunInput {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue