[Kimchi-devel] [PATCH 4/4 v5] [Memory HotPlug] Fix tests, adds slot and memory hotplug tests
Rodrigo Trujillo
rodrigo.trujillo at linux.vnet.ibm.com
Fri Jun 5 18:27:10 UTC 2015
This patch fixed the issues caused by previous changes in the guest xml,
like use of NUMA and MAXMEMORY elements.
It includes a slot number checking test, and memory hotplug test as
well.
Signed-off-by: Rodrigo Trujillo <rodrigo.trujillo at linux.vnet.ibm.com>
---
tests/test_model.py | 31 ++++++++++++++++++++++++++++++-
tests/test_rest.py | 12 +++++++++---
tests/test_vmtemplate.py | 9 ++++++++-
3 files changed, 47 insertions(+), 5 deletions(-)
diff --git a/tests/test_model.py b/tests/test_model.py
index 7a7b97d..602ca6e 100644
--- a/tests/test_model.py
+++ b/tests/test_model.py
@@ -600,12 +600,41 @@ class ModelTests(unittest.TestCase):
self.assertTrue(os.access(disk_path, os.F_OK))
self.assertFalse(os.access(disk_path, os.F_OK))
+ def test_vm_memory_hotplug(self):
+ config.set("authentication", "method", "pam")
+ inst = model.Model(None, objstore_loc=self.tmp_store)
+ orig_params = {'name': 'test', 'memory': 1024, 'cdrom': UBUNTU_ISO}
+ inst.templates_create(orig_params)
+
+ with RollbackContext() as rollback:
+ params = {'name': 'kimchi-vm1', 'template': '/templates/test'}
+ task1 = inst.vms_create(params)
+ inst.task_wait(task1['id'])
+ rollback.prependDefer(utils.rollback_wrapper, inst.vm_delete,
+ 'kimchi-vm1')
+ # Start vm
+ inst.vm_start('kimchi-vm1')
+ rollback.prependDefer(utils.rollback_wrapper, inst.vm_poweroff,
+ 'kimchi-vm1')
+
+ # Hotplug memory, only available in Libvirt >= 1.2.14
+ params = {'memory': 2048}
+ if inst.capabilities_lookup()['mem_hotplug_support']:
+ inst.vm_update('kimchi-vm1', params)
+ rollback.prependDefer(utils.rollback_wrapper, inst.vm_delete,
+ 'kimchi-vm1')
+ self.assertEquals(params['memory'],
+ inst.vm_lookup('kimchi-vm1')['memory'])
+ else:
+ self.assertRaises(InvalidOperation, inst.vm_update,
+ 'kimchi-vm1', params)
+
def test_vm_edit(self):
config.set("authentication", "method", "pam")
inst = model.Model(None,
objstore_loc=self.tmp_store)
- orig_params = {'name': 'test', 'memory': '1024', 'cpus': '1',
+ orig_params = {'name': 'test', 'memory': 1024, 'cpus': 1,
'cdrom': UBUNTU_ISO}
inst.templates_create(orig_params)
diff --git a/tests/test_rest.py b/tests/test_rest.py
index 7fe6831..c2d142f 100644
--- a/tests/test_rest.py
+++ b/tests/test_rest.py
@@ -156,9 +156,15 @@ class RestTests(unittest.TestCase):
resp = self.request('/vms/vm-1', req, 'PUT')
self.assertEquals(200, resp.status)
+ # Check if there is support to memory hotplug, once vm is running
+ resp = self.request('/config/capabilities').read()
+ conf = json.loads(resp)
req = json.dumps({'memory': 2048})
resp = self.request('/vms/vm-1', req, 'PUT')
- self.assertEquals(200, resp.status)
+ if conf['mem_hotplug_support']:
+ self.assertEquals(200, resp.status)
+ else:
+ self.assertEquals(400, resp.status)
req = json.dumps({"graphics": {'passwd': "abcdef"}})
resp = self.request('/vms/vm-1', req, 'PUT')
@@ -204,7 +210,7 @@ class RestTests(unittest.TestCase):
resp = self.request('/vms/vm-1', req, 'PUT')
self.assertEquals(400, resp.status)
- params = {'name': u'∨м-црdαtеd', 'cpus': 5, 'memory': 4096}
+ params = {'name': u'∨м-црdαtеd', 'cpus': 5, 'memory': 3072}
req = json.dumps(params)
resp = self.request('/vms/vm-1', req, 'PUT')
self.assertEquals(303, resp.status)
@@ -1064,7 +1070,7 @@ class RestTests(unittest.TestCase):
keys = [u'libvirt_stream_protocols', u'qemu_stream', u'qemu_spice',
u'screenshot', u'system_report_tool', u'update_tool',
u'repo_mngt_tool', u'federation', u'kernel_vfio', u'auth',
- u'nm_running']
+ u'nm_running', u'mem_hotplug_support']
self.assertEquals(sorted(keys), sorted(conf.keys()))
def test_peers(self):
diff --git a/tests/test_vmtemplate.py b/tests/test_vmtemplate.py
index b504fbc..0ca9adb 100644
--- a/tests/test_vmtemplate.py
+++ b/tests/test_vmtemplate.py
@@ -83,7 +83,12 @@ class VMTemplateTests(unittest.TestCase):
def test_to_xml(self):
graphics = {'type': 'spice', 'listen': '127.0.0.1'}
vm_uuid = str(uuid.uuid4()).replace('-', '')
- t = VMTemplate({'name': 'test-template', 'cdrom': self.iso})
+ if os.uname()[4] in ['ppc', 'ppc64', 'ppc64le']:
+ maxmem = 3328
+ else:
+ maxmem = 3072
+ t = VMTemplate({'name': 'test-template', 'cdrom': self.iso,
+ 'max_memory': maxmem << 10})
xml = t.to_vm_xml('test-vm', vm_uuid, graphics=graphics)
self.assertEquals(vm_uuid, xpath_get_text(xml, "/domain/uuid")[0])
self.assertEquals('test-vm', xpath_get_text(xml, "/domain/name")[0])
@@ -91,6 +96,8 @@ class VMTemplateTests(unittest.TestCase):
self.assertEquals(graphics['type'], xpath_get_text(xml, expr)[0])
expr = "/domain/devices/graphics/@listen"
self.assertEquals(graphics['listen'], xpath_get_text(xml, expr)[0])
+ expr = "/domain/maxMemory/@slots"
+ self.assertEquals('2', xpath_get_text(xml, expr)[0])
def test_arg_merging(self):
"""
--
2.1.0
More information about the Kimchi-devel
mailing list