Skip to content

Commit 7193ca2

Browse files
committed
ch: libvirt restart test
1 parent 4996626 commit 7193ca2

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

ch_integration_tests/tests/integration.rs

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,46 @@ mod tests {
349349
.starts_with(&format!("Domain {} has been undefined", guest.vm_name)));
350350
}
351351

352+
#[test]
353+
fn test_libvirt_restart() {
354+
cleanup_libvirt_state();
355+
let mut libvirtd = spawn_libvirtd().unwrap();
356+
thread::sleep(std::time::Duration::new(5, 0));
357+
358+
let mut disk = UbuntuDiskConfig::new(FOCAL_IMAGE_NAME.to_owned());
359+
let guest = Guest::new(&mut disk);
360+
let domain_path = guest.create_domain(VcpuConfig::default(), DEFAULT_RAM_SIZE);
361+
362+
spawn_virsh(&["create", domain_path.to_str().unwrap()])
363+
.unwrap()
364+
.wait()
365+
.unwrap();
366+
367+
guest.wait_vm_boot(None).unwrap();
368+
libvirtd.kill().unwrap();
369+
let mut libvirtd = spawn_libvirtd().unwrap();
370+
thread::sleep(std::time::Duration::new(5, 0));
371+
372+
let destroy_output = spawn_virsh(&["destroy", &guest.vm_name])
373+
.unwrap()
374+
.wait_with_output()
375+
.unwrap();
376+
377+
libvirtd.kill().unwrap();
378+
let libvirtd_output = libvirtd.wait_with_output().unwrap();
379+
380+
eprintln!(
381+
"libvirtd stdout\n\n{}\n\nlibvirtd stderr\n\n{}",
382+
std::str::from_utf8(&libvirtd_output.stdout).unwrap(),
383+
std::str::from_utf8(&libvirtd_output.stderr).unwrap()
384+
);
385+
386+
assert!(std::str::from_utf8(&destroy_output.stdout)
387+
.unwrap()
388+
.trim()
389+
.starts_with(&format!("Domain {} destroyed", guest.vm_name)));
390+
}
391+
352392
#[test]
353393
fn test_huge_memory() {
354394
cleanup_libvirt_state();

0 commit comments

Comments
 (0)