mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2025-01-12 15:42:57 +00:00
tests: Rely on wtmp
(the login records) to count reboot times
The systemd journal has a known issue of generating large size logs[1], which makes it unreliable as a source for retrieving system information, such as for counting reboot times. This is particularly problematic on disk-constrained systems, like the VMs we launched for our integration tests, where the disk size is normally 2GB. By default, the systemd journal has a size limit of 10% of the size of the underlying file system (e.g. around 200MB for the VMs of our integration tests), which would remove archived journal files on demand. A better alternative to count reboot times is based on information from `wtmp` (e.g. the login records) which is much more concise and can be accessed via the `last` command. [1] https://github.com/systemd/systemd/issues/5285 Fixes: #4749 Signed-off-by: Bo Chen <chen.bo@intel.com>
This commit is contained in:
parent
ffc222b26e
commit
958ef69295
@ -1085,7 +1085,7 @@ impl Guest {
|
||||
}
|
||||
|
||||
pub fn reboot_linux(&self, current_reboot_count: u32, custom_timeout: Option<i32>) {
|
||||
let list_boots_cmd = "sudo journalctl --list-boots | wc -l";
|
||||
let list_boots_cmd = "sudo last | grep -c reboot";
|
||||
let boot_count = self
|
||||
.ssh_command(list_boots_cmd)
|
||||
.unwrap()
|
||||
|
@ -1882,11 +1882,8 @@ fn _test_virtio_iommu(acpi: bool) {
|
||||
}
|
||||
|
||||
fn get_reboot_count(guest: &Guest) -> u32 {
|
||||
// Ensure that the current boot journal is written so reboot counts are valid
|
||||
guest.ssh_command("sudo journalctl --sync").unwrap();
|
||||
|
||||
guest
|
||||
.ssh_command("sudo journalctl --list-boots | wc -l")
|
||||
.ssh_command("sudo last | grep -c reboot")
|
||||
.unwrap()
|
||||
.trim()
|
||||
.parse::<u32>()
|
||||
|
Loading…
x
Reference in New Issue
Block a user