[Kimchi-devel] [PATCH 3/3] template integrity verification: update test case to verify storagepool
shaohef at linux.vnet.ibm.com
shaohef at linux.vnet.ibm.com
Wed Feb 26 03:08:35 UTC 2014
From: ShaoHe Feng <shaohef at linux.vnet.ibm.com>
update test_model.py and test_rest.py
Signed-off-by: ShaoHe Feng <shaohef at linux.vnet.ibm.com>
---
tests/test_model.py | 9 +++++++++
tests/test_rest.py | 13 +++++++++++++
2 files changed, 22 insertions(+)
diff --git a/tests/test_model.py b/tests/test_model.py
index 74e2424..0646e2c 100644
--- a/tests/test_model.py
+++ b/tests/test_model.py
@@ -459,6 +459,12 @@ class ModelTests(unittest.TestCase):
'subnet': '127.0.100.0/24'}
inst.networks_create(net_args)
+ pool_name = 'kimchi-test-pool'
+ pool_args = {'name': pool_name,
+ 'path': '/tmp/kimchi-images',
+ 'type': 'dir'}
+ inst.storagepools_create(pool_args )
+
path = '/tmp/kimchi-iso/'
if not os.path.exists(path):
os.makedirs(path)
@@ -467,17 +473,20 @@ class ModelTests(unittest.TestCase):
params = {'name': 'test', 'memory': 1024, 'cpus': 1,
'networks': ['test-network'], 'cdrom': iso,
+ 'storagepool': '/storagepools/%s' % pool_name,
'disks': [{'volume': iso}]}
inst.templates_create(params)
rollback.prependDefer(inst.template_delete, 'test')
inst.network_delete(net_name)
+ inst.storagepool_delete(pool_name)
shutil.rmtree(path)
info = inst.template_lookup('test')
self.assertEquals(info['invalid']['cdrom'], [iso])
self.assertEquals(info['invalid']['networks'], [net_name])
self.assertEquals(info['invalid']['disks'], [iso])
+ self.assertEquals(info['invalid']['storagepools'], [pool_name])
@unittest.skipUnless(utils.running_as_root(), 'Must be run as root')
def test_template_clone(self):
diff --git a/tests/test_rest.py b/tests/test_rest.py
index ca96dc0..528056f 100644
--- a/tests/test_rest.py
+++ b/tests/test_rest.py
@@ -1089,8 +1089,15 @@ class RestTests(unittest.TestCase):
resp = request(host, port, '/networks', req, 'POST')
self.assertEquals(201, resp.status)
+ req = json.dumps({'name': 'test-storagepool',
+ 'path': '/tmp/kimchi-images',
+ 'type': 'dir'})
+ resp = request(host, port, '/storagepools', req, 'POST')
+ self.assertEquals(201, resp.status)
+
t = {'name': 'test', 'memory': 1024, 'cpus': 1,
'networks': ['test-network'], 'cdrom': iso,
+ 'storagepool': '/storagepools/test-storagepool',
'disks': [{'volume': iso}]}
req = json.dumps(t)
@@ -1102,11 +1109,17 @@ class RestTests(unittest.TestCase):
resp = request(host, port, '/networks/test-network', '{}', 'DELETE')
self.assertEquals(204, resp.status)
+ # Delete the storagepool
+ resp = request(host, port, '/storagepools/test-storagepool',
+ '{}', 'DELETE')
+ self.assertEquals(204, resp.status)
+
# Verify the template
res = json.loads(self.request('/templates/test').read())
self.assertEquals(res['invalid']['cdrom'], [iso])
self.assertEquals(res['invalid']['networks'], ['test-network'])
self.assertEquals(res['invalid']['disks'], [iso])
+ self.assertEquals(res['invalid']['storagepools'], ['test-storagepool'])
# Delete the template
resp = request(host, port, '/templates/test', '{}', 'DELETE')
--
1.8.4.2
More information about the Kimchi-devel
mailing list