Merge branch 'tests-20181223'

* tests-20181223:
  tests: drop expectedFailure from qubes_desktop_run test
  tests: grub in HVM qubes
  tests: update dom0_update for new updates available flag
  tests: regression test LVM listing code
  tests/extra: wrap ProcessWrapper.wait() to be asyncio-aware
  tests: adjust backupcompat for new maxmem handling
This commit is contained in:
Marek Marczykowski-Górecki 2019-01-19 03:24:29 +01:00
commit dbd85c75e2
No known key found for this signature in database
GPG Key ID: 063938BA42CFA724
8 changed files with 65 additions and 36 deletions

View File

@ -1363,7 +1363,7 @@ def load_tests(loader, tests, pattern): # pylint: disable=unused-argument
# integration tests # integration tests
'qubes.tests.integ.basic', 'qubes.tests.integ.basic',
'qubes.tests.integ.storage', 'qubes.tests.integ.storage',
'qubes.tests.integ.pvgrub', 'qubes.tests.integ.grub',
'qubes.tests.integ.devices_block', 'qubes.tests.integ.devices_block',
'qubes.tests.integ.devices_pci', 'qubes.tests.integ.devices_pci',
'qubes.tests.integ.dom0_update', 'qubes.tests.integ.dom0_update',

View File

@ -43,6 +43,9 @@ class ProcessWrapper(object):
def communicate(self, input=None): def communicate(self, input=None):
return self._loop.run_until_complete(self._proc.communicate(input)) return self._loop.run_until_complete(self._proc.communicate(input))
def wait(self):
return self._loop.run_until_complete(self._proc.wait())
class VMWrapper(object): class VMWrapper(object):
'''Wrap VM object to provide stable API for basic operations''' '''Wrap VM object to provide stable API for basic operations'''
def __init__(self, vm, loop=None): def __init__(self, vm, loop=None):

View File

@ -424,17 +424,14 @@ class TC_00_BackupCompatibility(
'default_user': qubes.property.DEFAULT, 'default_user': qubes.property.DEFAULT,
'include_in_backups': True, 'include_in_backups': True,
'debug': False, 'debug': False,
'maxmem': 1535, 'maxmem': min(int(self.app.host.memory_total / 1024 / 2), 4000),
'memory': 400, 'memory': 400,
'features': { 'features': {},
'service.meminfo-writer': '1',
},
} }
template_standalone_props = common_props.copy() template_standalone_props = common_props.copy()
template_standalone_props['features'] = { template_standalone_props['features'] = {
'qrexec': '1', 'qrexec': '1',
'gui': '1', 'gui': '1',
'service.meminfo-writer': '1',
} }
self.assertRestored("test-template-clone", self.assertRestored("test-template-clone",
klass=qubes.vm.templatevm.TemplateVM, klass=qubes.vm.templatevm.TemplateVM,
@ -482,17 +479,14 @@ class TC_00_BackupCompatibility(
'default_user': qubes.property.DEFAULT, 'default_user': qubes.property.DEFAULT,
'include_in_backups': True, 'include_in_backups': True,
'debug': False, 'debug': False,
'maxmem': 1535, # 4063 caped by 10*400 'maxmem': min(int(self.app.host.memory_total / 1024 / 2), 4000),
'memory': 400, 'memory': 400,
'features': { 'features': {},
'service.meminfo-writer': '1',
},
} }
template_standalone_props = common_props.copy() template_standalone_props = common_props.copy()
template_standalone_props['features'] = { template_standalone_props['features'] = {
'qrexec': '1', 'qrexec': '1',
'gui': '1', 'gui': '1',
'service.meminfo-writer': '1',
} }
self.assertRestored("test-template-clone", self.assertRestored("test-template-clone",
klass=qubes.vm.templatevm.TemplateVM, klass=qubes.vm.templatevm.TemplateVM,

View File

@ -40,7 +40,6 @@ class TC_00_Dom0UpgradeMixin(object):
""" """
pkg_name = 'qubes-test-pkg' pkg_name = 'qubes-test-pkg'
dom0_update_common_opts = ['--disablerepo=*', '--enablerepo=test'] dom0_update_common_opts = ['--disablerepo=*', '--enablerepo=test']
update_flag_path = '/var/lib/qubes/updates/dom0-updates-available'
@classmethod @classmethod
def generate_key(cls, keydir): def generate_key(cls, keydir):
@ -211,7 +210,7 @@ Test package
subprocess.check_call(['rpm', '-i', filename]) subprocess.check_call(['rpm', '-i', filename])
filename = self.create_pkg(self.tmpdir, self.pkg_name, '2.0') filename = self.create_pkg(self.tmpdir, self.pkg_name, '2.0')
self.send_pkg(filename) self.send_pkg(filename)
open(self.update_flag_path, 'a').close() self.app.domains[0].features['updates-available'] = True
logpath = os.path.join(self.tmpdir, 'dom0-update-output.txt') logpath = os.path.join(self.tmpdir, 'dom0-update-output.txt')
with open(logpath, 'w') as f_log: with open(logpath, 'w') as f_log:
@ -234,16 +233,17 @@ Test package
self.pkg_name)], stdout=subprocess.DEVNULL) self.pkg_name)], stdout=subprocess.DEVNULL)
self.assertEqual(retcode, 0, 'Package {}-2.0 not installed after ' self.assertEqual(retcode, 0, 'Package {}-2.0 not installed after '
'update'.format(self.pkg_name)) 'update'.format(self.pkg_name))
self.assertFalse(os.path.exists(self.update_flag_path), self.assertFalse(
"'updates pending' flag not cleared") self.app.domains[0].features.get('updates-available', False),
"'updates pending' flag not cleared")
def test_005_update_flag_clear(self): def test_005_update_flag_clear(self):
"""Check if 'updates pending' flag is creared""" """Check if 'updates pending' flag is cleared"""
# create any pkg (but not install it) to initialize repo in the VM # create any pkg (but not install it) to initialize repo in the VM
filename = self.create_pkg(self.tmpdir, self.pkg_name, '1.0') filename = self.create_pkg(self.tmpdir, self.pkg_name, '1.0')
self.send_pkg(filename) self.send_pkg(filename)
open(self.update_flag_path, 'a').close() self.app.domains[0].features['updates-available'] = True
logpath = os.path.join(self.tmpdir, 'dom0-update-output.txt') logpath = os.path.join(self.tmpdir, 'dom0-update-output.txt')
with open(logpath, 'w') as f_log: with open(logpath, 'w') as f_log:
@ -265,16 +265,17 @@ Test package
"qubes-dom0-update reported an error: {}". "qubes-dom0-update reported an error: {}".
format(dom0_update_output)) format(dom0_update_output))
self.assertFalse(os.path.exists(self.update_flag_path), self.assertFalse(
"'updates pending' flag not cleared") self.app.domains[0].features.get('updates-available', False),
"'updates pending' flag not cleared")
def test_006_update_flag_clear(self): def test_006_update_flag_clear(self):
"""Check if 'updates pending' flag is creared, using --clean""" """Check if 'updates pending' flag is cleared, using --clean"""
# create any pkg (but not install it) to initialize repo in the VM # create any pkg (but not install it) to initialize repo in the VM
filename = self.create_pkg(self.tmpdir, self.pkg_name, '1.0') filename = self.create_pkg(self.tmpdir, self.pkg_name, '1.0')
self.send_pkg(filename) self.send_pkg(filename)
open(self.update_flag_path, 'a').close() self.app.domains[0].features['updates-available'] = True
# remove also repodata to test #1685 # remove also repodata to test #1685
if os.path.exists('/var/lib/qubes/updates/repodata'): if os.path.exists('/var/lib/qubes/updates/repodata'):
@ -300,8 +301,9 @@ Test package
"qubes-dom0-update reported an error: {}". "qubes-dom0-update reported an error: {}".
format(dom0_update_output)) format(dom0_update_output))
self.assertFalse(os.path.exists(self.update_flag_path), self.assertFalse(
"'updates pending' flag not cleared") self.app.domains[0].features.get('updates-available', False),
"'updates pending' flag not cleared")
def test_010_instal(self): def test_010_instal(self):
filename = self.create_pkg(self.tmpdir, self.pkg_name, '1.0') filename = self.create_pkg(self.tmpdir, self.pkg_name, '1.0')

View File

@ -28,11 +28,12 @@ import unittest
import qubes.tests import qubes.tests
@unittest.skipUnless(os.path.exists('/var/lib/qubes/vm-kernels/pvgrub2'), class GrubBase(object):
'grub-xen package not installed') virt_mode = None
class TC_40_PVGrub(object): kernel = None
def setUp(self): def setUp(self):
super(TC_40_PVGrub, self).setUp() super(GrubBase, self).setUp()
supported = False supported = False
if self.template.startswith('fedora-'): if self.template.startswith('fedora-'):
supported = True supported = True
@ -87,7 +88,7 @@ class TC_40_PVGrub(object):
self.testvm1 = self.app.add_new_vm('StandaloneVM', self.testvm1 = self.app.add_new_vm('StandaloneVM',
name=self.make_vm_name('vm1'), name=self.make_vm_name('vm1'),
label='red') label='red')
self.testvm1.virt_mode = 'pv' self.testvm1.virt_mode = self.virt_mode
self.testvm1.features.update(self.app.domains[self.template].features) self.testvm1.features.update(self.app.domains[self.template].features)
self.loop.run_until_complete( self.loop.run_until_complete(
self.testvm1.clone_disk_files(self.app.domains[self.template])) self.testvm1.clone_disk_files(self.app.domains[self.template]))
@ -96,7 +97,7 @@ class TC_40_PVGrub(object):
kver = self.get_kernel_version(self.testvm1) kver = self.get_kernel_version(self.testvm1)
self.loop.run_until_complete(self.testvm1.shutdown(wait=True)) self.loop.run_until_complete(self.testvm1.shutdown(wait=True))
self.testvm1.kernel = 'pvgrub2' self.testvm1.kernel = self.kernel
self.loop.run_until_complete(self.testvm1.start()) self.loop.run_until_complete(self.testvm1.start())
(actual_kver, _) = self.loop.run_until_complete( (actual_kver, _) = self.loop.run_until_complete(
self.testvm1.run_for_stdio('uname -r')) self.testvm1.run_for_stdio('uname -r'))
@ -105,7 +106,7 @@ class TC_40_PVGrub(object):
def test_010_template_based_vm(self): def test_010_template_based_vm(self):
self.test_template = self.app.add_new_vm('TemplateVM', self.test_template = self.app.add_new_vm('TemplateVM',
name=self.make_vm_name('template'), label='red') name=self.make_vm_name('template'), label='red')
self.test_template.virt_mode = 'pv' self.test_template.virt_mode = self.virt_mode
self.test_template.features.update(self.app.domains[self.template].features) self.test_template.features.update(self.app.domains[self.template].features)
self.loop.run_until_complete( self.loop.run_until_complete(
self.test_template.clone_disk_files(self.app.domains[self.template])) self.test_template.clone_disk_files(self.app.domains[self.template]))
@ -114,15 +115,15 @@ class TC_40_PVGrub(object):
template=self.test_template, template=self.test_template,
name=self.make_vm_name('vm1'), name=self.make_vm_name('vm1'),
label='red') label='red')
self.testvm1.virt_mode = 'pv' self.testvm1.virt_mode = self.virt_mode
self.loop.run_until_complete(self.testvm1.create_on_disk()) self.loop.run_until_complete(self.testvm1.create_on_disk())
self.loop.run_until_complete(self.test_template.start()) self.loop.run_until_complete(self.test_template.start())
self.install_packages(self.test_template) self.install_packages(self.test_template)
kver = self.get_kernel_version(self.test_template) kver = self.get_kernel_version(self.test_template)
self.loop.run_until_complete(self.test_template.shutdown(wait=True)) self.loop.run_until_complete(self.test_template.shutdown(wait=True))
self.test_template.kernel = 'pvgrub2' self.test_template.kernel = self.kernel
self.testvm1.kernel = 'pvgrub2' self.testvm1.kernel = self.kernel
# Check if TemplateBasedVM boots and has the right kernel # Check if TemplateBasedVM boots and has the right kernel
self.loop.run_until_complete( self.loop.run_until_complete(
@ -137,10 +138,23 @@ class TC_40_PVGrub(object):
self.test_template.run_for_stdio('uname -r')) self.test_template.run_for_stdio('uname -r'))
self.assertEquals(actual_kver.strip(), kver) self.assertEquals(actual_kver.strip(), kver)
@unittest.skipUnless(os.path.exists('/var/lib/qubes/vm-kernels/pvgrub2'),
'grub-xen package not installed')
class TC_40_PVGrub(GrubBase):
virt_mode = 'pv'
kernel = 'pvgrub2'
class TC_41_HVMGrub(GrubBase):
virt_mode = 'hvm'
kernel = None
def create_testcases_for_templates(): def create_testcases_for_templates():
return qubes.tests.create_testcases_for_templates('TC_40_PVGrub', yield from qubes.tests.create_testcases_for_templates('TC_40_PVGrub',
TC_40_PVGrub, qubes.tests.SystemTestCase, TC_40_PVGrub, qubes.tests.SystemTestCase,
module=sys.modules[__name__]) module=sys.modules[__name__])
yield from qubes.tests.create_testcases_for_templates('TC_41_HVMGrub',
TC_41_HVMGrub, qubes.tests.SystemTestCase,
module=sys.modules[__name__])
def load_tests(loader, tests, pattern): def load_tests(loader, tests, pattern):
tests.addTests(loader.loadTestsFromNames( tests.addTests(loader.loadTestsFromNames(

View File

@ -135,7 +135,6 @@ class TC_00_AppVMMixin(object):
@unittest.skipUnless(spawn.find_executable('xdotool'), @unittest.skipUnless(spawn.find_executable('xdotool'),
"xdotool not installed") "xdotool not installed")
@unittest.expectedFailure
def test_012_qubes_desktop_run(self): def test_012_qubes_desktop_run(self):
self.loop.run_until_complete(self.testvm1.start()) self.loop.run_until_complete(self.testvm1.start())
self.assertEqual(self.testvm1.get_power_state(), "Running") self.assertEqual(self.testvm1.get_power_state(), "Running")

View File

@ -30,7 +30,10 @@ import tempfile
import unittest import unittest
import unittest.mock import unittest.mock
import asyncio
import qubes.tests import qubes.tests
import qubes.tests.storage
import qubes.storage import qubes.storage
from qubes.storage.lvm import ThinPool, ThinVolume, qubes_lvm from qubes.storage.lvm import ThinPool, ThinVolume, qubes_lvm
@ -970,6 +973,20 @@ class TC_01_ThinPool(ThinPoolBase, qubes.tests.SystemTestCase):
with self.assertNotRaises(qubes.exc.QubesException): with self.assertNotRaises(qubes.exc.QubesException):
self.loop.run_until_complete(vm.start()) self.loop.run_until_complete(vm.start())
def test_006_name_suffix_parse(self):
'''Regression test for #4680'''
vm1 = self.app.add_new_vm(cls=qubes.vm.appvm.AppVM,
name=self.make_vm_name('appvm'), label='red')
vm2 = self.app.add_new_vm(cls=qubes.vm.appvm.AppVM,
name=self.make_vm_name('appvm-root'), label='red')
self.loop.run_until_complete(asyncio.wait([
vm1.create_on_disk(pool=self.pool.name),
vm2.create_on_disk(pool=self.pool.name)]))
self.loop.run_until_complete(vm2.start())
self.loop.run_until_complete(vm2.shutdown(wait=True))
with self.assertNotRaises(ValueError):
vm1.volumes['root'].size
@skipUnlessLvmPoolExists @skipUnlessLvmPoolExists
class TC_02_StorageHelpers(ThinPoolBase): class TC_02_StorageHelpers(ThinPoolBase):
def setUp(self): def setUp(self):

View File

@ -342,7 +342,7 @@ fi
%{python3_sitelib}/qubes/tests/integ/dom0_update.py %{python3_sitelib}/qubes/tests/integ/dom0_update.py
%{python3_sitelib}/qubes/tests/integ/mime.py %{python3_sitelib}/qubes/tests/integ/mime.py
%{python3_sitelib}/qubes/tests/integ/network.py %{python3_sitelib}/qubes/tests/integ/network.py
%{python3_sitelib}/qubes/tests/integ/pvgrub.py %{python3_sitelib}/qubes/tests/integ/grub.py
%{python3_sitelib}/qubes/tests/integ/salt.py %{python3_sitelib}/qubes/tests/integ/salt.py
%{python3_sitelib}/qubes/tests/integ/storage.py %{python3_sitelib}/qubes/tests/integ/storage.py
%{python3_sitelib}/qubes/tests/integ/vm_qrexec_gui.py %{python3_sitelib}/qubes/tests/integ/vm_qrexec_gui.py