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:
parent
cffe8895df
commit
7479d7fca7
1 changed files with 12 additions and 4 deletions
|
|
@ -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.
|
||||
|
|
|
|||
Loading…
Reference in a new issue