From: Paulo Vital <pvital(a)linux.vnet.ibm.com>
Libvirt of the Fedora 23 is not able to delete the storage volume in the
testcase test_vm_lifecycle when testing ModelTests. This happens because
Libvirt is not able to unlink/rmdir returning an error (-1) and
setting errno to ENOENT, causing the error:
"cannot unlink file '/var/lib/libvirt/images/test-vol': Success"
This patch fixes the testcase by manually remove the volume file from the
storage pool directory if the wok.plugins.kimchi.model.storagevolume_delete()
was not capable to delete the volume.
Signed-off-by: Paulo Vital <pvital(a)linux.vnet.ibm.com>
---
tests/test_model.py | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/tests/test_model.py b/tests/test_model.py
index 4aa19bd..ff63182 100644
--- a/tests/test_model.py
+++ b/tests/test_model.py
@@ -96,7 +96,7 @@ class ModelTests(unittest.TestCase):
os.unlink(self.tmp_store)
- def temporary_storagevolume_delete(inst, pool, vol):
+ def temporary_storagevolume_delete(self, inst, pool, vol):
# Quick fix to passby the Libvirt error:
# "error: cannot unlink file '%(vol)': Success"
# in Fedora <= 23. The Libvirt fix will be present only on Fedora 24
@@ -134,13 +134,14 @@ class ModelTests(unittest.TestCase):
@unittest.skipUnless(utils.running_as_root(), 'Must be run as root')
def test_vm_lifecycle(self):
+
inst = model.Model(objstore_loc=self.tmp_store)
with RollbackContext() as rollback:
vol_params = {'name': u'test-vol', 'capacity': 1024}
task = inst.storagevolumes_create(u'default', vol_params)
- rollback.prependDefer(inst.storagevolume_delete, u'default',
- vol_params['name'])
+ rollback.prependDefer(self.temporary_storagevolume_delete, inst,
+ u'default', vol_params['name'])
inst.task_wait(task['id'])
task = inst.task_lookup(task['id'])
self.assertEquals('finished', task['status'])
@@ -271,7 +272,7 @@ class ModelTests(unittest.TestCase):
'allocation': 1048576, # 1 MiB
'format': 'qcow2'}
task_id = inst.storagevolumes_create(pool, params)['id']
- rollback.prependDefer(temporary_storagevolume_delete, inst,
+ rollback.prependDefer(self.temporary_storagevolume_delete, inst,
pool, vol)
inst.task_wait(task_id)
self.assertEquals('finished',
inst.task_lookup(task_id)['status'])
--
2.5.0