tests/backup: verify restored VM properties

QubesOS/qubes-issues#2106
This commit is contained in:
Marek Marczykowski-Górecki 2016-07-16 21:50:24 +02:00
parent 8222324146
commit 6ccae83956
No known key found for this signature in database
GPG Key ID: 063938BA42CFA724
2 changed files with 29 additions and 0 deletions

View File

@ -639,6 +639,7 @@ class BackupTestsMixin(SystemTestsMixin):
testnet = self.qc.add_new_vm('QubesNetVm',
name=vmname, template=template)
testnet.create_on_disk(verbose=self.verbose)
testnet.services['ntpd'] = True
vms.append(testnet)
self.fill_image(testnet.private_img, 20*1024*1024)
@ -657,6 +658,8 @@ class BackupTestsMixin(SystemTestsMixin):
if self.verbose:
print >>sys.stderr, "-> Creating %s" % vmname
testvm2 = self.qc.add_new_vm('QubesHVm', name=vmname)
# fixup - uses_default_netvm=True anyway
testvm2.netvm = self.qc.get_default_netvm()
testvm2.create_on_disk(verbose=self.verbose)
self.fill_image(testvm2.root_img, 1024*1024*1024, True)
vms.append(testvm2)

View File

@ -37,6 +37,32 @@ class TC_00_Backup(qubes.tests.BackupTestsMixin, qubes.tests.QubesTestCase):
self.make_backup(vms)
self.remove_vms(vms)
self.restore_backup()
for vm in vms:
restored_vm = self.qc.get_vm_by_name(vm.name)
for prop in ('name', 'kernel', 'uses_default_kernel',
'uses_default_netvm', 'memory', 'maxmem', 'kernelopts',
'uses_default_kernelopts', 'services', 'vcpus', 'pcidevs',
'include_in_backups', 'default_user', 'qrexec_timeout',
'autostart', 'pci_strictreset', 'pci_e820_host', 'debug',
'internal'):
if prop not in vm.get_attrs_config():
continue
self.assertEquals(
getattr(vm, prop), getattr(restored_vm, prop),
"VM {} - property {} not properly restored".format(
vm.name, prop))
for prop in ('netvm', 'template', 'label'):
orig_value = getattr(vm, prop)
restored_value = getattr(restored_vm, prop)
if orig_value and restored_value:
self.assertEquals(orig_value.name, restored_value.name,
"VM {} - property {} not properly restored".format(
vm.name, prop))
else:
self.assertEquals(orig_value, restored_value,
"VM {} - property {} not properly restored".format(
vm.name, prop))
self.remove_vms(vms)
def test_001_compressed_backup(self):