[Kimchi-devel] [PATCHv5 5/6] Add volume ref_cnt: Update test

lvroyce at linux.vnet.ibm.com lvroyce at linux.vnet.ibm.com
Wed Mar 5 08:46:56 UTC 2014


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.
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 9df4994..8499056 100644
--- a/tests/test_model.py
+++ b/tests/test_model.py
@@ -353,6 +353,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
@@ -402,6 +403,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'])
 
             # reset template to default storage pool
             # so we can remove the storage pool created 'test-pool'
diff --git a/tests/test_rest.py b/tests/test_rest.py
index e5f50ae..e40ebfa 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')
@@ -844,6 +845,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'])
 
-- 
1.8.1.2




More information about the Kimchi-devel mailing list