[Kimchi-devel] [PATCH v2] [Kimchi] Modified unit test cases to include new s390x specific features
pkulkark at linux.vnet.ibm.com
pkulkark at linux.vnet.ibm.com
Tue Sep 20 07:10:35 UTC 2016
From: Pooja Kulkarni <pkulkark at linux.vnet.ibm.com>
v2:
Corrected make check-local errors
v1:
This patch modifies the unit test cases
to include the new features introduced
for s390x in vm interfaces (macvtap and ovs)
and ovsbridges api.
Signed-off-by: Pooja Kulkarni <pkulkark at linux.vnet.ibm.com>
---
tests/test_model.py | 24 +++++++++++++++++
tests/test_rest.py | 78 +++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 102 insertions(+)
diff --git a/tests/test_model.py b/tests/test_model.py
index ff2a6cb..082cb9d 100644
--- a/tests/test_model.py
+++ b/tests/test_model.py
@@ -651,6 +651,30 @@ class ModelTests(unittest.TestCase):
iface = inst.vmiface_lookup(vm_name, mac)
self.assertEquals(mac, iface['mac'])
+ if os.uname()[4] == "s390x":
+
+ # attach macvtap interface to vm
+ iface_args = {"type": "macvtap",
+ "source": "test-network",
+ "mode": "vepa"}
+ mac = inst.vmifaces_create(vm_name, iface_args)
+ rollback.prependDefer(inst.vmiface_delete, vm_name, mac)
+
+ iface = inst.vmiface_lookup(vm_name, mac)
+ self.assertEquals("macvtap", iface["type"])
+ self.assertEquals("test-network", iface['source'])
+ self.assertEquals("vepa", iface['mode'])
+
+ # attach ovs interface to vm
+ iface_args = {"type": "ovs",
+ "source": "test-network"}
+ mac = inst.vmifaces_create(vm_name, iface_args)
+ rollback.prependDefer(inst.vmiface_delete, vm_name, mac)
+
+ iface = inst.vmiface_lookup(vm_name, mac)
+ self.assertEquals("ovs", iface["type"])
+ self.assertEquals("test-network", iface['source'])
+
@unittest.skipUnless(utils.running_as_root(), 'Must be run as root')
def test_vm_netboot(self):
inst = model.Model(objstore_loc=self.tmp_store)
diff --git a/tests/test_rest.py b/tests/test_rest.py
index 3a61d13..bfb25c6 100644
--- a/tests/test_rest.py
+++ b/tests/test_rest.py
@@ -967,6 +967,19 @@ class RestTests(unittest.TestCase):
'POST')
self.assertEquals(400, resp.status)
+ # try to attach an interface of type "macvtap" without source
+ if os.uname()[4] == "s390x":
+ req = json.dumps({'type': 'macvtap'})
+ resp = self.request('/plugins/kimchi/vms/test-vm/ifaces', req,
+ 'POST')
+ self.assertEqual(400, resp.status)
+
+ # try to attach an interface of type "ovs" without source
+ req = json.dumps({'type': 'ovs'})
+ resp = self.request('/plugins/kimchi/vms/test-vm/ifaces', req,
+ 'POST')
+ self.assertEqual(400, resp.status)
+
# attach network interface to vm
req = json.dumps({"type": "network",
"network": "test-network",
@@ -1018,6 +1031,67 @@ class RestTests(unittest.TestCase):
iface['mac'], '{}', 'DELETE')
self.assertEquals(204, resp.status)
+ if os.uname()[4] == "s390x":
+ # attach macvtap interface to vm
+ req = json.dumps({"type": "macvtap",
+ "source": "test-network"})
+ resp = self.request('/plugins/kimchi/vms/test-vm/ifaces', req,
+ 'POST')
+ self.assertEquals(201, resp.status)
+ iface = json.loads(resp.read())
+
+ self.assertEquals('test-network', iface['source'])
+ self.assertEquals('macvtap', iface['type'])
+
+ # Start the VM
+ resp = self.request('/plugins/kimchi/vms/test-vm/start', '{}',
+ 'POST')
+ vm = json.loads(
+ self.request('/plugins/kimchi/vms/test-vm').read())
+ self.assertEquals('running', vm['state'])
+
+ # Force poweroff the VM
+ resp = self.request('/plugins/kimchi/vms/test-vm/poweroff',
+ '{}', 'POST')
+ vm = json.loads(
+ self.request('/plugins/kimchi/vms/test-vm').read())
+ self.assertEquals('shutoff', vm['state'])
+
+ # detach network interface from vm
+ resp = self.request('/plugins/kimchi/vms/test-vm/ifaces/%s' %
+ iface['mac'], '{}', 'DELETE')
+ self.assertEquals(204, resp.status)
+
+ # attach ovs interface to vm
+ req = json.dumps({"type": "ovs",
+ "source": "test-network"})
+ resp = self.request('/plugins/kimchi/vms/test-vm/ifaces', req,
+ 'POST')
+ self.assertEquals(201, resp.status)
+ iface = json.loads(resp.read())
+
+ self.assertEquals('test-network', iface['source'])
+ self.assertEquals('ovs', iface['type'])
+
+ # Start the VM
+ resp = self.request('/plugins/kimchi/vms/test-vm/start', '{}',
+ 'POST')
+ vm = json.loads(
+ self.request('/plugins/kimchi/vms/test-vm').read())
+ self.assertEquals('running', vm['state'])
+
+ # Force poweroff the VM
+ resp = self.request('/plugins/kimchi/vms/test-vm/poweroff',
+ '{}', 'POST')
+ vm = json.loads(
+ self.request('/plugins/kimchi/vms/test-vm').read())
+ self.assertEquals('shutoff', vm['state'])
+
+ # detach ovs interface from vm
+ resp = self.request('/plugins/kimchi/vms/test-vm/ifaces/%s' %
+ iface['mac'], '{}', 'DELETE')
+ self.assertEquals(204, resp.status)
+
def test_vm_customise_storage(self):
# Create a Template
req = json.dumps({'name': 'test', 'disks': DISKS,
@@ -1434,6 +1508,10 @@ class RestTests(unittest.TestCase):
if distro.get('reason'):
self.assertIn('KCHDISTRO0001E', distro.get('reason'))
+ def test_ovsbridges(self):
+ resp = self.request('/plugins/kimchi/ovsbridges')
+ self.assertEquals(200, resp.status)
+
class HttpsRestTests(RestTests):
"""
--
2.1.0
More information about the Kimchi-devel
mailing list