[Kimchi-devel] [PATCH v2] Does not list non-bootable images
Ramon Medeiros
ramonn at linux.vnet.ibm.com
Mon Jun 1 15:35:46 UTC 2015
Hi,
removing the lines that you mentioned results in errors in the test
framework:
======================================================================
ERROR: test_iso_scan_shallow (test_rest.HttpsRestTests)
----------------------------------------------------------------------
Traceback (most recent call last):
File "test_rest.py", line 925, in test_iso_scan_shallow
'/storagepools/kimchi_isos/storagevolumes/').read())[0]
IndexError: list index out of range
======================================================================
ERROR: test_iso_scan_shallow (test_rest.RestTests)
----------------------------------------------------------------------
Traceback (most recent call last):
File "test_rest.py", line 925, in test_iso_scan_shallow
'/storagepools/kimchi_isos/storagevolumes/').read())[0]
IndexError: list index out of range
======================================================================
FAIL: test_storagevolume_action
(test_model_storagevolume.StorageVolumeTests)
----------------------------------------------------------------------
Traceback (most recent call last):
File "test_model_storagevolume.py", line 269, in
test_storagevolume_action
_do_volume_test(self, model, host, ssl_port, 'default')
File "test_model_storagevolume.py", line 120, in _do_volume_test
self.assertEquals(0, storagevolume['allocation'])
AssertionError: 0 != 1024
On 05/29/2015 04:41 PM, Aline Manera wrote:
>
>
> On 29/05/2015 11:13, Ramon Medeiros wrote:
>> Also fix tests that were using non-bootable isos.
>>
>> Signed-off-by: Ramon Medeiros <ramonn at linux.vnet.ibm.com>
>>
>> Changes
>>
>> v2:
>> Fix tests that were listing non-bootable isos
>>
>> ---
>> src/kimchi/model/storagevolumes.py | 2 +-
>> tests/test_rest.py | 16 ++++++++--------
>> 2 files changed, 9 insertions(+), 9 deletions(-)
>>
>> diff --git a/src/kimchi/model/storagevolumes.py
>> b/src/kimchi/model/storagevolumes.py
>> index dc807e4..e88c2cb 100644
>> --- a/src/kimchi/model/storagevolumes.py
>> +++ b/src/kimchi/model/storagevolumes.py
>> @@ -530,7 +530,7 @@ class IsoVolumesModel(object):
>> for volume in volumes:
>> res = self.storagevolume.lookup(pool_name,
>> volume.decode("utf-8"))
>> - if res['format'] == 'iso':
>> + if res['format'] == 'iso' and res['bootable']:
>> res['name'] = '%s' % volume
>> iso_volumes.append(res)
>> return iso_volumes
>> diff --git a/tests/test_rest.py b/tests/test_rest.py
>> index 914b602..9e5988b 100644
>> --- a/tests/test_rest.py
>> +++ b/tests/test_rest.py
>> @@ -61,13 +61,14 @@ def setUpModule():
>>
>> # Create fake ISO to do the tests
>> iso_gen.construct_fake_iso(fake_iso, True, '12.04', 'ubuntu')
>> -
>> + iso_gen.construct_fake_iso("/var/lib/libvirt/images/fedora.iso", True,
>> + "17", "fedora")
>>
>> def tearDownModule():
>> test_server.stop()
>> os.unlink('/tmp/obj-store-test')
>> os.unlink(fake_iso)
>> -
>> + os.unlink("/var/lib/libvirt/images/fedora.iso")
>>
>> class RestTests(unittest.TestCase):
>> def _async_op(self, cb, opaque):
>> @@ -926,9 +927,9 @@ class RestTests(unittest.TestCase):
>> storagevolume['path'])
>
> The first lines of this test are:
>
> def test_iso_scan_shallow(self):
> # fake environment preparation
> self._create_pool('pool-3')
> self.request('/storagepools/pool-3/activate', '{}', 'POST')
> params = {'name': 'fedora.iso',
> 'capacity': 1073741824, # 1 GiB
> 'type': 'file',
> 'format': 'iso'}
> task_info = model.storagevolumes_create('pool-3', params)
> wait_task(self._task_lookup, task_info['id'])
>
> Which means a volume fedora.iso will be created on pool-3.
> I think it is the same you did by calling iso_gen.contruct_fake_iso()
>
> So you can remove the volume creation step here.
>
>> self.assertEquals(1073741824, storagevolume['capacity']) #
>> 1 GiB
>> self.assertEquals(0, storagevolume['allocation'])
>> - self.assertEquals('unknown', storagevolume['os_version'])
>> - self.assertEquals('unknown', storagevolume['os_distro'])
>> - self.assertEquals(False, storagevolume['bootable'])
>> + self.assertEquals('17', storagevolume['os_version'])
>> + self.assertEquals('fedora', storagevolume['os_distro'])
>> + self.assertEquals(True, storagevolume['bootable'])
>>
>> # Create a template
>> # In real model os distro/version can be omitted
>> @@ -943,8 +944,8 @@ class RestTests(unittest.TestCase):
>> # Verify the template
>> t = json.loads(self.request('/templates/test').read())
>> self.assertEquals('test', t['name'])
>> - self.assertEquals('unknown', t['os_distro'])
>> - self.assertEquals('unknown', t['os_version'])
>> + self.assertEquals('fedora', t['os_distro'])
>> + self.assertEquals('17', t['os_version'])
>> self.assertEquals(get_template_default('old', 'memory'),
>> t['memory'])
>>
>> # Deactivate or destroy scan pool return 405
>> @@ -1187,7 +1188,6 @@ class RestTests(unittest.TestCase):
>> resp = self.request('%s/fedora-fake' % base_uri, '{}',
>> 'DELETE')
>> self.assertEquals(204, resp.status)
>>
>> -
>> class HttpsRestTests(RestTests):
>> """
>> Run all of the same tests as above, but use https instead
>
--
Ramon Nunes Medeiros
Kimchi Developer
Linux Technology Center Brazil
IBM Systems & Technology Group
Phone : +55 19 2132 7878
ramonn at br.ibm.com
More information about the Kimchi-devel
mailing list