[Kimchi-devel] [PATCH V2 4/4] vmiface update support: update test case
shaohef at linux.vnet.ibm.com
shaohef at linux.vnet.ibm.com
Wed Apr 23 14:41:17 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 | 20 ++++++++++++++++++++
tests/test_rest.py | 8 ++++++++
2 files changed, 28 insertions(+)
diff --git a/tests/test_model.py b/tests/test_model.py
index 2fb4446..fac4008 100644
--- a/tests/test_model.py
+++ b/tests/test_model.py
@@ -147,6 +147,8 @@ class ModelTests(unittest.TestCase):
'subnet': '127.0.100.0/24'}
inst.networks_create(net_args)
rollback.prependDefer(inst.network_delete, net_name)
+ inst.network_activate(net_name)
+ rollback.prependDefer(inst.network_deactivate, net_name)
ifaces = inst.vmifaces_get_list('kimchi-ifaces')
self.assertEquals(1, len(ifaces))
@@ -170,6 +172,24 @@ class ModelTests(unittest.TestCase):
self.assertEquals("test-network", iface['network'])
self.assertEquals("virtio", iface["model"])
+ # update vm interface
+ iface_args = {"network": "default",
+ "model": "e1000"}
+ inst.vmiface_update('kimchi-ifaces', mac, iface_args)
+ iface = inst.vmiface_lookup('kimchi-ifaces', mac)
+ self.assertEquals("default", iface['network'])
+ self.assertEquals("e1000", iface["model"])
+
+ # update vm interface when vm is running
+ inst.vm_start("kimchi-ifaces")
+ rollback.prependDefer(inst.vm_poweroff, 'kimchi-ifaces')
+ iface_args = {"network": "test-network",
+ "model": "virtio"}
+ inst.vmiface_update('kimchi-ifaces', mac, iface_args)
+ iface = inst.vmiface_lookup('kimchi-ifaces', mac)
+ self.assertEquals("e1000", iface["model"])
+ self.assertEquals("test-network", iface['network'])
+
@unittest.skipUnless(utils.running_as_root(), 'Must be run as root')
def test_vm_cdrom(self):
inst = model.Model(objstore_loc=self.tmp_store)
diff --git a/tests/test_rest.py b/tests/test_rest.py
index 06396db..0d19841 100644
--- a/tests/test_rest.py
+++ b/tests/test_rest.py
@@ -516,6 +516,14 @@ class RestTests(unittest.TestCase):
self.assertEquals('virtio', iface['model'])
self.assertEquals('network', iface['type'])
+ # update vm interface
+ req = json.dumps({"network": "default", "model": "e1000"})
+ resp = self.request('/vms/test-vm/ifaces/%s' % iface['mac'], req, 'PUT')
+ self.assertEquals(200, resp.status)
+ update_iface = json.loads(resp.read())
+ self.assertEquals('e1000', update_iface['model'])
+ self.assertEquals('default', update_iface['network'])
+
# detach network interface from vm
resp = self.request('/vms/test-vm/ifaces/%s' % iface['mac'],
'{}', 'DELETE')
--
1.9.0
More information about the Kimchi-devel
mailing list