[Kimchi-devel] [PATCHv3 5/5] Add volume ref_cnt: Update test
lvroyce at linux.vnet.ibm.com
lvroyce at linux.vnet.ibm.com
Tue Feb 25 08:35:49 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 74e2424..3e39aa5 100644
--- a/tests/test_model.py
+++ b/tests/test_model.py
@@ -356,6 +356,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
@@ -405,6 +406,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 ca96dc0..69bb569 100644
--- a/tests/test_rest.py
+++ b/tests/test_rest.py
@@ -246,6 +246,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')
@@ -846,6 +847,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