From 556a08cb783e91085f2d0696c17331f820b8d07f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Date: Thu, 13 Sep 2018 16:43:24 +0200 Subject: [PATCH] tests: improve shutdown timeout handling Instead of waiting 1sec, wait up to 5sec but skip when vm is shut off. This fix tests on slow machines, including openQA nested virt. --- qubes/tests/integ/basic.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/qubes/tests/integ/basic.py b/qubes/tests/integ/basic.py index 5a7a73bd..9c67fc1d 100644 --- a/qubes/tests/integ/basic.py +++ b/qubes/tests/integ/basic.py @@ -109,7 +109,10 @@ class TC_00_Basic(qubes.tests.SystemTestCase): # Type 'poweroff' subprocess.check_call(['xdotool', 'search', '--name', self.vm.name, 'type', 'poweroff\r']) - self.loop.run_until_complete(asyncio.sleep(1)) + for _ in range(5): + if not self.vm.is_running(): + break + self.loop.run_until_complete(asyncio.sleep(1)) self.assertFalse(self.vm.is_running()) def _test_200_on_domain_start(self, vm, event, **_kwargs): @@ -205,6 +208,8 @@ class TC_00_Basic(qubes.tests.SystemTestCase): if self.test_failure_reason: self.fail(self.test_failure_reason) + while self.vm.get_power_state() != 'Halted': + self.loop.run_until_complete(asyncio.sleep(1)) # and give a chance for both domain-shutdown handlers to execute self.loop.run_until_complete(asyncio.sleep(1)) @@ -670,7 +675,10 @@ class TC_06_AppVMMixin(object): # Type 'poweroff' subprocess.check_call(['xdotool', 'search', '--name', self.vm.name, 'type', 'poweroff\r']) - self.loop.run_until_complete(asyncio.sleep(1)) + for _ in range(5): + if not self.vm.is_running(): + break + self.loop.run_until_complete(asyncio.sleep(1)) self.assertFalse(self.vm.is_running())