
Signed-off-by: Lucio Correia <luciojhc@linux.vnet.ibm.com> --- tests/test_mockmodel.py | 5 +++-- tests/test_model.py | 5 +++-- tests/test_rest.py | 2 +- tests/test_template.py | 11 +++++++++-- tests/test_vmtemplate.py | 5 +++-- 5 files changed, 19 insertions(+), 9 deletions(-) diff --git a/tests/test_mockmodel.py b/tests/test_mockmodel.py index ce6e837..c922c73 100644 --- a/tests/test_mockmodel.py +++ b/tests/test_mockmodel.py @@ -1,7 +1,7 @@ # # Project Kimchi # -# Copyright IBM, Corp. 2013-2015 +# Copyright IBM, Corp. 2013-2016 # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public @@ -124,7 +124,7 @@ class MockModelTests(unittest.TestCase): keys = set(('name', 'state', 'stats', 'uuid', 'memory', 'cpus', 'screenshot', 'icon', 'graphics', 'users', 'groups', - 'access', 'persistent')) + 'access', 'persistent', 'maxvcpus', 'cpu_info')) stats_keys = set(('cpu_utilization', 'mem_utilization', 'net_throughput', 'net_throughput_peak', @@ -137,6 +137,7 @@ class MockModelTests(unittest.TestCase): self.assertEquals(get_template_default('old', 'memory'), info['memory']) self.assertEquals(1, info['cpus']) + self.assertEquals(1, info['maxvcpus']) self.assertEquals('plugins/kimchi/images/icon-vm.png', info['icon']) self.assertEquals(stats_keys, set(info['stats'].keys())) self.assertEquals('vnc', info['graphics']['type']) diff --git a/tests/test_model.py b/tests/test_model.py index 762f0f8..a1cec53 100644 --- a/tests/test_model.py +++ b/tests/test_model.py @@ -2,7 +2,7 @@ # # Project Kimchi # -# Copyright IBM, Corp. 2013-2015 +# Copyright IBM, Corp. 2013-2016 # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public @@ -104,7 +104,7 @@ class ModelTests(unittest.TestCase): keys = set(('name', 'state', 'stats', 'uuid', 'memory', 'cpus', 'screenshot', 'icon', 'graphics', 'users', 'groups', - 'access', 'persistent')) + 'access', 'persistent', 'maxvcpus', 'cpu_info')) stats_keys = set(('cpu_utilization', 'mem_utilization', 'net_throughput', 'net_throughput_peak', @@ -115,6 +115,7 @@ class ModelTests(unittest.TestCase): self.assertEquals('test', info['name']) self.assertEquals(2048, info['memory']) self.assertEquals(2, info['cpus']) + self.assertEquals(2, info['maxvcpus']) self.assertEquals(None, info['icon']) self.assertEquals(stats_keys, set(info['stats'].keys())) self.assertRaises(NotFoundError, inst.vm_lookup, 'nosuchvm') diff --git a/tests/test_rest.py b/tests/test_rest.py index f4c4f4e..efce461 100644 --- a/tests/test_rest.py +++ b/tests/test_rest.py @@ -148,7 +148,7 @@ class RestTests(unittest.TestCase): vm = json.loads(self.request('/plugins/kimchi/vms/vm-1').read()) self.assertEquals('vm-1', vm['name']) - req = json.dumps({'cpus': 3}) + req = json.dumps({'maxvcpus': 5, 'cpus': 3}) resp = self.request('/plugins/kimchi/vms/vm-1', req, 'PUT') self.assertEquals(200, resp.status) diff --git a/tests/test_template.py b/tests/test_template.py index 0b3dd98..86fb743 100644 --- a/tests/test_template.py +++ b/tests/test_template.py @@ -2,7 +2,7 @@ # # Project Kimchi # -# Copyright IBM, Corp. 2015 +# Copyright IBM, Corp. 2015-2016 # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public @@ -83,7 +83,7 @@ class TemplateTests(unittest.TestCase): # Verify the template keys = ['name', 'icon', 'invalid', 'os_distro', 'os_version', 'cpus', - 'memory', 'cdrom', 'disks', 'networks', + 'maxvcpus', 'memory', 'cdrom', 'disks', 'networks', 'folder', 'graphics', 'cpu_info'] tmpl = json.loads( self.request('/plugins/kimchi/templates/test').read() @@ -193,6 +193,13 @@ class TemplateTests(unittest.TestCase): self.assertEquals('fedora', update_tmpl['os_distro']) self.assertEquals('21', update_tmpl['os_version']) + # Update maxvcpus + req = json.dumps({'maxvcpus': 2}) + resp = self.request(new_tmpl_uri, req, 'PUT') + self.assertEquals(200, resp.status) + update_tmpl = json.loads(resp.read()) + self.assertEquals(2, update_tmpl['maxvcpus']) + # Update cpus req = json.dumps({'cpus': 2}) resp = self.request(new_tmpl_uri, req, 'PUT') diff --git a/tests/test_vmtemplate.py b/tests/test_vmtemplate.py index de2d542..a49262a 100644 --- a/tests/test_vmtemplate.py +++ b/tests/test_vmtemplate.py @@ -1,7 +1,7 @@ # # Project Kimchi # -# Copyright IBM, Corp. 2013-2015 +# Copyright IBM, Corp. 2013-2016 # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public @@ -121,10 +121,11 @@ class VMTemplateTests(unittest.TestCase): """ graphics = {'type': 'vnc', 'listen': '127.0.0.1'} args = {'name': 'test', 'os_distro': 'opensuse', 'os_version': '12.3', - 'cpus': 2, 'memory': 2048, 'networks': ['foo'], + 'cpus': 2, 'maxvcpus': 4, 'memory': 2048, 'networks': ['foo'], 'cdrom': self.iso, 'graphics': graphics} t = VMTemplate(args) self.assertEquals(2, t.info.get('cpus')) + self.assertEquals(4, t.info.get('maxvcpus')) self.assertEquals(2048, t.info.get('memory')) self.assertEquals(['foo'], t.info.get('networks')) self.assertEquals(self.iso, t.info.get('cdrom')) -- 1.9.1