summaryrefslogtreecommitdiffstats
path: root/tests/dispatch.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/dispatch.rs')
-rw-r--r--tests/dispatch.rs43
1 files changed, 36 insertions, 7 deletions
diff --git a/tests/dispatch.rs b/tests/dispatch.rs
index e62b351..8c0e4ff 100644
--- a/tests/dispatch.rs
+++ b/tests/dispatch.rs
@@ -152,12 +152,15 @@ fn a_deterministic_build_failure_is_not_retried() {
#[test]
fn a_transient_failure_is_retried_up_to_the_cap() {
- // §8.4: transient failures (network, mirror 5xx) retry with a bounded
- // number of attempts. Here the toolchain itself is missing, which surfaces
- // as an IO error — the same class as a flaky mirror.
- let (mut env, _fx) = env_with_fixture("plain-make");
- let id = queued_build(&env, "plain-make");
- env.cfg.makechrootpkg_bin = "/nonexistent/makechrootpkg-for-test".into();
+ // §8.4: a failure the outside world caused is retried, up to a bound. This
+ // drives the real path: detection recorded a `SKIP` source's digest, then
+ // the bytes became unreachable and the cache was dropped, so the build's
+ // `sources` step has to fetch and gets an `Http` failure — the class a
+ // flaky mirror produces.
+ let (mut env, fx) = env_with_fixture("skip-checksum");
+ let id = queued_build(&env, "skip-checksum");
+ std::fs::remove_file(fx.data.join("payload.bin")).expect("payload exists");
+ env.exec("DELETE FROM source_cache", &[]);
env.cfg.max_transient_attempts = 3;
env.cfg.dispatch_tick_secs = 0;
let pool = dispatch::Pool::spawn(Arc::new(env.cfg.clone()), env.db.clone());
@@ -166,7 +169,33 @@ fn a_transient_failure_is_retried_up_to_the_cap() {
let b = wait_attempt(&env, &id, 3);
pool.shutdown();
assert_eq!(b.state, BuildState::Failed);
- assert_eq!(b.attempt, 3, "a transient failure should retry up to the cap");
+ assert_eq!(b.attempt, 3, "an unreachable source should retry up to the cap");
+ assert!(
+ b.error.unwrap_or_default().contains("payload"),
+ "the recorded failure should name what could not be fetched"
+ );
+}
+
+#[test]
+fn a_missing_toolchain_is_not_retried() {
+ // m-14: this used to be the transient test. A missing `makechrootpkg`
+ // surfaces as an `Io` error, and `Io` used to mean "retry" — so a
+ // misconfigured host or a full disk burned every attempt and then went
+ // quiet. It is deterministic: the tool is not going to appear.
+ let (mut env, _fx) = env_with_fixture("plain-make");
+ let id = queued_build(&env, "plain-make");
+ env.cfg.makechrootpkg_bin = "/nonexistent/makechrootpkg-for-test".into();
+ env.cfg.max_transient_attempts = 3;
+ env.cfg.dispatch_tick_secs = 0;
+ let pool = dispatch::Pool::spawn(Arc::new(env.cfg.clone()), env.db.clone());
+ let state = wait_for(&env, &id, &[BuildState::Failed]);
+ pool.shutdown();
+ assert_eq!(state, BuildState::Failed);
+ assert_eq!(
+ builds::get(&env.db, &id).unwrap().unwrap().attempt,
+ 1,
+ "a missing binary must not be retried as if the network had hiccupped"
+ );
}
#[test]