From 2c395d4ae8c1fd866708a6265302d849db1e8a67 Mon Sep 17 00:00:00 2001 From: Philipp Schuster Date: Fri, 10 Apr 2026 13:36:34 +0200 Subject: [PATCH] tests: Plumping to retry when event monitor output is not ready Treat missing or still-short event monitor files as a retryable state in integration test helpers. This keeps polling-based restore and snapshot checks from failing early with file-not-found or short-file assertions while the monitor output is still being written. In the following, we can gracefully wait for the corresponding conditions to become true. On-behalf-of: SAP philipp.schuster@sap.com Signed-off-by: Philipp Schuster --- cloud-hypervisor/tests/common/utils.rs | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/cloud-hypervisor/tests/common/utils.rs b/cloud-hypervisor/tests/common/utils.rs index 5064e1970..f7cc1ea18 100644 --- a/cloud-hypervisor/tests/common/utils.rs +++ b/cloud-hypervisor/tests/common/utils.rs @@ -498,6 +498,9 @@ fn parse_event_file(event_file: &str) -> Vec { // Return true if all events from the input 'expected_events' are matched sequentially // with events from the 'event_file' pub(crate) fn check_sequential_events(expected_events: &[&MetaEvent], event_file: &str) -> bool { + if !Path::new(event_file).exists() { + return false; + } let json_events = parse_event_file(event_file); let len = expected_events.len(); let mut idx = 0; @@ -529,8 +532,13 @@ pub(crate) fn check_sequential_events_exact( expected_events: &[&MetaEvent], event_file: &str, ) -> bool { + if !Path::new(event_file).exists() { + return false; + } let json_events = parse_event_file(event_file); - assert!(expected_events.len() <= json_events.len()); + if expected_events.len() > json_events.len() { + return false; + } let json_events = &json_events[..expected_events.len()]; for (idx, e) in json_events.iter().enumerate() { @@ -551,8 +559,13 @@ pub(crate) fn check_sequential_events_exact( // Return true if events from the input 'latest_events' are matched exactly // with the most recent events from the 'event_file' pub(crate) fn check_latest_events_exact(latest_events: &[&MetaEvent], event_file: &str) -> bool { + if !Path::new(event_file).exists() { + return false; + } let json_events = parse_event_file(event_file); - assert!(latest_events.len() <= json_events.len()); + if latest_events.len() > json_events.len() { + return false; + } let json_events = &json_events[(json_events.len() - latest_events.len())..]; for (idx, e) in json_events.iter().enumerate() {