]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Add unit test for add_vxlan in test_linux_ip_lib
authorSphoorti Joglekar <sphoorti.joglekar@gmail.com>
Fri, 14 Mar 2014 12:52:43 +0000 (18:22 +0530)
committerMark McClain <mmcclain@yahoo-inc.com>
Fri, 4 Apr 2014 22:34:27 +0000 (18:34 -0400)
This patch adds unit tests for the add_vxlan function in the test_linux_ip_lib.py
file.

Fixes bug: 1291974

Change-Id: I0238bedab7a3566aff1115a091ada494a01d2e02
(cherry picked from commit dd52ddb1e9322b3985ceba2db842e8201220f67f)

neutron/tests/unit/test_linux_ip_lib.py

index ea23c854971a8ee9deb594877ef476bc9da33631..7eb58ad7ba5479182334a7a6c12aacb82d8d25a9 100644 (file)
@@ -371,6 +371,32 @@ class TestIpWrapper(base.BaseTestCase):
                 self.assertNotIn(mock.call().delete('ns'),
                                  ip_ns_cmd_cls.mock_calls)
 
+    def test_add_vxlan_valid_port_length(self):
+        retval = ip_lib.IPWrapper('sudo').add_vxlan('vxlan0', 'vni0',
+                                                    group='group0',
+                                                    dev='dev0', ttl='ttl0',
+                                                    tos='tos0',
+                                                    local='local0', proxy=True,
+                                                    port=('1', '2'))
+        self.assertIsInstance(retval, ip_lib.IPDevice)
+        self.assertEqual(retval.name, 'vxlan0')
+        self.execute.assert_called_once_with('', 'link',
+                                             ['add', 'vxlan0', 'type',
+                                              'vxlan', 'id', 'vni0', 'group',
+                                              'group0', 'dev', 'dev0',
+                                              'ttl', 'ttl0', 'tos', 'tos0',
+                                              'local', 'local0', 'proxy',
+                                              'port', '1', '2'],
+                                             'sudo', None)
+
+    def test_add_vxlan_invalid_port_length(self):
+        wrapper = ip_lib.IPWrapper('sudo')
+        self.assertRaises(exceptions.NetworkVxlanPortRangeError,
+                          wrapper.add_vxlan, 'vxlan0', 'vni0', group='group0',
+                          dev='dev0', ttl='ttl0', tos='tos0',
+                          local='local0', proxy=True,
+                          port=('1', '2', '3'))
+
     def test_add_device_to_namespace(self):
         dev = mock.Mock()
         ip_lib.IPWrapper('sudo', 'ns').add_device_to_namespace(dev)