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.
Este commit está contenido en:
Marek Marczykowski-Górecki 2018-09-13 16:43:24 +02:00
padre 5a1bf11d0d
commit 556a08cb78
No se encontró ninguna clave conocida en la base de datos para esta firma
ID de clave GPG: 063938BA42CFA724

Ver fichero

@ -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())