clawhdf5-remote tests: the server counts only requests for its files
A local port scanner's GET / reached the test listeners and was counted, failing the exact request budgets (and consuming injected 503s). Requests for paths the server does not serve are now answered 404 without being counted, delayed or failed; the query string is not part of the path. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
This commit is contained in:
@@ -526,3 +526,21 @@ fn bad_urls_and_statuses_are_clean_errors() {
|
||||
"{err}"
|
||||
);
|
||||
}
|
||||
|
||||
/// A request for a path the server does not serve (a local port scanner's
|
||||
/// `GET /`) does not count against a test's request budget.
|
||||
#[test]
|
||||
fn requests_for_other_paths_are_not_counted() {
|
||||
use std::io::{Read, Write};
|
||||
let server = Server::start(vec![("/m.h5".into(), multi_block_file())]);
|
||||
let mut probe = std::net::TcpStream::connect(server.addr).unwrap();
|
||||
probe
|
||||
.write_all(b"GET / HTTP/1.1\r\nHost: x\r\nConnection: close\r\n\r\n")
|
||||
.unwrap();
|
||||
let mut answer = String::new();
|
||||
probe.read_to_string(&mut answer).unwrap();
|
||||
assert!(answer.starts_with("HTTP/1.1 404"), "{answer}");
|
||||
storage_for_url(&server.url("/m.h5"), &quick()).unwrap();
|
||||
assert_eq!(server.requests(), 1, "only the open counts");
|
||||
assert_eq!(server.log().len(), 1);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user