crates/monetize-server/src/estate_order/tests/front_keep_job.rs
//! **The shop's keep boot of a front is a queued jera job** (owner rule: server background work is
//! a jera ChainQueue job, never a raw thread; L7 2026-10-17): the tick queues one job per estate
//! waiting for it, a second tick while it is queued or running is that same job, and the job
//! finishes the boot as `front_keep` does.
use super::*;
#[test]
fn the_tick_queues_the_fronts_keep_boot_as_one_jera_job() {
let r = delivered("front-keep-job", release_cfg("02", true));
laid_older(&r);
let u = update::start(&r.state, "acme", "", "operator").expect("opened");
assert_eq!(
u.state,
update::state::FRONT_KEEP,
"the front never asked: front first"
);
let rt = tokio::runtime::Builder::new_multi_thread()
.worker_threads(2)
.enable_all()
.build()
.unwrap();
let state = r.state.clone();
rt.block_on(async move {
let s = state.clone();
tokio::task::spawn_blocking(move || {
update::look(&s);
update::look(&s);
})
.await
.unwrap();
assert!(
state.estates.front_keep_lane.get().is_some(),
"the keep boot went to the jera lane"
);
for _ in 0..200 {
if state
.estates
.get("acme")
.unwrap()
.update
.as_ref()
.is_some_and(|u| u.state != update::state::FRONT_KEEP)
{
break;
}
tokio::time::sleep(std::time::Duration::from_millis(25)).await;
}
});
let run = r.state.estates.get("acme").unwrap();
let u = run
.update
.as_ref()
.expect("still open: twin and main follow");
assert_eq!(u.state, update::state::RUNNING, "{}", u.line());
assert_eq!(
u.next().map(|s| s.role.as_str()),
Some("twin"),
"the front was keep-booted once"
);
assert_eq!(
run.release_of.get("front").map(String::as_str),
Some("02-front")
);
}