Browse Source

tests: fix asyncio usage in storage_lvm.TC_01_ThinPool

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.
Marek Marczykowski-Górecki 5 years ago
parent
commit
299c514647
1 changed files with 5 additions and 4 deletions
  1. 5 4
      qubes/tests/storage_lvm.py

+ 5 - 4
qubes/tests/storage_lvm.py

@@ -946,26 +946,27 @@ class TC_01_ThinPool(ThinPoolBase, qubes.tests.SystemTestCase):
         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):