From 77ce956c2dac0f23035d75a9a97feae3e5585a47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Date: Mon, 16 Oct 2017 01:57:17 +0200 Subject: [PATCH] tests: improve root volume resize tests - clone all features, not just qrexec (especially include 'gui') - do not leak VM reference on failed test - add test for online root volume resize QubesOS/qubes-issues#3173 --- qubes/tests/integ/basic.py | 41 ++++++++++++++++++++++++++++++++++---- 1 file changed, 37 insertions(+), 4 deletions(-) diff --git a/qubes/tests/integ/basic.py b/qubes/tests/integ/basic.py index e939aab9..0b312c4b 100644 --- a/qubes/tests/integ/basic.py +++ b/qubes/tests/integ/basic.py @@ -534,22 +534,30 @@ class TC_05_StandaloneVM(qubes.tests.SystemTestCase): def test_000_create_start(self): self.testvm1 = self.app.add_new_vm(qubes.vm.standalonevm.StandaloneVM, name=self.make_vm_name('vm1'), label='red') - self.testvm1.features['qrexec'] = True + self.testvm1.features.update(self.app.default_template.features) self.loop.run_until_complete( self.testvm1.clone_disk_files(self.app.default_template)) self.app.save() self.loop.run_until_complete(self.testvm1.start()) self.assertEqual(self.testvm1.get_power_state(), "Running") + # current qubes-core-agent do not call resize2fs on VM startup, also #3173 + @unittest.expectedFailure def test_100_resize_root_img(self): self.testvm1 = self.app.add_new_vm(qubes.vm.standalonevm.StandaloneVM, name=self.make_vm_name('vm1'), label='red') - self.testvm1.features['qrexec'] = True + self.testvm1.features.update(self.app.default_template.features) self.loop.run_until_complete( self.testvm1.clone_disk_files(self.app.default_template)) self.app.save() - self.loop.run_until_complete( - self.testvm1.storage.resize(self.testvm1.volumes['root'], 20 * 1024 ** 3)) + try: + self.loop.run_until_complete( + self.testvm1.storage.resize(self.testvm1.volumes['root'], + 20 * 1024 ** 3)) + except (subprocess.CalledProcessError, + qubes.storage.StoragePoolException) as e: + # exception object would leak VM reference + self.fail(str(e)) self.assertEqual(self.testvm1.volumes['root'].size, 20 * 1024 ** 3) self.loop.run_until_complete(self.testvm1.start()) # new_size in 1k-blocks @@ -558,6 +566,31 @@ class TC_05_StandaloneVM(qubes.tests.SystemTestCase): # some safety margin for FS metadata self.assertGreater(int(new_size.strip()), 19 * 1024 ** 2) + # See issue #3173 + @unittest.expectedFailure + def test_101_resize_root_img_online(self): + self.testvm1 = self.app.add_new_vm(qubes.vm.standalonevm.StandaloneVM, + name=self.make_vm_name('vm1'), label='red') + self.testvm1.features['qrexec'] = True + self.loop.run_until_complete( + self.testvm1.clone_disk_files(self.app.default_template)) + self.testvm1.features.update(self.app.default_template.features) + self.app.save() + self.loop.run_until_complete(self.testvm1.start()) + try: + self.loop.run_until_complete( + self.testvm1.storage.resize(self.testvm1.volumes['root'], + 20 * 1024 ** 3)) + except (subprocess.CalledProcessError, + qubes.storage.StoragePoolException) as e: + # exception object would leak VM reference + self.fail(str(e)) + self.assertEqual(self.testvm1.volumes['root'].size, 20 * 1024 ** 3) + # new_size in 1k-blocks + (new_size, _) = self.loop.run_until_complete( + self.testvm1.run_for_stdio('df --output=size /|tail -n 1')) + # some safety margin for FS metadata + self.assertGreater(int(new_size.strip()), 19 * 1024 ** 2) # vim: ts=4 sw=4 et