STRA-338 S14: admission tests on the scripted host
This commit is contained in:
@@ -124,3 +124,55 @@ fn a_stuck_reject_is_lifted_by_the_requests_themselves_once_the_sampler_is_five_
|
||||
assert_eq!(g.admit(&SHAPE), Admission::Admit);
|
||||
assert_eq!(g.level(), Level::Shed);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn admission_follows_the_level_the_scripted_host_drives_it_to() {
|
||||
// normal, then shed (requests are still served), then reject (503 with a Retry-After); an admit that gets past the
|
||||
// level reads the host once more for its own transient, a refusal by level does not
|
||||
let (g, _clock) = scripted(&[20_000, 20_000, 3000, 3000, 1024]);
|
||||
g.sample_at(1000);
|
||||
assert_eq!(g.admit(&SHAPE), Admission::Admit);
|
||||
g.sample_at(2000);
|
||||
assert_eq!(g.level(), Level::Shed);
|
||||
assert_eq!(g.admit(&SHAPE), Admission::Admit, "shedding still serves");
|
||||
g.sample_at(3000);
|
||||
let Admission::Refuse(refusal) = g.admit(&SHAPE) else {
|
||||
panic!("rejecting must refuse")
|
||||
};
|
||||
assert_eq!((refusal.status, refusal.code), (503, "memory_pressure"));
|
||||
assert!(refusal.retry_after_secs >= 5, "{refusal:?}");
|
||||
let report = g.report();
|
||||
assert_eq!(report["counters"]["admitted"], 2);
|
||||
assert_eq!(report["counters"]["rejected_memory_pressure"], 1);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_request_whose_own_transient_would_cross_the_hard_floor_is_refused_on_the_scripted_host() {
|
||||
// 2.1 GiB available: above the 2 GiB hard floor, but the 256 MiB transient of one request would cross it
|
||||
let (g, _clock) = scripted(&[2150]);
|
||||
let Admission::Refuse(refusal) = g.admit(&SHAPE) else {
|
||||
panic!("must refuse")
|
||||
};
|
||||
assert_eq!(refusal.code, "memory_pressure");
|
||||
assert!(
|
||||
refusal.message.contains("hard floor"),
|
||||
"{}",
|
||||
refusal.message
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_context_that_can_never_fit_is_a_400_and_does_not_read_the_host() {
|
||||
let (g, _clock) = scripted(&[20_000]);
|
||||
let Admission::Refuse(refusal) = g.admit(&RequestShape {
|
||||
prompt_tokens: 262_144,
|
||||
..SHAPE
|
||||
}) else {
|
||||
panic!()
|
||||
};
|
||||
assert_eq!(
|
||||
(refusal.status, refusal.code),
|
||||
(400, "context_length_exceeded")
|
||||
);
|
||||
assert_eq!(g.report()["counters"]["rejected_context"], 1);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user