performance-metrics: Add all supported formats to block tests

Signed-off-by: Wei Liu <liuwe@microsoft.com>
This commit is contained in:
Wei Liu
2025-07-17 00:20:24 +00:00
committed by Bo Chen
parent 76d8d47f6a
commit 8a26380657
2 changed files with 77 additions and 10 deletions

View File

@@ -106,10 +106,45 @@ impl Default for MetricsReport {
}
}
#[derive(Clone, Copy, Default)]
pub enum ImageFormat {
#[default]
Raw,
Qcow2,
Vhd,
Vhdx,
}
impl std::str::FromStr for ImageFormat {
type Err = ();
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"raw" => Ok(ImageFormat::Raw),
"qcow2" => Ok(ImageFormat::Qcow2),
"vhd" => Ok(ImageFormat::Vhd),
"vhdx" => Ok(ImageFormat::Vhdx),
_ => Err(()),
}
}
}
impl fmt::Display for ImageFormat {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self {
ImageFormat::Raw => write!(f, "raw"),
ImageFormat::Qcow2 => write!(f, "qcow2"),
ImageFormat::Vhd => write!(f, "vhd"),
ImageFormat::Vhdx => write!(f, "vhdx"),
}
}
}
#[derive(Default)]
pub struct PerformanceTestOverrides {
test_iterations: Option<u32>,
test_timeout: Option<u32>,
test_image_format: Option<ImageFormat>,
}
impl fmt::Display for PerformanceTestOverrides {
@@ -121,6 +156,10 @@ impl fmt::Display for PerformanceTestOverrides {
write!(f, "test_timeout = {test_timeout}")?;
}
if let Some(test_image_format) = self.test_image_format {
write!(f, "test_image_format = {test_image_format}")?;
}
Ok(())
}
}
@@ -686,6 +725,15 @@ fn main() {
.help("Override test timeout, Ex. --timeout 5")
.num_args(1),
)
.arg(
Arg::new("image-format")
.long("image-format")
.help(
"Override the image format used for block tests, supported values: qcow2, raw, vhd, vhdx. \
Default is 'raw'.",
)
.num_args(1),
)
.get_matches();
// It seems that the tool (ethr) used for testing the virtio-net latency
@@ -723,9 +771,14 @@ fn main() {
.map(|s| s.parse())
.transpose()
.unwrap_or_default(),
test_image_format: cmd_arguments
.get_one::<String>("image-format")
.map(|s| s.parse())
.transpose()
.unwrap_or_default(),
});
init_tests();
init_tests(&overrides);
for test in test_list.iter() {
if test_filter.is_empty() || test_filter.iter().any(|&s| test.name.contains(s)) {