Hi Pooja,
make check-local is failing:
/bin/pep8 --version
1.5.7
/bin/pep8 --filename '*.py,*.py.in'
--exclude="*config.py,*i18n.py,*tests/test_config.py" .
./tests/test_model.py:679:5: E303 too many blank lines (2)
./tests/test_rest.py:974:33: E128 continuation line under-indented for
visual indent
./tests/test_rest.py:977:17: E265 block comment should start with '# '
./tests/test_rest.py:980:33: E128 continuation line under-indented for
visual indent
./tests/test_rest.py:1039:33: E128 continuation line under-indented for
visual indent
./tests/test_rest.py:1049:80: E501 line too long (83 > 79 characters)
./tests/test_rest.py:1053:80: E501 line too long (81 > 79 characters)
./tests/test_rest.py:1055:80: E501 line too long (83 > 79 characters)
./tests/test_rest.py:1063:18: E111 indentation is not a multiple of four
./tests/test_rest.py:1063:18: E113 unexpected indentation
./tests/test_rest.py:1067:33: E128 continuation line under-indented for
visual indent
./tests/test_rest.py:1077:80: E501 line too long (83 > 79 characters)
./tests/test_rest.py:1081:80: E501 line too long (81 > 79 characters)
./tests/test_rest.py:1083:80: E501 line too long (83 > 79 characters)
Makefile:1062: recipe for target 'check-local' failed
make[3]: *** [check-local] Error 1
Could you fix that and resend?
Thanks,
Aline Manera
On 09/15/2016 06:04 AM, pkulkark(a)linux.vnet.ibm.com wrote:
From: Pooja Kulkarni <pkulkark(a)linux.vnet.ibm.com>
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(a)linux.vnet.ibm.com>
---
tests/test_model.py | 25 ++++++++++++++++++
tests/test_rest.py | 74 +++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 99 insertions(+)
diff --git a/tests/test_model.py b/tests/test_model.py
index ff2a6cb..6509e21 100644
--- a/tests/test_model.py
+++ b/tests/test_model.py
@@ -651,6 +651,31 @@ 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..b672f47 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,63 @@ 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 +1504,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):
"""