[Kimchi-devel] [PATCH 4/4] Add volume ref_cnt: Update test

Sheldon shaohef at linux.vnet.ibm.com
Mon Feb 17 12:08:05 UTC 2014


comments below

On 02/17/2014 04:38 PM, lvroyce at linux.vnet.ibm.com wrote:
> From: Royce Lv <lvroyce at linux.vnet.ibm.com>
>
> Add mockmodel test and model test to validate:
> 1. ref_cnt of storage volume forked internal vm creation is -1.
should this be 1? for it is used by a VM.
> 2. ref_cnt of storage volume created from REST API is 0.
>
> Signed-off-by: Royce Lv <lvroyce at linux.vnet.ibm.com>
> ---
>   tests/test_model.py | 4 ++++
>   tests/test_rest.py  | 2 ++
>   2 files changed, 6 insertions(+)
>
> diff --git a/tests/test_model.py b/tests/test_model.py
> index b374d2d..7ab002f 100644
> --- a/tests/test_model.py
> +++ b/tests/test_model.py
> @@ -288,6 +288,7 @@ class ModelTests(unittest.TestCase):
>               inst.storagevolume_wipe(pool, vol)
>               volinfo = inst.storagevolume_lookup(pool, vol)
>               self.assertEquals(0, volinfo['allocation'])
> +            self.assertEquals(0, volinfo['ref_cnt'])
>
>               volinfo = inst.storagevolume_lookup(pool, vol)
>               # Define the size = capacity + 16M
> @@ -337,6 +338,9 @@ class ModelTests(unittest.TestCase):
>               vm_info = inst.vm_lookup(params['name'])
>               disk_path = '/tmp/kimchi-images/%s-0.img' % vm_info['uuid']
>               self.assertTrue(os.access(disk_path, os.F_OK))
> +            vol = '%s-0.img' % vm_info['uuid']
> +            volinfo = inst.storagevolume_lookup(pool, vol)
> +            self.assertEquals(-1, volinfo['ref_cnt'])
>
>       @unittest.skipUnless(utils.running_as_root(), 'Must be run as root')
>       def test_template_create(self):
> diff --git a/tests/test_rest.py b/tests/test_rest.py
> index deb6fe8..e052cd0 100644
> --- a/tests/test_rest.py
> +++ b/tests/test_rest.py
> @@ -244,6 +244,7 @@ class RestTests(unittest.TestCase):
>           resp = self.request(vol_uri)
>           vol = json.loads(resp.read())
>           self.assertEquals(1 << 30, vol['capacity'])
> +        self.assertEquals(-1, vol['ref_cnt'])
>
>           # Start the VM
>           resp = self.request('/vms/test-vm/start', '{}', 'POST')
> @@ -769,6 +770,7 @@ class RestTests(unittest.TestCase):
>           storagevolume = json.loads(resp.read())
>           self.assertEquals('volume-1', storagevolume['name'])
>           self.assertEquals('raw', storagevolume['format'])
> +        self.assertEquals(0, storagevolume['ref_cnt'])
>           self.assertEquals('/var/lib/libvirt/images/volume-1',
>                             storagevolume['path'])
>


-- 
Thanks and best regards!

Sheldon Feng(冯少合)<shaohef at linux.vnet.ibm.com>
IBM Linux Technology Center




More information about the Kimchi-devel mailing list