Reconcile byte-identical historical offers without allowing another execution
This commit is contained in:
@@ -326,6 +326,40 @@ fn consumed_attempt_and_unknown_lock_survive_reopen_without_reexecution() {
|
||||
std::fs::remove_file(path).unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn retired_reboot_redelivery_preserves_the_original_attempt_and_enrollment() {
|
||||
let (binding, request, permit, _) = fixture();
|
||||
let mut old = binding.job(&request.job_bytes).unwrap();
|
||||
old.action = Action::Reboot {
|
||||
reason: "historical reboot".into(),
|
||||
reconnect_timeout_seconds: 60,
|
||||
dependency_group: "test".into(),
|
||||
};
|
||||
old.execution_identity = "root".into();
|
||||
let payload = encode(&old).unwrap();
|
||||
let offer = JobOffer {
|
||||
job_id: old.job_id.to_string(),
|
||||
attempt_id: old.attempt_id.to_string(),
|
||||
job_payload_hash: hash(&payload),
|
||||
payload_bytes: payload,
|
||||
plan_hash: permit.plan_hash,
|
||||
authorization_id: permit.authorization_id.to_string(),
|
||||
};
|
||||
let db = Connection::open_in_memory().unwrap();
|
||||
db.execute_batch("CREATE TABLE job_attempts(job TEXT,attempt TEXT,offer BLOB,state TEXT,PRIMARY KEY(job,attempt))").unwrap();
|
||||
assert!(jobs::accept(&db, &binding, &offer, |_| false).is_err());
|
||||
assert!(jobs::accept(&db, &binding, &offer, |_| true).unwrap());
|
||||
db.execute("UPDATE job_attempts SET state='unknown'", []).unwrap();
|
||||
assert!(!jobs::accept(&db, &binding, &offer, |_| panic!("historical delivery invoked the execution probe")).unwrap());
|
||||
let mut altered = offer.clone();
|
||||
altered.authorization_id = Uuid::new_v4().to_string();
|
||||
assert!(jobs::accept(&db, &binding, &altered, |_| false).is_err());
|
||||
let mut other = binding;
|
||||
other.enrollment_generation += 1;
|
||||
assert!(jobs::accept(&db, &other, &offer, |_| true).is_err());
|
||||
assert_eq!(db.query_row("SELECT count(*) FROM job_attempts WHERE state='unknown'", [], |r| r.get::<_,u32>(0)).unwrap(), 1);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn portable_acceptance_requires_platform_capability_and_exact_redelivery() {
|
||||
let (binding, request, permit, _) = fixture();
|
||||
|
||||
Reference in New Issue
Block a user