[Kimchi-devel] [PATCH] [Kimchi 2/5] Fix test_image_based_template testcase.

Paulo Ricardo Paz Vital pvital at linux.vnet.ibm.com
Mon Dec 14 18:46:32 UTC 2015


On 12/07/2015 11:52 AM, Aline Manera wrote:
> 
> 
> 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_image_based_template 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/base-vol.img': 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 | 18 +++++++++++++++---
>>   1 file changed, 15 insertions(+), 3 deletions(-)
>>
>> diff --git a/tests/test_model.py b/tests/test_model.py
>> index caacd91..0108015 100644
>> --- a/tests/test_model.py
>> +++ b/tests/test_model.py
>> @@ -250,19 +250,31 @@ class ModelTests(unittest.TestCase):
>>
>>       @unittest.skipUnless(utils.running_as_root(), 'Must be run as
>> root')
>>       def test_image_based_template(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
> 
> Is there a Fedora issue for it? If so, could you add a reference for
> that in this comment?

There's no Fedora's bugzilla or even libvirt issue about this error. The
error was found during the investigation of a different libvirt problem
and them a solution was submitted to libvirt ML.

I can add the reference to this patch sent to libvirt ML.

> 
>> +            try:
>> +                inst.storagevolume_delete(pool, vol)
>> +            except OperationFailed as e:
>> +                path = inst.storagevolume_lookup(pool, vol)['path']
>> +                os.remove(path)
>> +
>>           inst = model.Model(objstore_loc=self.tmp_store)
>>
>>           with RollbackContext() as rollback:
>> +            pool = 'default'
>>               vol = 'base-vol.img'
>>               params = {'name': vol,
>>                         'capacity': 1073741824,  # 1 GiB
>>                         'allocation': 1048576,  # 1 MiB
>>                         'format': 'qcow2'}
>> -            task_id = inst.storagevolumes_create('default',
>> params)['id']
>> -            rollback.prependDefer(inst.storagevolume_delete,
>> 'default', vol)
>> +            task_id = inst.storagevolumes_create(pool, params)['id']
>> +            rollback.prependDefer(temporary_storagevolume_delete,
>> pool, vol)
>>               inst.task_wait(task_id)
>>               self.assertEquals('finished',
>> inst.task_lookup(task_id)['status'])
>> -            vol_path = inst.storagevolume_lookup('default', vol)['path']
>> +            vol_path = inst.storagevolume_lookup(pool, vol)['path']
>>
>>               # Create template based on IMG file
>>               tmpl_name = "img-tmpl"
> 




More information about the Kimchi-devel mailing list