From 69905508846e2fe84b9855241c6926a1cad16b46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Date: Tue, 3 Oct 2017 11:58:39 +0200 Subject: [PATCH] tests: more tests fixes, drop expectedFailure where not needed anymore --- qubes/tests/integ/basic.py | 10 ++++----- qubes/tests/integ/network.py | 42 +++++++++++++++++++----------------- 2 files changed, 27 insertions(+), 25 deletions(-) diff --git a/qubes/tests/integ/basic.py b/qubes/tests/integ/basic.py index 029ca9ea..67b5f44c 100644 --- a/qubes/tests/integ/basic.py +++ b/qubes/tests/integ/basic.py @@ -95,7 +95,6 @@ class TC_01_Properties(qubes.tests.SystemTestCase): def cleanup_props(self): del self.vm - @unittest.expectedFailure def test_030_clone(self): try: testvm1 = self.app.add_new_vm( @@ -109,6 +108,7 @@ class TC_01_Properties(qubes.tests.SystemTestCase): template=testvm1.template, label='red') testvm2.clone_properties(testvm1) + testvm2.firewall.clone(testvm1.firewall) self.loop.run_until_complete(testvm2.clone_disk_files(testvm1)) self.assertTrue(self.loop.run_until_complete(testvm1.storage.verify())) self.assertIn('source', testvm1.volumes['root'].config) @@ -156,6 +156,7 @@ class TC_01_Properties(qubes.tests.SystemTestCase): template=testvm1.template, label='red',) testvm3.clone_properties(testvm1) + testvm3.firewall.clone(testvm1.firewall) self.loop.run_until_complete(testvm3.clone_disk_files(testvm1)) # qubes.xml reload @@ -181,7 +182,7 @@ class TC_01_Properties(qubes.tests.SystemTestCase): self.assertEqual(testvm1.default_user, testvm3.default_user) self.assertEqual(testvm1.features, testvm3.features) self.assertEqual(testvm1.firewall.rules, - testvm2.firewall.rules) + testvm3.firewall.rules) finally: try: del firewall @@ -359,6 +360,7 @@ class TC_03_QvmRevertTemplateChanges(qubes.tests.SystemTestCase): self.test_template.tags.update(self.app.default_template.tags) self.loop.run_until_complete( self.test_template.clone_disk_files(self.app.default_template)) + self.test_template.volumes['root'].revisions_to_keep = 3 self.app.save() def get_rootimg_checksum(self): @@ -374,8 +376,7 @@ class TC_03_QvmRevertTemplateChanges(qubes.tests.SystemTestCase): self.log.warning("template not modified, test result will be " "unreliable") self.assertNotEqual(self.test_template.volumes['root'].revisions, {}) - pool_vid = repr(self.test_template.volumes['root']).strip("'") - revert_cmd = ['qvm-block', 'revert', pool_vid] + revert_cmd = ['qvm-volume', 'revert', self.test_template.name + ':root'] p = self.loop.run_until_complete(asyncio.create_subprocess_exec( *revert_cmd)) self.loop.run_until_complete(p.wait()) @@ -385,7 +386,6 @@ class TC_03_QvmRevertTemplateChanges(qubes.tests.SystemTestCase): checksum_after = self.get_rootimg_checksum() self.assertEqual(checksum_before, checksum_after) - @unittest.expectedFailure def test_000_revert_linux(self): """ Test qvm-revert-template-changes for PV template diff --git a/qubes/tests/integ/network.py b/qubes/tests/integ/network.py index 7f4f01bf..1da0f4eb 100644 --- a/qubes/tests/integ/network.py +++ b/qubes/tests/integ/network.py @@ -486,7 +486,7 @@ class VmNetworkingMixin(object): try: cmd = 'iptables -I INPUT -s {} -j ACCEPT'.format(self.testvm2.ip) - self.loop.run_until_complete(self.proxy.run_for_stdio( + self.loop.run_until_complete(self.testvm1.run_for_stdio( cmd, user='root')) except subprocess.CalledProcessError as e: raise AssertionError( @@ -912,27 +912,29 @@ SHA256: self.loop.run_until_complete(self.testvm1.start()) self.configure_test_repo() - # update repository metadata - p = self.loop.run_until_complete(self.testvm1.run( - self.update_cmd, user='root', stdout=subprocess.PIPE, - stderr=subprocess.PIPE)) - (stdout, stderr) = self.loop.run_until_complete(p.communicate()) - self.assertIn(self.loop.run_until_complete(p.wait()), self.exit_code_ok, - '{}: {}\n{}'.format(self.update_cmd, stdout, stderr)) + with self.qrexec_policy('qubes.UpdatesProxy', self.testvm1, + '$default', action='allow,target=' + self.netvm_repo.name): + # update repository metadata + p = self.loop.run_until_complete(self.testvm1.run( + self.update_cmd, user='root', stdout=subprocess.PIPE, + stderr=subprocess.PIPE)) + (stdout, stderr) = self.loop.run_until_complete(p.communicate()) + self.assertIn(self.loop.run_until_complete(p.wait()), self.exit_code_ok, + '{}: {}\n{}'.format(self.update_cmd, stdout, stderr)) - # install test package - p = self.loop.run_until_complete(self.testvm1.run( - self.install_cmd.format('test-pkg'), user='root')) - (stdout, stderr) = self.loop.run_until_complete(p.communicate()) - self.assertIn(self.loop.run_until_complete(p.wait()), self.exit_code_ok, - '{}: {}\n{}'.format(self.update_cmd, stdout, stderr)) + # install test package + p = self.loop.run_until_complete(self.testvm1.run( + self.install_cmd.format('test-pkg'), user='root')) + (stdout, stderr) = self.loop.run_until_complete(p.communicate()) + self.assertIn(self.loop.run_until_complete(p.wait()), self.exit_code_ok, + '{}: {}\n{}'.format(self.update_cmd, stdout, stderr)) - # verify if it was really installed - p = self.loop.run_until_complete(self.testvm1.run( - self.install_test_cmd.format('test-pkg'), user='root')) - (stdout, stderr) = self.loop.run_until_complete(p.communicate()) - self.assertIn(self.loop.run_until_complete(p.wait()), self.exit_code_ok, - '{}: {}\n{}'.format(self.update_cmd, stdout, stderr)) + # verify if it was really installed + p = self.loop.run_until_complete(self.testvm1.run( + self.install_test_cmd.format('test-pkg'), user='root')) + (stdout, stderr) = self.loop.run_until_complete(p.communicate()) + self.assertIn(self.loop.run_until_complete(p.wait()), self.exit_code_ok, + '{}: {}\n{}'.format(self.update_cmd, stdout, stderr)) def load_tests(loader, tests, pattern): for template in qubes.tests.list_templates():