mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
tests: Constify rate limiter runtimes
Introduce named constants for the net and single block rate limiter test runtimes and use them directly at the call sites. Signed-off-by: Anatol Belski <anbelski@linux.microsoft.com>
This commit is contained in:
committed by
Rob Bradford
parent
a8904a93a6
commit
6de3d5279f
@@ -10475,6 +10475,9 @@ mod aarch64_acpi {
|
|||||||
mod rate_limiter {
|
mod rate_limiter {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
|
const NET_RATE_LIMITER_RUNTIME: u32 = 10;
|
||||||
|
const BLOCK_RATE_LIMITER_RUNTIME: u32 = 10;
|
||||||
|
|
||||||
// Check if the 'measured' rate is within the expected 'difference' (in percentage)
|
// Check if the 'measured' rate is within the expected 'difference' (in percentage)
|
||||||
// compared to given 'limit' rate.
|
// compared to given 'limit' rate.
|
||||||
fn check_rate_limit(measured: f64, limit: f64, difference: f64) -> bool {
|
fn check_rate_limit(measured: f64, limit: f64, difference: f64) -> bool {
|
||||||
@@ -10498,7 +10501,6 @@ mod rate_limiter {
|
|||||||
let disk_config = UbuntuDiskConfig::new(JAMMY_IMAGE_NAME.to_string());
|
let disk_config = UbuntuDiskConfig::new(JAMMY_IMAGE_NAME.to_string());
|
||||||
let guest = Guest::new(Box::new(disk_config));
|
let guest = Guest::new(Box::new(disk_config));
|
||||||
|
|
||||||
let test_timeout = 10;
|
|
||||||
let num_queues = 2;
|
let num_queues = 2;
|
||||||
let queue_size = 256;
|
let queue_size = 256;
|
||||||
let bw_size = 10485760_u64; // bytes
|
let bw_size = 10485760_u64; // bytes
|
||||||
@@ -10528,9 +10530,14 @@ mod rate_limiter {
|
|||||||
|
|
||||||
let r = std::panic::catch_unwind(|| {
|
let r = std::panic::catch_unwind(|| {
|
||||||
guest.wait_vm_boot().unwrap();
|
guest.wait_vm_boot().unwrap();
|
||||||
let measured_bps =
|
let measured_bps = measure_virtio_net_throughput(
|
||||||
measure_virtio_net_throughput(test_timeout, num_queues / 2, &guest, rx, true)
|
NET_RATE_LIMITER_RUNTIME,
|
||||||
.unwrap();
|
num_queues / 2,
|
||||||
|
&guest,
|
||||||
|
rx,
|
||||||
|
true,
|
||||||
|
)
|
||||||
|
.unwrap();
|
||||||
assert!(check_rate_limit(measured_bps, limit_bps, 0.1));
|
assert!(check_rate_limit(measured_bps, limit_bps, 0.1));
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -10550,7 +10557,6 @@ mod rate_limiter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn _test_rate_limiter_block(bandwidth: bool, num_queues: u32) {
|
fn _test_rate_limiter_block(bandwidth: bool, num_queues: u32) {
|
||||||
let test_timeout = 10;
|
|
||||||
let fio_ops = FioOps::RandRW;
|
let fio_ops = FioOps::RandRW;
|
||||||
|
|
||||||
let bw_size = if bandwidth {
|
let bw_size = if bandwidth {
|
||||||
@@ -10618,7 +10624,7 @@ mod rate_limiter {
|
|||||||
let fio_command = format!(
|
let fio_command = format!(
|
||||||
"sudo fio --filename=/dev/vdc --name=test --output-format=json \
|
"sudo fio --filename=/dev/vdc --name=test --output-format=json \
|
||||||
--direct=1 --bs=4k --ioengine=io_uring --iodepth=64 \
|
--direct=1 --bs=4k --ioengine=io_uring --iodepth=64 \
|
||||||
--rw={fio_ops} --runtime={test_timeout} --numjobs={num_queues}"
|
--rw={fio_ops} --runtime={BLOCK_RATE_LIMITER_RUNTIME} --numjobs={num_queues}"
|
||||||
);
|
);
|
||||||
let output = guest.ssh_command(&fio_command).unwrap();
|
let output = guest.ssh_command(&fio_command).unwrap();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user