Skip to content

Commit e9afdb5

Browse files
Sebastien Boeufbryteise
authored andcommitted
ch_integration_tests: Add huge memory test
Adding a new integration test to validate the VM gets created with the expected amount of memory. Signed-off-by: Sebastien Boeuf <[email protected]>
1 parent 53f8ec9 commit e9afdb5

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

ch_integration_tests/tests/integration.rs

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,13 @@ mod tests {
182182
.parse()
183183
.map_err(Error::Parsing)
184184
}
185+
186+
fn get_total_memory(&self) -> Result<u32, Error> {
187+
self.ssh_command("grep MemTotal /proc/meminfo | grep -o \"[0-9]*\"")?
188+
.trim()
189+
.parse()
190+
.map_err(Error::Parsing)
191+
}
185192
}
186193

187194
fn spawn_libvirtd() -> io::Result<Child> {
@@ -258,6 +265,45 @@ mod tests {
258265
assert!(r.is_ok());
259266
}
260267

268+
#[test]
269+
fn test_huge_memory() {
270+
cleanup_libvirt_state();
271+
let mut libvirtd = spawn_libvirtd().unwrap();
272+
thread::sleep(std::time::Duration::new(5, 0));
273+
274+
let mut disk = UbuntuDiskConfig::new(FOCAL_IMAGE_NAME.to_owned());
275+
let guest = Guest::new(&mut disk);
276+
277+
let domain_path = guest.create_domain(DEFAULT_VCPUS, 128 << 30);
278+
279+
let r = std::panic::catch_unwind(|| {
280+
spawn_virsh(&["create", domain_path.to_str().unwrap()])
281+
.unwrap()
282+
.wait()
283+
.unwrap();
284+
285+
guest.wait_vm_boot(None).unwrap();
286+
287+
assert!(guest.get_total_memory().unwrap_or_default() > 128_000_000);
288+
});
289+
290+
spawn_virsh(&["destroy", &guest.vm_name])
291+
.unwrap()
292+
.wait()
293+
.unwrap();
294+
295+
libvirtd.kill().unwrap();
296+
let libvirtd_output = libvirtd.wait_with_output().unwrap();
297+
298+
eprintln!(
299+
"libvirtd stdout\n\n{}\n\nlibvirtd stderr\n\n{}",
300+
std::str::from_utf8(&libvirtd_output.stdout).unwrap(),
301+
std::str::from_utf8(&libvirtd_output.stderr).unwrap()
302+
);
303+
304+
assert!(r.is_ok());
305+
}
306+
261307
#[test]
262308
fn test_multi_cpu() {
263309
cleanup_libvirt_state();

0 commit comments

Comments
 (0)