mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2025-04-01 20:04:37 +00:00
ci: Consolidate virtio-blk integration tests
In order to reduce the amount of times VMs are being started through integration tests, this commit consolidates very similar tests related to virtio-blk into a single one. Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
This commit is contained in:
parent
a33e8342ee
commit
9efaff73fa
118
src/main.rs
118
src/main.rs
@ -2551,7 +2551,7 @@ mod tests {
|
||||
}
|
||||
|
||||
#[cfg_attr(not(feature = "mmio"), test)]
|
||||
fn test_virtio_blk_readonly() {
|
||||
fn test_virtio_blk() {
|
||||
test_block!(tb, "", {
|
||||
let mut clear = ClearDiskConfig::new();
|
||||
let guest = Guest::new(&mut clear);
|
||||
@ -2560,7 +2560,7 @@ mod tests {
|
||||
blk_file_path.push("blk.img");
|
||||
|
||||
let mut cloud_child = Command::new("target/release/cloud-hypervisor")
|
||||
.args(&["--cpus", "boot=1"])
|
||||
.args(&["--cpus", "boot=4"])
|
||||
.args(&["--memory", "size=512M,file=/dev/shm"])
|
||||
.args(&["--kernel", guest.fw_path.as_str()])
|
||||
.args(&[
|
||||
@ -2575,7 +2575,11 @@ mod tests {
|
||||
guest.disk_config.disk(DiskType::CloudInit).unwrap()
|
||||
)
|
||||
.as_str(),
|
||||
format!("path={},readonly=on", blk_file_path.to_str().unwrap()).as_str(),
|
||||
format!(
|
||||
"path={},readonly=on,direct=on,num_queues=4",
|
||||
blk_file_path.to_str().unwrap()
|
||||
)
|
||||
.as_str(),
|
||||
])
|
||||
.args(&["--net", guest.default_net_string().as_str()])
|
||||
.spawn()
|
||||
@ -2607,114 +2611,6 @@ mod tests {
|
||||
1
|
||||
);
|
||||
|
||||
guest.ssh_command("sudo shutdown -h now")?;
|
||||
thread::sleep(std::time::Duration::new(5, 0));
|
||||
let _ = cloud_child.kill();
|
||||
let _ = cloud_child.wait();
|
||||
|
||||
Ok(())
|
||||
});
|
||||
}
|
||||
|
||||
#[cfg_attr(not(feature = "mmio"), test)]
|
||||
fn test_virtio_blk_direct() {
|
||||
test_block!(tb, "", {
|
||||
let mut clear = ClearDiskConfig::new();
|
||||
let guest = Guest::new(&mut clear);
|
||||
let mut blk_file_path = dirs::home_dir().unwrap();
|
||||
blk_file_path.push("workloads");
|
||||
blk_file_path.push("blk.img");
|
||||
|
||||
let mut cloud_child = Command::new("target/release/cloud-hypervisor")
|
||||
.args(&["--cpus", "boot=1"])
|
||||
.args(&["--memory", "size=512M,file=/dev/shm"])
|
||||
.args(&["--kernel", guest.fw_path.as_str()])
|
||||
.args(&[
|
||||
"--disk",
|
||||
format!(
|
||||
"path={}",
|
||||
guest.disk_config.disk(DiskType::OperatingSystem).unwrap()
|
||||
)
|
||||
.as_str(),
|
||||
format!(
|
||||
"path={}",
|
||||
guest.disk_config.disk(DiskType::CloudInit).unwrap()
|
||||
)
|
||||
.as_str(),
|
||||
format!("path={},direct=on", blk_file_path.to_str().unwrap()).as_str(),
|
||||
])
|
||||
.args(&["--net", guest.default_net_string().as_str()])
|
||||
.spawn()
|
||||
.unwrap();
|
||||
|
||||
thread::sleep(std::time::Duration::new(20, 0));
|
||||
|
||||
// Check both if /dev/vdc exists and if the block size is 16M.
|
||||
aver_eq!(
|
||||
tb,
|
||||
guest
|
||||
.ssh_command("lsblk | grep vdc | grep -c 16M")
|
||||
.unwrap_or_default()
|
||||
.trim()
|
||||
.parse::<u32>()
|
||||
.unwrap_or_default(),
|
||||
1
|
||||
);
|
||||
|
||||
guest.ssh_command("sudo shutdown -h now")?;
|
||||
thread::sleep(std::time::Duration::new(5, 0));
|
||||
let _ = cloud_child.kill();
|
||||
let _ = cloud_child.wait();
|
||||
|
||||
Ok(())
|
||||
});
|
||||
}
|
||||
|
||||
#[cfg_attr(not(feature = "mmio"), test)]
|
||||
fn test_virtio_blk_mq() {
|
||||
test_block!(tb, "", {
|
||||
let mut clear = ClearDiskConfig::new();
|
||||
let guest = Guest::new(&mut clear);
|
||||
let mut blk_file_path = dirs::home_dir().unwrap();
|
||||
blk_file_path.push("workloads");
|
||||
blk_file_path.push("blk.img");
|
||||
|
||||
let mut cloud_child = Command::new("target/release/cloud-hypervisor")
|
||||
.args(&["--cpus", "boot=4"])
|
||||
.args(&["--memory", "size=512M,file=/dev/shm"])
|
||||
.args(&["--kernel", guest.fw_path.as_str()])
|
||||
.args(&[
|
||||
"--disk",
|
||||
format!(
|
||||
"path={}",
|
||||
guest.disk_config.disk(DiskType::OperatingSystem).unwrap()
|
||||
)
|
||||
.as_str(),
|
||||
format!(
|
||||
"path={}",
|
||||
guest.disk_config.disk(DiskType::CloudInit).unwrap()
|
||||
)
|
||||
.as_str(),
|
||||
format!("path={},num_queues=4", blk_file_path.to_str().unwrap()).as_str(),
|
||||
])
|
||||
.args(&["--net", guest.default_net_string().as_str()])
|
||||
.spawn()
|
||||
.unwrap();
|
||||
|
||||
thread::sleep(std::time::Duration::new(20, 0));
|
||||
|
||||
// Check both if /dev/vdc exists and if the block size is 16M.
|
||||
aver_eq!(
|
||||
tb,
|
||||
guest
|
||||
.ssh_command("lsblk | grep vdc | grep -c 16M")
|
||||
.unwrap_or_default()
|
||||
.trim()
|
||||
.parse::<u32>()
|
||||
.unwrap_or_default(),
|
||||
1
|
||||
);
|
||||
|
||||
// Check if the number of queues is 4.
|
||||
aver_eq!(
|
||||
tb,
|
||||
|
Loading…
x
Reference in New Issue
Block a user