Skip to content

Commit

Permalink
chore(test): Double refill time for RX rate limiter
Browse files Browse the repository at this point in the history
Although we increased the refill time in the past in commit
347f877 ("unittest: net: eliminate ReadTapMock::MockFrame") to
avoid intermittent issues, it still fails rarely (maybe due to resource
contention). We are not sure the enough refill time, but it's worth a
try and may reduce the chance of kicking the retry of the whole unit
tests manually.

Signed-off-by: Takahiro Itazuri <[email protected]>
  • Loading branch information
zulinx86 committed Nov 8, 2024
1 parent c75c861 commit bcfefab
Showing 1 changed file with 8 additions and 8 deletions.
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

0 comments on commit bcfefab

Please sign in to comment.