Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(test): Double refill time for RX rate limiter #4904

Merged
merged 2 commits into from
Nov 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions src/vmm/src/devices/virtio/net/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2153,7 +2153,7 @@ pub mod tests {
// Test RX bandwidth rate limiting
{
// create bandwidth rate limiter that allows 2000 bytes/s with bucket size 1000 bytes
let mut rl = RateLimiter::new(1000, 0, 500, 0, 0, 0).unwrap();
let mut rl = RateLimiter::new(1000, 0, 1000, 0, 0, 0).unwrap();

// set up RX
assert!(th.net().rx_buffer.used_descriptors == 0);
Expand Down Expand Up @@ -2195,9 +2195,9 @@ pub mod tests {
assert_eq!(th.net().metrics.rx_rate_limiter_throttled.count(), 2);
}

// wait for 500ms to give the rate-limiter timer a chance to replenish
// wait for an extra 500ms to make sure the timerfd event makes its way from the kernel
thread::sleep(Duration::from_millis(1000));
// wait for 1000ms to give the rate-limiter timer a chance to replenish
// wait for an extra 1000ms to make sure the timerfd event makes its way from the kernel
thread::sleep(Duration::from_millis(2000));

// following RX procedure should succeed because bandwidth should now be available
{
Expand Down Expand Up @@ -2276,7 +2276,7 @@ pub mod tests {
// Test RX ops rate limiting
{
// create ops rate limiter that allows 2 ops/s with bucket size 1 ops
let mut rl = RateLimiter::new(0, 0, 0, 1, 0, 500).unwrap();
let mut rl = RateLimiter::new(0, 0, 0, 1, 0, 1000).unwrap();

// set up RX
assert!(th.net().rx_buffer.used_descriptors == 0);
Expand Down Expand Up @@ -2319,9 +2319,9 @@ pub mod tests {
assert_eq!(th.rxq.used.idx.get(), 0);
}

// wait for 500ms to give the rate-limiter timer a chance to replenish
// wait for an extra 500ms to make sure the timerfd event makes its way from the kernel
thread::sleep(Duration::from_millis(1000));
// wait for 1000ms to give the rate-limiter timer a chance to replenish
// wait for an extra 1000ms to make sure the timerfd event makes its way from the kernel
thread::sleep(Duration::from_millis(2000));

// following RX procedure should succeed because ops should now be available
{
Expand Down
Loading