performance-metrics: Refactor fio_control to BlockControl

Introduce a new BlockControl struct to encapsulate fio operation
parameters. This replaces the tuple-based fio_control with a more
extensible structure that includes:
- fio_ops: The FIO operation type
- bandwidth: Whether to measure bandwidth or IOPS
- test_file: The file path to test against

This refactoring enables reusing performance_block_io with different
test files.

Signed-off-by: Anatol Belski <anbelski@linux.microsoft.com>
This commit is contained in:
Anatol Belski
2025-12-15 20:07:42 +01:00
committed by Bo Chen
parent 7288031c0e
commit d696cea024
2 changed files with 101 additions and 26 deletions

View File

@@ -32,7 +32,7 @@ enum Error {
// The test image cannot be created on tmpfs (e.g. /tmp) filesystem,
// as tmpfs does not support O_DIRECT
const BLK_IO_TEST_IMG: &str = "/var/tmp/ch-blk-io-test.img";
pub const BLK_IO_TEST_IMG: &str = "/var/tmp/ch-blk-io-test.img";
pub fn init_tests(overrides: &PerformanceTestOverrides) {
let mut cmd = format!("dd if=/dev/zero of={BLK_IO_TEST_IMG} bs=1M count=4096");
@@ -366,7 +366,10 @@ pub fn performance_block_io(control: &PerformanceTestControl) -> f64 {
let test_timeout = control.test_timeout;
let num_queues = control.num_queues.unwrap();
let queue_size = control.queue_size.unwrap();
let (fio_ops, bandwidth) = control.fio_control.as_ref().unwrap();
let block_control = control.block_control.as_ref().unwrap();
let fio_ops = &block_control.fio_ops;
let bandwidth = block_control.bandwidth;
let test_file = block_control.test_file;
let focal = UbuntuDiskConfig::new(FOCAL_IMAGE_NAME.to_string());
let guest = performance_test_new_guest(Box::new(focal));
@@ -395,8 +398,7 @@ pub fn performance_block_io(control: &PerformanceTestControl) -> f64 {
guest.disk_config.disk(DiskType::CloudInit).unwrap()
)
.as_str(),
format!("path={BLK_IO_TEST_IMG},queue_size={queue_size},num_queues={num_queues}")
.as_str(),
format!("path={test_file},queue_size={queue_size},num_queues={num_queues}").as_str(),
])
.default_net()
.args(["--api-socket", &api_socket])
@@ -420,7 +422,7 @@ pub fn performance_block_io(control: &PerformanceTestControl) -> f64 {
.unwrap();
// Parse fio output
if *bandwidth {
if bandwidth {
parse_fio_output(&output, fio_ops, num_queues).unwrap()
} else {
parse_fio_output_iops(&output, fio_ops, num_queues).unwrap()