[Kimchi-devel] [PATCH] [Kimchi 4/5] Fix test_vm_lifecycle testcase.
Aline Manera
alinefm at linux.vnet.ibm.com
Mon Dec 7 13:52:11 UTC 2015
On 05/12/2015 17:22, pvital at linux.vnet.ibm.com wrote:
> From: Paulo Vital <pvital at 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 at linux.vnet.ibm.com>
> ---
> tests/test_model.py | 13 ++++++++++++-
> 1 file changed, 12 insertions(+), 1 deletion(-)
>
> diff --git a/tests/test_model.py b/tests/test_model.py
> index 0ac36dd..338f04d 100644
> --- a/tests/test_model.py
> +++ b/tests/test_model.py
> @@ -124,12 +124,23 @@ class ModelTests(unittest.TestCase):
>
> @unittest.skipUnless(utils.running_as_root(), 'Must be run as root')
> def test_vm_lifecycle(self):
> +
> + def temporary_storagevolume_delete(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
> + try:
> + inst.storagevolume_delete(pool, vol)
> + except OperationFailed as e:
> + path = inst.storagevolume_lookup(pool, vol)['path']
> + os.remove(path)
> +
This function was created twice (check patch 2/5). I suggest to add it
for the test class and reuse everywhere when needed.
> 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',
> + rollback.prependDefer(temporary_storagevolume_delete, u'default',
> vol_params['name'])
> inst.task_wait(task['id'])
> task = inst.task_lookup(task['id'])
More information about the Kimchi-devel
mailing list