[Kimchi-devel] [PATCH] Change network tests

Ramon Medeiros ramonn at linux.vnet.ibm.com
Tue Feb 18 17:03:12 UTC 2014


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 at 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'}
+            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():
-- 
1.8.3.1




More information about the Kimchi-devel mailing list