S050: connector flood test fires in parallel so the limit shows

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
This commit is contained in:
astar76 2026-11-27 07:51:02 -06:00
commit ff1b1a06a9

View file

@ -274,15 +274,17 @@ async fn connector_slow_and_flood() {
#[tokio::test(flavor = "multi_thread")]
async fn connector_flood_15() {
let (_c, _rx, p) = start().await;
// One loop, one after the other: the rate gate answers the first ~30 and then says busy.
// All at once: a sequential loop is slowed by the peer lookup and the 5 per second refill hides the limit.
let codes: Vec<u16> = tokio::task::spawn_blocking(move || {
(0..40).map(|_| code(&send(p, format!("GET / HTTP/1.1\r\nHost: 127.0.0.1:{p}\r\nConnection: close\r\n\r\n").as_bytes()))).collect()
let req = format!("GET / HTTP/1.1\r\nHost: 127.0.0.1:{p}\r\nConnection: close\r\n\r\n");
let jobs: Vec<_> = (0..40).map(|_| { let r = req.clone(); std::thread::spawn(move || code(&send(p, r.as_bytes()))) }).collect();
jobs.into_iter().map(|j| j.join().unwrap()).collect()
})
.await
.unwrap();
let ok = codes.iter().filter(|c| **c == 200).count();
let busy = codes.iter().filter(|c| **c == 429).count();
assert!(ok >= 25 && busy >= 5 && ok + busy == 40, "ok {ok} busy {busy} {codes:?}");
assert!(ok >= 10 && busy >= 5 && ok + busy == 40, "ok {ok} busy {busy} {codes:?}");
}
/// S037: connections over the limit of 16 at once get 429 "busy", not a silent close.