Shared rate-limit tests wait a second sync round
Browse files at this commit7c429b64a3a2839abe86b35938918983af0d6b2aParent: fa1529a- fix
- shared rate-limit tests wait a second sync round
1 changed file +5 -3
- tests/rate_limit.rs +5 -3
tests/rate_limit.rsmodified+5 -3
| @@ -432,7 +432,7 @@ async fn sync_round() { | ||
| 432 | 432 | tokio::task::yield_now().await; |
| 433 | 433 | tokio::time::advance(Duration::from_secs(RATE_SYNC_INTERVAL_SECS)).await; |
| 434 | 434 | tokio::time::resume(); |
| 435 | - tokio::time::sleep(Duration::from_millis(750)).await; | |
| 435 | + tokio::time::sleep(Duration::from_millis(2000)).await; | |
| 436 | 436 | tokio::time::pause(); |
| 437 | 437 | } |
| 438 | 438 | |
| @@ -489,8 +489,9 @@ async fn a_restarted_process_inherits_the_windows_spend() { | ||
| 489 | 489 | let spent = admits(&a, "user:a", 6) + admits(&b, "user:a", 6); |
| 490 | 490 | assert_eq!(spent, 12, "each process starts on its own local budget"); |
| 491 | 491 | |
| 492 | - // From the first sync on, the shared total is what binds: neither limiter | |
| 493 | - // admits anything more in this window, whatever the interleaving was. | |
| 492 | + // Two rounds: each limiter's fold is its own statement, so the process | |
| 493 | + // that landed first only learns the other's spend on the next tick. | |
| 494 | + sync_round().await; | |
| 494 | 495 | sync_round().await; |
| 495 | 496 | assert_eq!( |
| 496 | 497 | admits(&a, "user:a", 6) + admits(&b, "user:a", 6), |
| @@ -512,6 +513,7 @@ async fn a_process_that_never_admitted_still_learns_the_budget_is_gone() { | ||
| 512 | 513 | assert_eq!(admits(&b, "user:a", 1), 1); |
| 513 | 514 | assert_eq!(admits(&a, "user:a", 3), 3); |
| 514 | 515 | sync_round().await; |
| 516 | + sync_round().await; | |
| 515 | 517 | |
| 516 | 518 | assert_eq!( |
| 517 | 519 | admits(&b, "user:a", 3), |