mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
tests: avoid event wait log spam
Event expectation helpers print detailed diagnostics when the observed event stream does not match the expected one. That is useful for direct assertions, but it becomes extremely noisy [0] when the helper is used as the predicate for wait_until(), because every polling attempt emits the full mismatch dump. Add quiet wait wrappers for event polling and emit the existing detailed diagnostics only once after the timeout expires. [0] https://github.com/cloud-hypervisor/cloud-hypervisor/actions/runs/25745401604/job/75619840718?pr=8021 On-behalf-of: Philipp Schuster@sap.com Signed-off-by: Philipp Schuster <philipp.schuster@cyberus-technology.de>
This commit is contained in:
committed by
Bo Chen
parent
96c83168a1
commit
b0f92d01fc
@@ -5783,9 +5783,11 @@ mod common_parallel {
|
||||
event: "panic".to_string(),
|
||||
device_id: None,
|
||||
}];
|
||||
assert!(wait_until(Duration::from_secs(3), || {
|
||||
check_latest_events_exact(&expected_sequential_events, &event_path)
|
||||
}));
|
||||
assert!(wait_for_latest_events_exact(
|
||||
Duration::from_secs(3),
|
||||
&expected_sequential_events,
|
||||
&event_path
|
||||
));
|
||||
});
|
||||
|
||||
kill_child(&mut child);
|
||||
@@ -7537,9 +7539,11 @@ mod ivshmem {
|
||||
device_id: None,
|
||||
}];
|
||||
// Wait for the restored event to show up in the monitor file.
|
||||
assert!(wait_until(Duration::from_secs(30), || {
|
||||
check_latest_events_exact(&latest_events, &event_path_restored)
|
||||
}));
|
||||
assert!(wait_for_latest_events_exact(
|
||||
Duration::from_secs(30),
|
||||
&latest_events,
|
||||
&event_path_restored
|
||||
));
|
||||
|
||||
// Remove the snapshot dir
|
||||
let _ = remove_dir_all(snapshot_dir.as_str());
|
||||
@@ -7562,9 +7566,11 @@ mod ivshmem {
|
||||
device_id: None,
|
||||
},
|
||||
];
|
||||
assert!(wait_until(Duration::from_secs(30), || {
|
||||
check_latest_events_exact(&latest_events, &event_path_restored)
|
||||
}));
|
||||
assert!(wait_for_latest_events_exact(
|
||||
Duration::from_secs(30),
|
||||
&latest_events,
|
||||
&event_path_restored
|
||||
));
|
||||
|
||||
// Check the number of vCPUs
|
||||
assert_eq!(guest.get_cpu_count().unwrap_or_default(), 2);
|
||||
@@ -7663,9 +7669,11 @@ mod snapshot_restore_common {
|
||||
},
|
||||
];
|
||||
|
||||
assert!(wait_until(Duration::from_secs(30), || {
|
||||
check_latest_events_exact(&latest_events, event_path)
|
||||
}));
|
||||
assert!(wait_for_latest_events_exact(
|
||||
Duration::from_secs(30),
|
||||
&latest_events,
|
||||
event_path
|
||||
));
|
||||
|
||||
// Take a snapshot from the VM
|
||||
assert!(remote_command(
|
||||
@@ -7685,9 +7693,11 @@ mod snapshot_restore_common {
|
||||
},
|
||||
];
|
||||
|
||||
assert!(wait_until(Duration::from_secs(30), || {
|
||||
check_latest_events_exact(&latest_events, event_path)
|
||||
}));
|
||||
assert!(wait_for_latest_events_exact(
|
||||
Duration::from_secs(30),
|
||||
&latest_events,
|
||||
event_path
|
||||
));
|
||||
}
|
||||
|
||||
pub(crate) fn _test_snapshot_restore(use_hotplug: bool, use_resume_option: bool) {
|
||||
@@ -7800,9 +7810,11 @@ mod snapshot_restore_common {
|
||||
event: "device-removed".to_string(),
|
||||
device_id: Some(net_id.to_string()),
|
||||
}];
|
||||
assert!(wait_until(Duration::from_secs(30), || {
|
||||
check_latest_events_exact(&latest_events, &event_path)
|
||||
}));
|
||||
assert!(wait_for_latest_events_exact(
|
||||
Duration::from_secs(30),
|
||||
&latest_events,
|
||||
&event_path
|
||||
));
|
||||
|
||||
// Plug the virtio-net device again
|
||||
assert!(remote_command(
|
||||
@@ -7874,9 +7886,11 @@ mod snapshot_restore_common {
|
||||
device_id: None,
|
||||
},
|
||||
];
|
||||
assert!(wait_until(Duration::from_secs(30), || {
|
||||
check_sequential_events(&expected_events, &event_path_restored)
|
||||
}));
|
||||
assert!(wait_for_sequential_events(
|
||||
Duration::from_secs(30),
|
||||
&expected_events,
|
||||
&event_path_restored
|
||||
));
|
||||
if use_resume_option {
|
||||
let latest_events = [
|
||||
&MetaEvent {
|
||||
@@ -7892,17 +7906,21 @@ mod snapshot_restore_common {
|
||||
device_id: None,
|
||||
},
|
||||
];
|
||||
assert!(wait_until(Duration::from_secs(30), || {
|
||||
check_latest_events_exact(&latest_events, &event_path_restored)
|
||||
}));
|
||||
assert!(wait_for_latest_events_exact(
|
||||
Duration::from_secs(30),
|
||||
&latest_events,
|
||||
&event_path_restored
|
||||
));
|
||||
} else {
|
||||
let latest_events = [&MetaEvent {
|
||||
event: "restored".to_string(),
|
||||
device_id: None,
|
||||
}];
|
||||
assert!(wait_until(Duration::from_secs(30), || {
|
||||
check_latest_events_exact(&latest_events, &event_path_restored)
|
||||
}));
|
||||
assert!(wait_for_latest_events_exact(
|
||||
Duration::from_secs(30),
|
||||
&latest_events,
|
||||
&event_path_restored
|
||||
));
|
||||
}
|
||||
|
||||
// Wait until the restored VM API is ready before issuing follow-up requests.
|
||||
@@ -7938,9 +7956,11 @@ mod snapshot_restore_common {
|
||||
device_id: None,
|
||||
},
|
||||
];
|
||||
assert!(wait_until(Duration::from_secs(30), || {
|
||||
check_latest_events_exact(&latest_events, &event_path_restored)
|
||||
}));
|
||||
assert!(wait_for_latest_events_exact(
|
||||
Duration::from_secs(30),
|
||||
&latest_events,
|
||||
&event_path_restored
|
||||
));
|
||||
}
|
||||
|
||||
// Perform same checks to validate VM has been properly restored
|
||||
@@ -8062,9 +8082,11 @@ mod snapshot_restore_common {
|
||||
device_id: None,
|
||||
}];
|
||||
|
||||
assert!(wait_until(Duration::from_secs(30), || {
|
||||
check_latest_events_exact(&latest_events, &event_path_restored)
|
||||
}));
|
||||
assert!(wait_for_latest_events_exact(
|
||||
Duration::from_secs(30),
|
||||
&latest_events,
|
||||
&event_path_restored
|
||||
));
|
||||
|
||||
let r = std::panic::catch_unwind(|| {
|
||||
assert!(wait_until(Duration::from_secs(30), || remote_command(
|
||||
@@ -8084,9 +8106,11 @@ mod snapshot_restore_common {
|
||||
device_id: None,
|
||||
},
|
||||
];
|
||||
assert!(wait_until(Duration::from_secs(30), || {
|
||||
check_latest_events_exact(&latest_events, &event_path_restored)
|
||||
}));
|
||||
assert!(wait_for_latest_events_exact(
|
||||
Duration::from_secs(30),
|
||||
&latest_events,
|
||||
&event_path_restored
|
||||
));
|
||||
|
||||
assert_eq!(guest.get_cpu_count().unwrap_or_default(), 4);
|
||||
assert!(guest.get_total_memory().unwrap_or_default() > min_total_memory_kib);
|
||||
@@ -8191,9 +8215,11 @@ mod snapshot_restore_common {
|
||||
event: "restored".to_string(),
|
||||
device_id: None,
|
||||
}];
|
||||
assert!(wait_until(Duration::from_secs(30), || {
|
||||
check_latest_events_exact(&latest_events, &event_path_restored)
|
||||
}));
|
||||
assert!(wait_for_latest_events_exact(
|
||||
Duration::from_secs(30),
|
||||
&latest_events,
|
||||
&event_path_restored
|
||||
));
|
||||
|
||||
let _ = remove_dir_all(snapshot_dir.as_str());
|
||||
|
||||
@@ -8214,9 +8240,11 @@ mod snapshot_restore_common {
|
||||
device_id: None,
|
||||
},
|
||||
];
|
||||
assert!(wait_until(Duration::from_secs(30), || {
|
||||
check_latest_events_exact(&latest_events, &event_path_restored)
|
||||
}));
|
||||
assert!(wait_for_latest_events_exact(
|
||||
Duration::from_secs(30),
|
||||
&latest_events,
|
||||
&event_path_restored
|
||||
));
|
||||
|
||||
assert_eq!(guest.get_cpu_count().unwrap_or_default(), 2);
|
||||
guest.check_devices_common(Some(&socket), Some(&console_text), None);
|
||||
@@ -8451,16 +8479,20 @@ mod common_sequential {
|
||||
},
|
||||
];
|
||||
// Wait for the restore event sequence to be recorded.
|
||||
assert!(wait_until(Duration::from_secs(30), || {
|
||||
check_sequential_events(&expected_events, &event_path_restored)
|
||||
}));
|
||||
assert!(wait_for_sequential_events(
|
||||
Duration::from_secs(30),
|
||||
&expected_events,
|
||||
&event_path_restored
|
||||
));
|
||||
let latest_events = [&MetaEvent {
|
||||
event: "restored".to_string(),
|
||||
device_id: None,
|
||||
}];
|
||||
assert!(wait_until(Duration::from_secs(30), || {
|
||||
check_latest_events_exact(&latest_events, &event_path_restored)
|
||||
}));
|
||||
assert!(wait_for_latest_events_exact(
|
||||
Duration::from_secs(30),
|
||||
&latest_events,
|
||||
&event_path_restored
|
||||
));
|
||||
|
||||
// Remove the snapshot dir
|
||||
let _ = remove_dir_all(snapshot_dir.as_str());
|
||||
@@ -8484,9 +8516,11 @@ mod common_sequential {
|
||||
device_id: None,
|
||||
},
|
||||
];
|
||||
assert!(wait_until(Duration::from_secs(30), || {
|
||||
check_latest_events_exact(&latest_events, &event_path_restored)
|
||||
}));
|
||||
assert!(wait_for_latest_events_exact(
|
||||
Duration::from_secs(30),
|
||||
&latest_events,
|
||||
&event_path_restored
|
||||
));
|
||||
|
||||
// Perform same checks to validate VM has been properly restored
|
||||
assert_eq!(guest.get_cpu_count().unwrap_or_default(), n_cpu);
|
||||
|
||||
Reference in New Issue
Block a user