performance-metrics: Add all supported formats to block tests
Signed-off-by: Wei Liu <liuwe@microsoft.com>
This commit is contained in:
parent
76d8d47f6a
commit
8a26380657
2 changed files with 77 additions and 10 deletions
|
|
@ -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)) {
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ use std::{fs, thread};
|
|||
use test_infra::{Error as InfraError, *};
|
||||
use thiserror::Error;
|
||||
|
||||
use crate::{mean, PerformanceTestControl};
|
||||
use crate::{mean, ImageFormat, PerformanceTestControl, PerformanceTestOverrides};
|
||||
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
pub const FOCAL_IMAGE_NAME: &str = "focal-server-cloudimg-amd64-custom-20210609-0.raw";
|
||||
|
|
@ -30,16 +30,30 @@ enum Error {
|
|||
RestoreTimeParse,
|
||||
}
|
||||
|
||||
// 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 fn init_tests() {
|
||||
// The test image cannot be created on tmpfs (e.g. /tmp) filesystem,
|
||||
// as tmpfs does not support O_DIRECT
|
||||
assert!(exec_host_command_output(&format!(
|
||||
"dd if=/dev/zero of={BLK_IO_TEST_IMG} bs=1M count=4096"
|
||||
))
|
||||
.status
|
||||
.success());
|
||||
pub fn init_tests(overrides: &PerformanceTestOverrides) {
|
||||
let mut cmd = format!("dd if=/dev/zero of={BLK_IO_TEST_IMG} bs=1M count=4096");
|
||||
|
||||
if let Some(o) = overrides.test_image_format {
|
||||
match o {
|
||||
ImageFormat::Raw => { /* Nothing to do */ }
|
||||
ImageFormat::Qcow2 => {
|
||||
cmd =
|
||||
format!("qemu-img create -f qcow2 -o preallocation=full {BLK_IO_TEST_IMG} 4G");
|
||||
}
|
||||
ImageFormat::Vhd => {
|
||||
cmd = format!("qemu-img create -f vpc -o subformat=fixed {BLK_IO_TEST_IMG} 4G");
|
||||
}
|
||||
ImageFormat::Vhdx => {
|
||||
cmd = format!("qemu-img create -f vhdx -o subformat=fixed {BLK_IO_TEST_IMG} 4G");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
assert!(exec_host_command_output(&cmd).status.success());
|
||||
}
|
||||
|
||||
pub fn cleanup_tests() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue