On 02/18/2014 04:41 PM, Ramon Medeiros wrote:
Add a test without subnet while creating a network interface, to
test
bug
https://github.com/kimchi-project/kimchi/issues/318.
Signed-off-by: Ramon Medeiros <ramonn(a)linux.vnet.ibm.com>
---
tests/test_model.py | 36 ++++++++++++++++++++++++++++++++----
1 file changed, 32 insertions(+), 4 deletions(-)
diff --git a/tests/test_model.py b/tests/test_model.py
index 859f7bd..df6b3d0 100644
--- a/tests/test_model.py
+++ b/tests/test_model.py
@@ -537,21 +537,49 @@ class ModelTests(unittest.TestCase):
inst = model.Model('qemu:///system', self.tmp_store)
with RollbackContext() as rollback:
- name = 'test-network'
+
+ # Regression test:
+ # Kimchi fails creating new network #318
+ name = 'test-network-no-subnet'
networks = inst.networks_get_list()
num = len(networks) + 1
args = {'name': name,
'connection': 'nat',
- 'subnet': '127.0.100.0/24'}
+ 'subnet': ''}
inst.networks_create(args)
rollback.prependDefer(inst.network_delete, name)
networks = inst.networks_get_list()
self.assertEquals(num, len(networks))
+ networkinfo = inst.network_lookup(name)
+ self.assertNotEqual(args['subnet'], networkinfo['subnet'])
+ self.assertEqual(args['connection'],
networkinfo['connection'])
+ self.assertEquals('inactive', networkinfo['state'])
+ self.assertEquals([], networkinfo['vms'])
+ self.assertTrue(networkinfo['autostart'])
+ inst.network_activate(name)
+ rollback.prependDefer(inst.network_deactivate, name)
+
+ networkinfo = inst.network_lookup(name)
+ self.assertEquals('active', networkinfo['state'])
+
+ # test network creation with subnet passed
+ name = 'test-network-subnet'
+
+ networks = inst.networks_get_list()
+ num = len(networks) + 1
+ args = {'name': name,
+ 'connection': 'nat',
+ 'subnet': '127.0.0.0/24'}
The tests are failing:
======================================================================
ERROR: test_network (test_model.ModelTests)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/alinefm/kimchi/tests/test_model.py", line 588, in
test_network
inst.network_activate(name)
File "/home/alinefm/kimchi/src/kimchi/model/networks.py", line 213,
in activate
network.create()
File "/home/alinefm/kimchi/src/kimchi/model/libvirtconnection.py",
line 65, in wrapper
ret = f(*args, **kwargs)
File "/home/alinefm/kimchi/src/kimchi/model/libvirtconnection.py",
line 65, in wrapper
ret = f(*args, **kwargs)
File "/home/alinefm/kimchi/src/kimchi/model/libvirtconnection.py",
line 65, in wrapper
ret = f(*args, **kwargs)
File "/home/alinefm/kimchi/src/kimchi/model/libvirtconnection.py",
line 65, in wrapper
ret = f(*args, **kwargs)
File "/home/alinefm/kimchi/src/kimchi/model/libvirtconnection.py",
line 65, in wrapper
ret = f(*args, **kwargs)
File "/home/alinefm/kimchi/src/kimchi/model/libvirtconnection.py",
line 65, in wrapper
ret = f(*args, **kwargs)
File "/home/alinefm/kimchi/src/kimchi/model/libvirtconnection.py",
line 65, in wrapper
ret = f(*args, **kwargs)
File "/home/alinefm/kimchi/src/kimchi/model/libvirtconnection.py",
line 65, in wrapper
ret = f(*args, **kwargs)
File "/home/alinefm/kimchi/src/kimchi/model/libvirtconnection.py",
line 65, in wrapper
ret = f(*args, **kwargs)
File "/home/alinefm/kimchi/src/kimchi/model/libvirtconnection.py",
line 65, in wrapper
ret = f(*args, **kwargs)
File "/usr/lib/python2.7/dist-packages/libvirt.py", line 1951, in create
if ret == -1: raise libvirtError ('virNetworkCreate() failed',
net=self)
libvirtError: internal error Child process (/usr/sbin/dnsmasq -u
libvirt-dnsmasq --strict-order --bind-interfaces
--pid-file=/var/run/libvirt/network/test-network-subnet.pid --conf-file=
--except-interface lo --listen-address 127.0.0.1 --dhcp-range
127.0.0.129,127.0.0.255
--dhcp-leasefile=/var/lib/libvirt/dnsmasq/test-network-subnet.leases
--dhcp-lease-max=127 --dhcp-no-override) status unexpected: exit status 2
It needs to be a different subnet as 127.0.0.0 is already in use
I will change it before applying
+ inst.networks_create(args)
+ rollback.prependDefer(inst.network_delete, name)
+
+ networks = inst.networks_get_list()
+ self.assertEquals(num, len(networks))
networkinfo = inst.network_lookup(name)
- self.assertEquals(args['subnet'], networkinfo['subnet'])
+ self.assertEqual(args['subnet'], networkinfo['subnet'])
self.assertEqual(args['connection'],
networkinfo['connection'])
self.assertEquals('inactive', networkinfo['state'])
self.assertEquals([], networkinfo['vms'])
@@ -564,7 +592,7 @@ class ModelTests(unittest.TestCase):
self.assertEquals('active', networkinfo['state'])
networks = inst.networks_get_list()
- self.assertEquals((num - 1), len(networks))
+ self.assertEquals((num - 2), len(networks))
def test_multithreaded_connection(self):
def worker():