mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
tests: Enhance test_disk_hotplug to also unplug device
Ensure that the device is removed and the removed device stays away after a reboot. Signed-off-by: Rob Bradford <robert.bradford@intel.com>
This commit is contained in:
committed by
Samuel Ortiz
parent
f9a0445c3d
commit
6389418fa6
@@ -3668,7 +3668,10 @@ mod tests {
|
|||||||
remote_command(
|
remote_command(
|
||||||
&api_socket,
|
&api_socket,
|
||||||
"add-disk",
|
"add-disk",
|
||||||
Some(&format!("path={}", blk_file_path.to_str().unwrap()))
|
Some(&format!(
|
||||||
|
"path={},id=test0",
|
||||||
|
blk_file_path.to_str().unwrap()
|
||||||
|
))
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -3707,6 +3710,48 @@ mod tests {
|
|||||||
1
|
1
|
||||||
);
|
);
|
||||||
|
|
||||||
|
aver!(
|
||||||
|
tb,
|
||||||
|
remote_command(&api_socket, "remove-device", Some("test0"))
|
||||||
|
);
|
||||||
|
|
||||||
|
thread::sleep(std::time::Duration::new(20, 0));
|
||||||
|
|
||||||
|
// Check device has gone away
|
||||||
|
aver_eq!(
|
||||||
|
tb,
|
||||||
|
guest
|
||||||
|
.ssh_command("lsblk | grep vdc | grep -c 16M")
|
||||||
|
.unwrap_or_default()
|
||||||
|
.trim()
|
||||||
|
.parse::<u32>()
|
||||||
|
.unwrap_or(1),
|
||||||
|
0
|
||||||
|
);
|
||||||
|
|
||||||
|
guest.ssh_command("sudo reboot").unwrap_or_default();
|
||||||
|
|
||||||
|
thread::sleep(std::time::Duration::new(20, 0));
|
||||||
|
let reboot_count = guest
|
||||||
|
.ssh_command("sudo journalctl | grep -c -- \"-- Reboot --\"")
|
||||||
|
.unwrap_or_default()
|
||||||
|
.trim()
|
||||||
|
.parse::<u32>()
|
||||||
|
.unwrap_or_default();
|
||||||
|
aver_eq!(tb, reboot_count, 2);
|
||||||
|
|
||||||
|
// Check device still absent
|
||||||
|
aver_eq!(
|
||||||
|
tb,
|
||||||
|
guest
|
||||||
|
.ssh_command("lsblk | grep vdc | grep -c 16M")
|
||||||
|
.unwrap_or_default()
|
||||||
|
.trim()
|
||||||
|
.parse::<u32>()
|
||||||
|
.unwrap_or(1),
|
||||||
|
0
|
||||||
|
);
|
||||||
|
|
||||||
let _ = child.kill();
|
let _ = child.kill();
|
||||||
let _ = child.wait();
|
let _ = child.wait();
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|||||||
Reference in New Issue
Block a user