From 091d02b9a32c223d9b6016be9c456ff82bbaa9e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Date: Thu, 19 Feb 2015 03:52:35 +0100 Subject: [PATCH] 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). --- tests/__init__.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/tests/__init__.py b/tests/__init__.py index 939d9c84..59983735 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -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