Skip to content

Commit 92d9741

Browse files
authored
test(server): Fix flaky test_bandwidth_burst_tolerance (#578)
The test left only 500ms of margin between the accumulated bandwidth debt and the burst tolerance, so a slow runner would see the debt drain back under the burst and admit the request that should have been rejected. Scaled the rate and burst down so the margin is seconds instead of milliseconds, keeping the same scenario. Closes FS-459
1 parent 94c5897 commit 92d9741

1 file changed

Lines changed: 7 additions & 6 deletions

File tree

objectstore-server/tests/limits.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -398,17 +398,18 @@ async fn test_bandwidth_global_bps_limit() -> Result<()> {
398398

399399
#[tokio::test]
400400
async fn test_bandwidth_burst_tolerance() -> Result<()> {
401-
// 100 bps with 1.5s burst → burst budget = 150 bytes.
402-
// A 100-byte upload creates 1s of debt, within 1.5s burst → next request admitted.
401+
// 10 bps with 10s burst → burst budget = exactly one 100-byte upload.
402+
// The rate is deliberately slow so that each upload creates 10s of debt: the third
403+
// request stays rejected for a full 10s, independent of CI scheduling delays.
403404
let server = TestServer::with_config(Config {
404405
auth: AuthZ {
405406
enforce: false,
406407
..Default::default()
407408
},
408409
rate_limits: RateLimits {
409410
bandwidth: BandwidthLimits {
410-
global_bps: Some(100),
411-
burst_ms: 1500,
411+
global_bps: Some(10),
412+
burst_ms: 10_000,
412413
..Default::default()
413414
},
414415
..Default::default()
@@ -420,7 +421,7 @@ async fn test_bandwidth_burst_tolerance() -> Result<()> {
420421
let client = reqwest::Client::new();
421422
let payload = vec![0xABu8; 100];
422423

423-
// First upload creates 1s of debt, within the 1.5s burst tolerance.
424+
// First upload creates 10s of debt, within the 10s burst tolerance.
424425
let response = client
425426
.post(server.url("/v1/objects/test/org=1/"))
426427
.body(payload.clone())
@@ -436,7 +437,7 @@ async fn test_bandwidth_burst_tolerance() -> Result<()> {
436437
.await?;
437438
assert_eq!(response.status(), reqwest::StatusCode::CREATED);
438439

439-
// Now debt ≈ 2s > 1.5s burst → rejected.
440+
// Now debt ≈ 20s > 10s burst → rejected.
440441
let response = client
441442
.post(server.url("/v1/objects/test/org=1/"))
442443
.body(payload.clone())

0 commit comments

Comments
 (0)