From 2eafee69bee6eb22ef06875c8e24e5a02a6e9ec7 Mon Sep 17 00:00:00 2001 From: Rob Bradford Date: Wed, 15 Apr 2026 08:46:35 +0100 Subject: [PATCH] tests: Remove explicit sleeps from balloon tests Use the new `wait_until()` to test the balloon size. Signed-off-by: Rob Bradford --- cloud-hypervisor/tests/integration.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/cloud-hypervisor/tests/integration.rs b/cloud-hypervisor/tests/integration.rs index cc24cb8eb..c009a0ed6 100644 --- a/cloud-hypervisor/tests/integration.rs +++ b/cloud-hypervisor/tests/integration.rs @@ -4752,8 +4752,9 @@ mod common_parallel { // Wait for balloon memory's initialization and check its size. // The virtio-balloon driver might take a few seconds to report the // balloon effective size back to the VMM. - thread::sleep(std::time::Duration::new(20, 0)); - + assert!(wait_until(Duration::from_secs(20), || { + balloon_size(&api_socket) == 2147483648 + })); let orig_balloon = balloon_size(&api_socket); println!("The original balloon memory size is {orig_balloon} bytes"); assert!(orig_balloon == 2147483648); @@ -4766,7 +4767,9 @@ mod common_parallel { // Give some time for the OOM to happen in the guest and be reported // back to the host. - thread::sleep(std::time::Duration::new(20, 0)); + assert!(wait_until(Duration::from_secs(20), || { + balloon_size(&api_socket) < 2147483648 + })); // 2nd: check balloon_mem's value to verify balloon has been automatically deflated let deflated_balloon = balloon_size(&api_socket);