Watch
0
0
Fork
You've already forked hyperhive
0

review classifier: pin that a try-out's expiry follows its own size

The expiry test only built entries sized for ten classifications, so a run
whose deadline was ignored or fixed at the default would pass. It now checks
that a run of a hundred is still held when ten would have expired, and drops
at its own deadline.
This commit is contained in:
iris 2026-11-07 10:53:44 +01:00 • committed by mara
commit 7479d7fca7

View file

@ -1279,19 +1279,27 @@ pub(crate) mod tests {
#[test]
fn a_result_expires_after_its_ttl() {
let now = Instant::now();
let entry = |settled: Option<Instant>| Entry {
let sized = |classifications: usize, settled: Option<Instant>| Entry {
status: TryOutStatus::settled("abc".to_owned(), done()),
started: now,
deadline: run_deadline(10),
deadline: run_deadline(classifications),
settled,
};
let entry = |settled: Option<Instant>| sized(10, settled);
let deadline = run_deadline(10);
assert!(!entry(Some(now)).expired(now + RESULT_TTL));
assert!(entry(Some(now)).expired(now + RESULT_TTL + Duration::from_secs(1)));
// A run whose reply never came stays until the latest it could have,
// which is later for a bigger run.
// A run whose reply never came stays until the latest it could have.
assert!(!entry(None).expired(now + deadline + RESULT_TTL));
assert!(entry(None).expired(now + deadline + RESULT_TTL + Duration::from_secs(1)));
// That is later for a bigger run: a hundred classifications are still
// running when ten would have given up, and expire at their own.
let big = run_deadline(100);
assert!(big > deadline);
let past_ten = now + deadline + RESULT_TTL + Duration::from_secs(1);
assert!(!sized(100, None).expired(past_ten));
assert!(!sized(100, None).expired(now + big + RESULT_TTL));
assert!(sized(100, None).expired(now + big + RESULT_TTL + Duration::from_secs(1)));
}
/// A rules file holding `classifications`, and `extra` beside them.