summaryrefslogtreecommitdiffstats
path: root/tests/dispatch.rs
diff options
context:
space:
mode:
authoraur-build <aur-build@localhost>2026-11-19 20:27:26 +0000
committeraur-build <aur-build@localhost>2026-11-19 20:27:26 +0000
commit3cb78f6bc988beaf0408100a1425c02933d8957f (patch)
tree1130d54d02369050aaeda7017b89934d576b787f /tests/dispatch.rs
parentf139b9ae0e8d98dc98e1dec6bb0fc427d36ccefa (diff)
downloadaur-build-3cb78f6bc988beaf0408100a1425c02933d8957f.tar.gz
aur-build-3cb78f6bc988beaf0408100a1425c02933d8957f.zip
tests: wait on the condition instead of on the clock
The dispatch and crash waits polled every 50ms and 25ms against a dispatcher that ticks every two seconds; live.rs staged its log appends with 400ms sleeps; vcs.rs waited 80ms to conclude that a blocked racer had not entered. The pool tests take the virtual clock and poll a 2ms condition wait, live.rs appends without sleeping at all, and the Stage B test queues every racer on the slot before releasing it, so the window a broken cap would slip through is set up rather than hoped for. live.rs no longer proves delivery mid-stream, because it never could: the stream response is buffered until it ends, so the sleeps were not observable. Worth fixing on the serving side, but that is a behaviour change, not a test one.
Diffstat (limited to 'tests/dispatch.rs')
-rw-r--r--tests/dispatch.rs12
1 files changed, 8 insertions, 4 deletions
diff --git a/tests/dispatch.rs b/tests/dispatch.rs
index 84dd2b7..9381a17 100644
--- a/tests/dispatch.rs
+++ b/tests/dispatch.rs
@@ -110,6 +110,7 @@ fn a_newer_approval_cancels_an_in_flight_build_at_the_step_boundary() {
fn a_deterministic_build_failure_is_not_retried() {
let (env, _fx) = env_with_fixture("build-fails");
let id = queued_build(&env, "build-fails");
+ let _clock = aur_build::time::virtualize();
let pool = dispatch::Pool::spawn(Arc::new(env.cfg.clone()), env.db.clone());
let state = wait_for(&env, &id, &[BuildState::Failed, BuildState::Succeeded]);
pool.shutdown();
@@ -146,6 +147,7 @@ fn a_missing_toolchain_is_not_retried() {
env.cfg.makepkg_bin = "/nonexistent/makepkg-for-test".into();
env.cfg.max_transient_attempts = 3;
env.cfg.dispatch_tick_secs = 0;
+ let _clock = aur_build::time::virtualize();
let pool = dispatch::Pool::spawn(Arc::new(env.cfg.clone()), env.db.clone());
let state = wait_for(&env, &id, &[BuildState::Failed]);
pool.shutdown();
@@ -161,6 +163,7 @@ fn a_missing_toolchain_is_not_retried() {
fn the_pool_takes_a_queued_build_all_the_way_to_publication() {
let (env, _fx) = env_with_fixture("plain-make");
let id = queued_build(&env, "plain-make");
+ let _clock = aur_build::time::virtualize();
let cfg = Arc::new(env.cfg.clone());
let pool = dispatch::Pool::spawn(cfg, env.db.clone());
let state = wait_for(&env, &id, &[BuildState::Succeeded, BuildState::Failed]);
@@ -194,6 +197,7 @@ fn a_reaped_build_resumes_at_the_next_incomplete_step_with_no_duplicate_work() {
&params(vec![id.as_str()]),
);
+ let _clock = aur_build::time::virtualize();
let pool = dispatch::Pool::spawn(Arc::new(env.cfg.clone()), env.db.clone());
let state = wait_for(&env, &id, &[BuildState::Succeeded, BuildState::Failed]);
pool.shutdown();
@@ -228,25 +232,25 @@ fn queued_candidate(env: &Env, name: &str) -> CandidateRow {
}
fn wait_attempt(env: &Env, id: &str, n: i64) -> builds::BuildRow {
- for _ in 0..600 {
+ for _ in 0..15_000 {
if let Some(b) = builds::get(&env.db, id).unwrap() {
if b.attempt >= n && b.state == BuildState::Failed {
return b;
}
}
- std::thread::sleep(std::time::Duration::from_millis(50));
+ std::thread::sleep(std::time::Duration::from_millis(2));
}
panic!("build {id} never reached {n} attempts in state failed");
}
fn wait_for(env: &Env, id: &str, want: &[BuildState]) -> BuildState {
- for _ in 0..600 {
+ for _ in 0..15_000 {
if let Some(b) = builds::get(&env.db, id).unwrap() {
if want.contains(&b.state) {
return b.state;
}
}
- std::thread::sleep(std::time::Duration::from_millis(50));
+ std::thread::sleep(std::time::Duration::from_millis(2));
}
panic!("build {id} never reached {want:?}");
}