mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2024-08-21 23:41:15 +00:00
performance-metrics: Create test image for block I/O tests from main
In this way, we can avoid create/delete large temporary files during every iteration of block I/O performance tests. Also, we can reuse the 'init/clean_tests()' interface in the future for other setup/cleanup. Signed-off-by: Bo Chen <chen.bo@intel.com>
This commit is contained in:
parent
1cf73c83e2
commit
b806935941
1
Cargo.lock
generated
1
Cargo.lock
generated
@ -637,7 +637,6 @@ dependencies = [
|
|||||||
"serde_derive",
|
"serde_derive",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"test_infra",
|
"test_infra",
|
||||||
"vmm-sys-util",
|
|
||||||
"wait-timeout",
|
"wait-timeout",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -11,5 +11,4 @@ serde = { version = "1.0.136", features = ["rc"] }
|
|||||||
serde_derive = "1.0.136"
|
serde_derive = "1.0.136"
|
||||||
serde_json = "1.0.78"
|
serde_json = "1.0.78"
|
||||||
test_infra = { path = "../test_infra" }
|
test_infra = { path = "../test_infra" }
|
||||||
vmm-sys-util = "0.9.0"
|
|
||||||
wait-timeout = "0.2.0"
|
wait-timeout = "0.2.0"
|
||||||
|
@ -336,6 +336,8 @@ fn run_test_with_timetout(test: &'static PerformanceTest) -> Result<String, Erro
|
|||||||
fn main() {
|
fn main() {
|
||||||
let test_filter = env::var("TEST_FILTER").map_or("".to_string(), |o| o);
|
let test_filter = env::var("TEST_FILTER").map_or("".to_string(), |o| o);
|
||||||
|
|
||||||
|
init_tests();
|
||||||
|
|
||||||
// Run performance tests sequentially and report results (in both readable/json format)
|
// Run performance tests sequentially and report results (in both readable/json format)
|
||||||
let mut json_output = String::new();
|
let mut json_output = String::new();
|
||||||
for test in TEST_LIST.iter() {
|
for test in TEST_LIST.iter() {
|
||||||
@ -352,6 +354,8 @@ fn main() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cleanup_tests();
|
||||||
|
|
||||||
// Todo: Report/upload to the metrics database
|
// Todo: Report/upload to the metrics database
|
||||||
println!("\n\nTests result in json format: \n {}", json_output);
|
println!("\n\nTests result in json format: \n {}", json_output);
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,6 @@ use std::time::Duration;
|
|||||||
use std::{fmt, fs};
|
use std::{fmt, fs};
|
||||||
use test_infra::Error as InfraError;
|
use test_infra::Error as InfraError;
|
||||||
use test_infra::*;
|
use test_infra::*;
|
||||||
use vmm_sys_util::tempdir::TempDir;
|
|
||||||
use wait_timeout::ChildExt;
|
use wait_timeout::ChildExt;
|
||||||
|
|
||||||
pub const FOCAL_IMAGE_NAME: &str = "focal-server-cloudimg-amd64-custom-20210609-0.raw";
|
pub const FOCAL_IMAGE_NAME: &str = "focal-server-cloudimg-amd64-custom-20210609-0.raw";
|
||||||
@ -41,6 +40,24 @@ impl From<InfraError> for Error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const BLK_IO_TEST_IMG: &str = "/var/tmp/ch-blk-io-test.img";
|
||||||
|
|
||||||
|
pub fn init_tests() {
|
||||||
|
// The test image can not 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={} bs=1M count=4096",
|
||||||
|
BLK_IO_TEST_IMG
|
||||||
|
))
|
||||||
|
.status
|
||||||
|
.success());
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn cleanup_tests() {
|
||||||
|
fs::remove_file(BLK_IO_TEST_IMG)
|
||||||
|
.unwrap_or_else(|_| panic!("Failed to remove file '{}'.", BLK_IO_TEST_IMG));
|
||||||
|
}
|
||||||
|
|
||||||
const DIRECT_KERNEL_BOOT_CMDLINE: &str =
|
const DIRECT_KERNEL_BOOT_CMDLINE: &str =
|
||||||
"root=/dev/vda1 console=hvc0 rw systemd.journald.forward_to_console=1";
|
"root=/dev/vda1 console=hvc0 rw systemd.journald.forward_to_console=1";
|
||||||
|
|
||||||
@ -593,15 +610,6 @@ pub fn performance_block_io(control: &PerformanceTestControl) -> f64 {
|
|||||||
.to_str()
|
.to_str()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.to_string();
|
.to_string();
|
||||||
// The test image can not be created on tmpfs (e.g. /tmp) filesystem,
|
|
||||||
// as tmpfs does not support O_DIRECT
|
|
||||||
let test_dir = TempDir::new_with_prefix("/home/ch").unwrap();
|
|
||||||
let test_img = test_dir
|
|
||||||
.as_path()
|
|
||||||
.join("tmp.img")
|
|
||||||
.to_str()
|
|
||||||
.unwrap()
|
|
||||||
.to_string();
|
|
||||||
|
|
||||||
let mut child = GuestCommand::new(&guest)
|
let mut child = GuestCommand::new(&guest)
|
||||||
.args(&["--cpus", &format!("boot={}", queue_num * 2)])
|
.args(&["--cpus", &format!("boot={}", queue_num * 2)])
|
||||||
@ -617,14 +625,6 @@ pub fn performance_block_io(control: &PerformanceTestControl) -> f64 {
|
|||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
let r = std::panic::catch_unwind(|| {
|
let r = std::panic::catch_unwind(|| {
|
||||||
// Generate a image file for testing
|
|
||||||
assert!(exec_host_command_output(&format!(
|
|
||||||
"dd if=/dev/zero of={} bs=1M count=4096",
|
|
||||||
test_img
|
|
||||||
))
|
|
||||||
.status
|
|
||||||
.success());
|
|
||||||
|
|
||||||
guest.wait_vm_boot(None).unwrap();
|
guest.wait_vm_boot(None).unwrap();
|
||||||
|
|
||||||
// Hotplug test disk
|
// Hotplug test disk
|
||||||
@ -634,7 +634,7 @@ pub fn performance_block_io(control: &PerformanceTestControl) -> f64 {
|
|||||||
"add-disk",
|
"add-disk",
|
||||||
&format!(
|
&format!(
|
||||||
"path={},num_queues={},queue_size={},direct=on",
|
"path={},num_queues={},queue_size={},direct=on",
|
||||||
test_img, queue_num, queue_size
|
BLK_IO_TEST_IMG, queue_num, queue_size
|
||||||
)
|
)
|
||||||
])
|
])
|
||||||
.stderr(Stdio::piped())
|
.stderr(Stdio::piped())
|
||||||
@ -661,8 +661,6 @@ pub fn performance_block_io(control: &PerformanceTestControl) -> f64 {
|
|||||||
parse_fio_output(&output, fio_ops, queue_num).unwrap()
|
parse_fio_output(&output, fio_ops, queue_num).unwrap()
|
||||||
});
|
});
|
||||||
|
|
||||||
test_dir.remove().unwrap();
|
|
||||||
|
|
||||||
let _ = child.kill();
|
let _ = child.kill();
|
||||||
let output = child.wait_with_output().unwrap();
|
let output = child.wait_with_output().unwrap();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user