tests: reload qubes.xml after save

This is to make sure that QubesVmCollection state is consistent with
qubes.xml - unfortunately some changes are applied to Qubes*Vm object
only at load time (for example connected_vms collections).
This commit is contained in:
Marek Marczykowski-Górecki 2015-02-19 03:52:35 +01:00
parent f7a06ae29b
commit 091d02b9a3

View File

@ -217,6 +217,11 @@ class SystemTestsMixin(object):
def make_vm_name(self, name):
return VMPREFIX + name
def save_and_reload_db(self):
self.qc.save()
self.qc.unlock_db()
self.qc.lock_db_for_writing()
self.qc.load()
def _remove_vm_qubes(self, vm):
vmname = vm.name
@ -234,7 +239,6 @@ class SystemTestsMixin(object):
except libvirt.libvirtError: pass
self.qc.pop(vm.qid)
self.qc.save()
del vm
# Now ensure it really went away. This may not have happened,
@ -272,6 +276,7 @@ class SystemTestsMixin(object):
def remove_vms(self, vms):
for vm in vms: self._remove_vm_qubes(vm)
self.save_and_reload_db()
def remove_test_vms(self):
@ -285,9 +290,13 @@ class SystemTestsMixin(object):
'''
# first, remove them Qubes-way
something_removed = False
for vm in self.qc.values():
if vm.name.startswith(VMPREFIX):
self._remove_vm_qubes(vm)
something_removed = True
if something_removed:
self.save_and_reload_db()
# now remove what was only in libvirt
for dom in self.conn.listAllDomains():
@ -392,6 +401,8 @@ class BackupTestsMixin(SystemTestsMixin):
self.fill_image(testvm2.root_img, 1024*1024*1024, True)
vms.append(testvm2)
self.save_and_reload_db()
return vms