tests: more tests fixes, drop expectedFailure where not needed anymore

This commit is contained in:
Marek Marczykowski-Górecki 2017-10-03 11:58:39 +02:00
parent e0be7861f9
commit 6990550884
No known key found for this signature in database
GPG Key ID: 063938BA42CFA724
2 changed files with 27 additions and 25 deletions

View File

@ -95,7 +95,6 @@ class TC_01_Properties(qubes.tests.SystemTestCase):
def cleanup_props(self): def cleanup_props(self):
del self.vm del self.vm
@unittest.expectedFailure
def test_030_clone(self): def test_030_clone(self):
try: try:
testvm1 = self.app.add_new_vm( testvm1 = self.app.add_new_vm(
@ -109,6 +108,7 @@ class TC_01_Properties(qubes.tests.SystemTestCase):
template=testvm1.template, template=testvm1.template,
label='red') label='red')
testvm2.clone_properties(testvm1) testvm2.clone_properties(testvm1)
testvm2.firewall.clone(testvm1.firewall)
self.loop.run_until_complete(testvm2.clone_disk_files(testvm1)) self.loop.run_until_complete(testvm2.clone_disk_files(testvm1))
self.assertTrue(self.loop.run_until_complete(testvm1.storage.verify())) self.assertTrue(self.loop.run_until_complete(testvm1.storage.verify()))
self.assertIn('source', testvm1.volumes['root'].config) self.assertIn('source', testvm1.volumes['root'].config)
@ -156,6 +156,7 @@ class TC_01_Properties(qubes.tests.SystemTestCase):
template=testvm1.template, template=testvm1.template,
label='red',) label='red',)
testvm3.clone_properties(testvm1) testvm3.clone_properties(testvm1)
testvm3.firewall.clone(testvm1.firewall)
self.loop.run_until_complete(testvm3.clone_disk_files(testvm1)) self.loop.run_until_complete(testvm3.clone_disk_files(testvm1))
# qubes.xml reload # 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.default_user, testvm3.default_user)
self.assertEqual(testvm1.features, testvm3.features) self.assertEqual(testvm1.features, testvm3.features)
self.assertEqual(testvm1.firewall.rules, self.assertEqual(testvm1.firewall.rules,
testvm2.firewall.rules) testvm3.firewall.rules)
finally: finally:
try: try:
del firewall del firewall
@ -359,6 +360,7 @@ class TC_03_QvmRevertTemplateChanges(qubes.tests.SystemTestCase):
self.test_template.tags.update(self.app.default_template.tags) self.test_template.tags.update(self.app.default_template.tags)
self.loop.run_until_complete( self.loop.run_until_complete(
self.test_template.clone_disk_files(self.app.default_template)) self.test_template.clone_disk_files(self.app.default_template))
self.test_template.volumes['root'].revisions_to_keep = 3
self.app.save() self.app.save()
def get_rootimg_checksum(self): 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 " self.log.warning("template not modified, test result will be "
"unreliable") "unreliable")
self.assertNotEqual(self.test_template.volumes['root'].revisions, {}) self.assertNotEqual(self.test_template.volumes['root'].revisions, {})
pool_vid = repr(self.test_template.volumes['root']).strip("'") revert_cmd = ['qvm-volume', 'revert', self.test_template.name + ':root']
revert_cmd = ['qvm-block', 'revert', pool_vid]
p = self.loop.run_until_complete(asyncio.create_subprocess_exec( p = self.loop.run_until_complete(asyncio.create_subprocess_exec(
*revert_cmd)) *revert_cmd))
self.loop.run_until_complete(p.wait()) self.loop.run_until_complete(p.wait())
@ -385,7 +386,6 @@ class TC_03_QvmRevertTemplateChanges(qubes.tests.SystemTestCase):
checksum_after = self.get_rootimg_checksum() checksum_after = self.get_rootimg_checksum()
self.assertEqual(checksum_before, checksum_after) self.assertEqual(checksum_before, checksum_after)
@unittest.expectedFailure
def test_000_revert_linux(self): def test_000_revert_linux(self):
""" """
Test qvm-revert-template-changes for PV template Test qvm-revert-template-changes for PV template

View File

@ -486,7 +486,7 @@ class VmNetworkingMixin(object):
try: try:
cmd = 'iptables -I INPUT -s {} -j ACCEPT'.format(self.testvm2.ip) 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')) cmd, user='root'))
except subprocess.CalledProcessError as e: except subprocess.CalledProcessError as e:
raise AssertionError( raise AssertionError(
@ -912,27 +912,29 @@ SHA256:
self.loop.run_until_complete(self.testvm1.start()) self.loop.run_until_complete(self.testvm1.start())
self.configure_test_repo() self.configure_test_repo()
# update repository metadata with self.qrexec_policy('qubes.UpdatesProxy', self.testvm1,
p = self.loop.run_until_complete(self.testvm1.run( '$default', action='allow,target=' + self.netvm_repo.name):
self.update_cmd, user='root', stdout=subprocess.PIPE, # update repository metadata
stderr=subprocess.PIPE)) p = self.loop.run_until_complete(self.testvm1.run(
(stdout, stderr) = self.loop.run_until_complete(p.communicate()) self.update_cmd, user='root', stdout=subprocess.PIPE,
self.assertIn(self.loop.run_until_complete(p.wait()), self.exit_code_ok, stderr=subprocess.PIPE))
'{}: {}\n{}'.format(self.update_cmd, stdout, stderr)) (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 # install test package
p = self.loop.run_until_complete(self.testvm1.run( p = self.loop.run_until_complete(self.testvm1.run(
self.install_cmd.format('test-pkg'), user='root')) self.install_cmd.format('test-pkg'), user='root'))
(stdout, stderr) = self.loop.run_until_complete(p.communicate()) (stdout, stderr) = self.loop.run_until_complete(p.communicate())
self.assertIn(self.loop.run_until_complete(p.wait()), self.exit_code_ok, self.assertIn(self.loop.run_until_complete(p.wait()), self.exit_code_ok,
'{}: {}\n{}'.format(self.update_cmd, stdout, stderr)) '{}: {}\n{}'.format(self.update_cmd, stdout, stderr))
# verify if it was really installed # verify if it was really installed
p = self.loop.run_until_complete(self.testvm1.run( p = self.loop.run_until_complete(self.testvm1.run(
self.install_test_cmd.format('test-pkg'), user='root')) self.install_test_cmd.format('test-pkg'), user='root'))
(stdout, stderr) = self.loop.run_until_complete(p.communicate()) (stdout, stderr) = self.loop.run_until_complete(p.communicate())
self.assertIn(self.loop.run_until_complete(p.wait()), self.exit_code_ok, self.assertIn(self.loop.run_until_complete(p.wait()), self.exit_code_ok,
'{}: {}\n{}'.format(self.update_cmd, stdout, stderr)) '{}: {}\n{}'.format(self.update_cmd, stdout, stderr))
def load_tests(loader, tests, pattern): def load_tests(loader, tests, pattern):
for template in qubes.tests.list_templates(): for template in qubes.tests.list_templates():