From 6eaf44ec6106d9e589ba3a2b65b4b4dddc453257 Mon Sep 17 00:00:00 2001 From: Sebastien Boeuf Date: Fri, 30 Apr 2021 09:44:18 +0200 Subject: [PATCH] tests: Update journalctl command to get reboot count In order to support most recent Ubuntu distributions, we must update the way of detecting a reboot through the journal since there is no more "-- Reboot --" logs. Using the `--list-boots` option is the preferred way for getting the boot count information from journalctl command. We simply need to add 1 to the count in order to get the reboot count. Signed-off-by: Sebastien Boeuf --- tests/integration.rs | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/tests/integration.rs b/tests/integration.rs index f1c5ce23b..ae5b07803 100644 --- a/tests/integration.rs +++ b/tests/integration.rs @@ -709,24 +709,25 @@ mod tests { } fn reboot_linux(&self, current_reboot_count: u32, custom_timeout: Option) { - let reboot_count = self - .ssh_command("sudo journalctl | grep -c -- \"-- Reboot --\"") - .unwrap() - .trim() - .parse::() - .unwrap_or(current_reboot_count + 1); - - assert_eq!(reboot_count, current_reboot_count); - self.ssh_command("sudo reboot").unwrap(); - - self.wait_vm_boot(custom_timeout).unwrap(); - let reboot_count = self - .ssh_command("sudo journalctl | grep -c -- \"-- Reboot --\"") + let list_boots_cmd = "sudo journalctl --list-boots | wc -l"; + let boot_count = self + .ssh_command(list_boots_cmd) .unwrap() .trim() .parse::() .unwrap_or_default(); - assert_eq!(reboot_count, current_reboot_count + 1); + + assert_eq!(boot_count, current_reboot_count + 1); + self.ssh_command("sudo reboot").unwrap(); + + self.wait_vm_boot(custom_timeout).unwrap(); + let boot_count = self + .ssh_command(list_boots_cmd) + .unwrap() + .trim() + .parse::() + .unwrap_or_default(); + assert_eq!(boot_count, current_reboot_count + 2); } fn enable_memory_hotplug(&self) {