Skip to content

Commit

Permalink
tests: fix asyncio usage in storage_lvm.TC_01_ThinPool
Browse files Browse the repository at this point in the history
Both vm.create_on_disk() and vm.start() are coroutines. Tests in this
class didn't run them, so basically didn't test anything.

Wrap couroutine calls with self.loop.run_until_complete().

Additionally, don't fail if LVM pool is named differently.
In that case, the test is rather sily, as it probably use the same pool
for source and destination (operation already tested elsewhere). But it
isn't a reason for failing the test.
  • Loading branch information
marmarek committed Oct 23, 2018
1 parent 6170edb commit 299c514
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions qubes/tests/storage_lvm.py
Original file line number Diff line number Diff line change
Expand Up @@ -946,26 +946,27 @@ def test_004_import(self):
vm = self.app.add_new_vm(qubes.vm.templatevm.TemplateVM, name=name,
label='red')
vm.clone_properties(template_vm)
vm.clone_disk_files(template_vm, pool='test-lvm')
self.loop.run_until_complete(
vm.clone_disk_files(template_vm, pool=self.pool.name))
for v_name, volume in vm.volumes.items():
if volume.save_on_stop:
expected = "/dev/{!s}/vm-{!s}-{!s}".format(
DEFAULT_LVM_POOL.split('/')[0], vm.name, v_name)
self.assertEqual(volume.path, expected)
with self.assertNotRaises(qubes.exc.QubesException):
vm.start()
self.loop.run_until_complete(vm.start())

def test_005_create_appvm(self):
vm = self.app.add_new_vm(cls=qubes.vm.appvm.AppVM,
name=self.make_vm_name('appvm'), label='red')
vm.create_on_disk(pool='test-lvm')
self.loop.run_until_complete(vm.create_on_disk(pool=self.pool.name))
for v_name, volume in vm.volumes.items():
if volume.save_on_stop:
expected = "/dev/{!s}/vm-{!s}-{!s}".format(
DEFAULT_LVM_POOL.split('/')[0], vm.name, v_name)
self.assertEqual(volume.path, expected)
with self.assertNotRaises(qubes.exc.QubesException):
vm.start()
self.loop.run_until_complete(vm.start())

@skipUnlessLvmPoolExists
class TC_02_StorageHelpers(ThinPoolBase):
Expand Down

0 comments on commit 299c514

Please sign in to comment.