hive-c0re: reconcile declared agents periodically, with backoff
This commit is contained in:
parent
7468aa4cff
commit
b8c07a5492
1 changed files with 516 additions and 9 deletions
|
|
@ -1556,6 +1556,62 @@ fn a_rebuild_is_live_for_its_own_agent_only() {
|
|||
assert!(!q.rebuild_live("bob"));
|
||||
}
|
||||
|
||||
/// The periodic reconcile tick queues one lone `Reconcile` on the agent's lease
|
||||
/// and nothing for an agent any live node already targets — whichever kind
|
||||
/// of work it is — while other agents and finished work do not block it.
|
||||
#[test]
|
||||
fn an_idle_agent_gets_one_reconcile_and_a_busy_one_none() {
|
||||
let q = JobQueue::new(1);
|
||||
let first = q
|
||||
.insert_reconcile_if_idle("alice")
|
||||
.expect("insert")
|
||||
.expect("control: an idle agent gets a reconcile");
|
||||
assert_eq!(
|
||||
declared_shape(&q)
|
||||
.iter()
|
||||
.filter(|d| d.kind == "reconcile")
|
||||
.count(),
|
||||
1,
|
||||
"exactly one Reconcile node"
|
||||
);
|
||||
assert_eq!(
|
||||
declared_resources_of_kind(&q, "reconcile"),
|
||||
vec![vec![Resource::Agent("alice".to_owned())]],
|
||||
"it holds the agent's lease"
|
||||
);
|
||||
|
||||
assert!(
|
||||
q.insert_reconcile_if_idle("alice")
|
||||
.expect("insert")
|
||||
.is_none(),
|
||||
"the live reconcile blocks another"
|
||||
);
|
||||
assert!(
|
||||
q.insert_reconcile_if_idle("bob").expect("insert").is_some(),
|
||||
"control: another agent is independent"
|
||||
);
|
||||
|
||||
// Work that is not a reconcile blocks too.
|
||||
insert(&q, |b| {
|
||||
let _ = rebuild(b, "carol");
|
||||
});
|
||||
assert!(
|
||||
q.insert_reconcile_if_idle("carol")
|
||||
.expect("insert")
|
||||
.is_none(),
|
||||
"a rebuild in flight blocks it"
|
||||
);
|
||||
|
||||
// A finished reconcile does not.
|
||||
assert!(q.cancel(first[0].get()), "cancel the queued reconcile");
|
||||
assert!(
|
||||
q.insert_reconcile_if_idle("alice")
|
||||
.expect("insert")
|
||||
.is_some(),
|
||||
"a terminal node does not count as busy"
|
||||
);
|
||||
}
|
||||
|
||||
/// Agents whose running closure differs from the declaration are rebuilt in one
|
||||
/// sweep. Each rebuild's window holds a build slot, so `buildSlots` caps how
|
||||
/// many swap at once, however many agents the sweep rebuilds.
|
||||
|
|
|
|||
Loading…
Reference in a new issue