This patch add tests to following cases:
- maxMemory lesser than 512
- maxMemory not integer
- maxMemory change
- hotPlug more memory than supported
Signed-off-by: Rodrigo Trujillo <rodrigo.trujillo(a)linux.vnet.ibm.com>
---
src/wok/plugins/kimchi/tests/test_rest.py | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
diff --git a/src/wok/plugins/kimchi/tests/test_rest.py
b/src/wok/plugins/kimchi/tests/test_rest.py
index 544f2e6..d4835bf 100644
--- a/src/wok/plugins/kimchi/tests/test_rest.py
+++ b/src/wok/plugins/kimchi/tests/test_rest.py
@@ -144,6 +144,19 @@ class RestTests(unittest.TestCase):
vm = json.loads(self.request('/plugins/kimchi/vms/vm-1').read())
self.assertEquals('vm-1', vm['name'])
+ # Test max memory
+ req = json.dumps({'maxmemory': 23})
+ resp = self.request('/plugins/kimchi/vms/vm-1', req, 'PUT')
+ self.assertEquals(400, resp.status)
+
+ req = json.dumps({'maxmemory': 'maxmem 80'})
+ resp = self.request('/plugins/kimchi/vms/vm-1', req, 'PUT')
+ self.assertEquals(400, resp.status)
+
+ req = json.dumps({'maxmemory': 3072})
+ resp = self.request('/plugins/kimchi/vms/vm-1', req, 'PUT')
+ self.assertEquals(200, resp.status)
+
resp = self.request('/plugins/kimchi/vms/vm-1/start', '{}',
'POST')
self.assertEquals(200, resp.status)
@@ -216,11 +229,21 @@ class RestTests(unittest.TestCase):
params = {'name': u'∨м-црdαtеd', 'cpus': 5,
'memory': 3072}
req = json.dumps(params)
resp = self.request('/plugins/kimchi/vms/vm-1', req, 'PUT')
+ # 1G hotpluged + 3G = 4G --> Higher than maxmemory = 3G
+ self.assertEquals(500, resp.status)
+
+ params['memory'] = 2048
+ req = json.dumps(params)
+ resp = self.request('/plugins/kimchi/vms/vm-1', req, 'PUT')
+ # 1G hotpluged + 2G = 3G --> Equal maxmemory = 3G
self.assertEquals(303, resp.status)
vm = json.loads(
self.request('/plugins/kimchi/vms/∨м-црdαtеd', req).read()
)
for key in params.keys():
+ if key == 'memory':
+ # 1G Hot Plugged
+ params[key] = params[key] + 1024
self.assertEquals(params[key], vm[key])
# change only VM users - groups are not changed (default is empty)
--
2.1.0