]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Unit test and Readme changes related to cisco plugin.
authorroot <root@opnstck-compute2.(none)>
Mon, 18 Jun 2012 10:09:00 +0000 (06:09 -0400)
committerShweta P <shpadubi@cisco.com>
Tue, 19 Jun 2012 08:56:34 +0000 (04:56 -0400)
Change-Id: Ica6db500a2ec8a895cb90756ca9ff304faa16519

Unit test and Readme changes related to cisco plugin.

Remove additional space in the Readme file

Remove file inadverntently checked in

Bug #1015410

Change-Id: I273255ff475b1ca6e80409fbf7f8c8571b3c456c

etc/quantum/plugins/cisco/cisco_plugins.ini
quantum/plugins/cisco/README
quantum/plugins/cisco/tests/unit/test_l2networkApi.py
quantum/plugins/cisco/tests/unit/test_ucs_inventory.py
quantum/plugins/cisco/tests/unit/test_ucs_plugin.py

index de98ccb18e25e28a38da142871b85522ad79230a..2e6308766a1267b2fa8a4b11eab5a87c70e8f575 100644 (file)
@@ -1,7 +1,7 @@
 [PLUGINS]
-ucs_plugin=quantum.plugins.cisco.ucs.cisco_ucs_plugin.UCSVICPlugin
+#ucs_plugin=quantum.plugins.cisco.ucs.cisco_ucs_plugin.UCSVICPlugin
 #nexus_plugin=quantum.plugins.cisco.nexus.cisco_nexus_plugin.NexusPlugin
 
 [INVENTORY]
-ucs_plugin=quantum.plugins.cisco.ucs.cisco_ucs_inventory.UCSInventory
+#ucs_plugin=quantum.plugins.cisco.ucs.cisco_ucs_inventory.UCSInventory
 #nexus_plugin=quantum.plugins.cisco.nexus.cisco_nexus_inventory.NexusInventory
index d817643631f30c02428236f79f2b604244bf30d6..bccbcb555481e3779eca492273d3cb41ff7a4312 100755 (executable)
@@ -46,6 +46,7 @@ If you plan to just leverage the plugin framework, you do not need these.)
   ** Ubuntu 11.10 or above
   ** Package: python-configobj-4.6.0-3.el6.noarch (or newer)
   ** Package: python-routes-1.12.3-2.el6.noarch (or newer)
+  ** Package: pip install mysql-python
 
 If you are using a Nexus switch in your topology, you'll need the following
 NX-OS version and packages to enable Nexus support:
@@ -364,29 +365,33 @@ result the run_tests.py script.
 
 1. All unit tests (needs environment setup as indicated in the pre-requisites):
 
-   ./run_tests.sh -N quantum.plugins.cisco.tests.unit
-
-   or by modifying the environment variable to point to the plugin directory
+   Modify the environment variable to point to the plugin directory
 
        In bash : export PLUGIN_DIR=quantum/plugins/cisco
           tcsh/csh : setenv PLUGIN_DIR quantum/plugins/cisco
 
-       ./run_tests.sh -N
+   When no sub-plugins are configured(ucs or nexus plugins), execute only the l2networkApi unit tests.
+   Device-specific sub-plugins can be disabled by commenting out all the entries in:
+       etc/quantum/plugins/cisco/cisco_plugins.ini
+
+   Execute the l2networkApi tests only using:
+       ./run_tests.sh quantum.plugins.cisco.tests.unit.test_l2networkApi
 
-   Another option is to execute the python script run_tests.py
+   If just the ucs or both ucs and the nexus plugins are configured then all the tests could be executed by
+       ./run_tests.sh
 
-   python run_tests.py quantum.plugins.cisco.tests.unit
+   All the test execution steps listed below is for when the sub-plugins are configured.
 
 2. Testing the core API (without UCS/Nexus/RHEL hardware, and can be run on
    Ubuntu):
-   Device-specific plugins can be disabled by commenting out the entries in:
-   etc/quantum/plugins/cisco/cisco_plugins.ini
    The Core API can be tested by initially disabling all device plugins, then
    enabling just the UCS plugins, and finally enabling both the UCS and the
    Nexus plugins.
+   Device-specific plugins can be disabled by commenting out the entries in:
+       etc/quantum/plugins/cisco/cisco_plugins.ini
    Execute the test script as follows:
 
-   ./run_tests.sh -N quantum.plugins.cisco.tests.unit.test_l2networkApi
+   ./run_tests.sh quantum.plugins.cisco.tests.unit.test_l2networkApi
 
    or
 
@@ -395,7 +400,7 @@ result the run_tests.py script.
 3. Specific Plugin unit test (needs environment setup as indicated in the
    pre-requisites):
 
-   ./run_tests.sh -N quantum.plugins.cisco.tests.unit.<name_of_the_module>
+   ./run_tests.sh quantum.plugins.cisco.tests.unit.<name_of_the_module>
 
    or
 
@@ -405,6 +410,11 @@ result the run_tests.py script.
    python run_tests.py quantum.plugins.cisco.tests.unit.test_ucs_plugin
 
    To run specific tests, use the following:
+
+   ./run_tests.sh quantum.plugins.cisco.tests.unit.<name_of_the_module>:<ClassName>.<funcName>
+
+   or
+
    python run_tests.py
     quantum.plugins.cisco.tests.unit.<name_of_the_module>:<ClassName>.<funcName>
 
@@ -418,7 +428,7 @@ result the run_tests.py script.
    Location quantum/plugins/cisco/tests/unit/test_cisco_extension.py
 
    The script can be executed by :
-    ./run_tests.sh -N quantum.plugins.cisco.tests.unit.test_cisco_extension
+    ./run_tests.sh quantum.plugins.cisco.tests.unit.test_cisco_extension
 
     or
 
index fa3824ff0c81638257ab54dea8d6c01a1af2a620..d335fbd22998eb52ee4ec6a1867528096e4b76ad 100644 (file)
@@ -113,10 +113,13 @@ class CoreAPITestFunc(unittest.TestCase):
         instance_vif_desc = {'project_id': tenant_id,
                              'user_id': nova_user_id,
                              'vif_id': vif_id}
-        vif_description = self._l2network_plugin.associate_port(
-            instance_tenant_id, instance_id,
-            instance_vif_desc)
-
+        if conf.PLUGINS[const.PLUGINS].keys():
+            vif_description = self._l2network_plugin.associate_port(
+                instance_tenant_id, instance_id, instance_vif_desc)
+        else:
+            db.port_set_attachment_by_id(port_dict[const.PORT_ID],
+                                         instance_vif_desc['vif_id'] +
+                                         const.UNPLUGGED)
         self.assertRaises(exc.NetworkInUse,
                           self._l2network_plugin.delete_network, tenant_id,
                           new_net_dict[const.NET_ID])
@@ -359,7 +362,6 @@ class CoreAPITestFunc(unittest.TestCase):
         """
         Tests deletion of Ports when port is in Use.
         """
-
         LOG.debug("test_delete_portInUse - START")
         new_net_dict = self._l2network_plugin.create_network(
             tenant_id, self.network_name)
@@ -374,12 +376,17 @@ class CoreAPITestFunc(unittest.TestCase):
         instance_vif_desc = {'project_id': tenant_id,
                              'user_id': nova_user_id,
                              'vif_id': vif_id}
-        vif_description = self._l2network_plugin.associate_port(
-            instance_tenant_id, instance_id,
-            instance_vif_desc)
-        self.assertRaises(exc.PortInUse,
-                          self._l2network_plugin.delete_port, tenant_id,
-                          new_net_dict[const.NET_ID], port_dict[const.PORT_ID])
+        if conf.PLUGINS[const.PLUGINS].keys():
+            vif_description = self._l2network_plugin.associate_port(
+                instance_tenant_id, instance_id, instance_vif_desc)
+        else:
+            db.port_set_attachment_by_id(port_dict[const.PORT_ID],
+                                         instance_vif_desc['vif_id'] +
+                                         const.UNPLUGGED)
+
+        self.assertRaises(exc.PortInUse, self._l2network_plugin.delete_port,
+                          tenant_id, new_net_dict[const.NET_ID],
+                          port_dict[const.PORT_ID])
         self.tearDownNetworkPortInterface(
             tenant_id, instance_tenant_id, instance_id, instance_vif_desc,
             new_net_dict[const.NET_ID], port_dict[const.PORT_ID])
@@ -506,13 +513,19 @@ class CoreAPITestFunc(unittest.TestCase):
         instance_vif_desc = {'project_id': tenant_id,
                              'user_id': nova_user_id,
                              'vif_id': vif_id}
-        vif_description = self._l2network_plugin.associate_port(
-            instance_tenant_id, instance_id,
-            instance_vif_desc)
 
-        self._l2network_plugin.plug_interface(
-            tenant_id, new_net_dict[const.NET_ID],
-            port_dict[const.PORT_ID], vif_id)
+        if conf.PLUGINS[const.PLUGINS].keys():
+            vif_description = self._l2network_plugin.associate_port(
+                instance_tenant_id, instance_id,
+                instance_vif_desc)
+        else:
+            db.port_set_attachment_by_id(port_dict[const.PORT_ID],
+                                         instance_vif_desc['vif_id'] +
+                                         const.UNPLUGGED)
+
+        self._l2network_plugin.plug_interface(tenant_id,
+                                              new_net_dict[const.NET_ID],
+                                              port_dict[const.PORT_ID], vif_id)
         port = db.port_get(new_net_dict[const.NET_ID],
                            port_dict[const.PORT_ID])
         self.assertEqual(port[const.INTERFACEID], vif_id)
@@ -543,13 +556,13 @@ class CoreAPITestFunc(unittest.TestCase):
         """
         Tests attachment of interface port does not exist
         """
-
         LOG.debug("test_plug_interface_portDNE - START")
         new_net_dict = self._l2network_plugin.create_network(tenant_id,
                                                              self.network_name)
-        self.assertRaises(
-            exc.PortNotFound, self._l2network_plugin.plug_interface, tenant_id,
-            new_net_dict[const.NET_ID], port_id, remote_interface)
+        self.assertRaises(exc.PortNotFound,
+                          self._l2network_plugin.plug_interface,
+                          tenant_id, new_net_dict[const.NET_ID], port_id,
+                          remote_interface)
         self.tearDownNetwork(tenant_id, new_net_dict[const.NET_ID])
         LOG.debug("test_plug_interface_portDNE - END")
 
@@ -564,31 +577,33 @@ class CoreAPITestFunc(unittest.TestCase):
         Tests attachment of new interface to the port when there is an
         existing attachment
         """
-
         LOG.debug("test_plug_interface_portInUse - START")
-        new_net_dict = self._l2network_plugin.create_network(
-            tenant_id, self.network_name)
+        new_net_dict = self._l2network_plugin.create_network(tenant_id,
+                                                             self.network_name)
         port_dict = self._l2network_plugin.create_port(
             tenant_id, new_net_dict[const.NET_ID], self.state)
-        instance_desc = {'project_id': tenant_id,
-                         'user_id': nova_user_id}
+        instance_desc = {'project_id': tenant_id, 'user_id': nova_user_id}
         host_list = self._l2network_plugin.schedule_host(instance_tenant_id,
                                                          instance_id,
                                                          instance_desc)
-        instance_vif_desc = {'project_id': tenant_id,
-                             'user_id': nova_user_id,
+        instance_vif_desc = {'project_id': tenant_id, 'user_id': nova_user_id,
                              'vif_id': vif_id}
-        vif_description = self._l2network_plugin.associate_port(
-            instance_tenant_id, instance_id,
-            instance_vif_desc)
 
-        self.assertRaises(exc.PortInUse,
-                          self._l2network_plugin.plug_interface, tenant_id,
-                          new_net_dict[const.NET_ID],
+        if conf.PLUGINS[const.PLUGINS].keys():
+            vif_description = self._l2network_plugin.associate_port(
+                instance_tenant_id, instance_id, instance_vif_desc)
+        else:
+            db.port_set_attachment_by_id(port_dict[const.PORT_ID],
+                                         instance_vif_desc['vif_id'] +
+                                         const.UNPLUGGED)
+
+        self.assertRaises(exc.PortInUse, self._l2network_plugin.plug_interface,
+                          tenant_id, new_net_dict[const.NET_ID],
                           port_dict[const.PORT_ID], remote_interface)
-        self.tearDownNetworkPortInterface(
-            tenant_id, instance_tenant_id, instance_id, instance_vif_desc,
-            new_net_dict[const.NET_ID], port_dict[const.PORT_ID])
+        self.tearDownNetworkPortInterface(tenant_id, instance_tenant_id,
+                                          instance_id, instance_vif_desc,
+                                          new_net_dict[const.NET_ID],
+                                          port_dict[const.PORT_ID])
 
         LOG.debug("test_plug_interface_portInUse - END")
 
@@ -599,38 +614,43 @@ class CoreAPITestFunc(unittest.TestCase):
         """
         Tests detaachment of an interface to a port
         """
-
         LOG.debug("test_unplug_interface - START")
-        new_net_dict = self._l2network_plugin.create_network(
-            tenant_id, self.network_name)
+        new_net_dict = self._l2network_plugin.create_network(tenant_id,
+                                                             self.network_name)
         port_dict = self._l2network_plugin.create_port(
-            tenant_id, new_net_dict[const.NET_ID],
-            self.state)
+            tenant_id, new_net_dict[const.NET_ID], self.state)
         instance_desc = {'project_id': tenant_id,
                          'user_id': nova_user_id}
         host_list = self._l2network_plugin.schedule_host(instance_tenant_id,
                                                          instance_id,
                                                          instance_desc)
-        instance_vif_desc = {'project_id': tenant_id,
-                             'user_id': nova_user_id,
+        instance_vif_desc = {'project_id': tenant_id, 'user_id': nova_user_id,
                              'vif_id': vif_id}
-        vif_description = self._l2network_plugin.associate_port(
-            instance_tenant_id, instance_id,
-            instance_vif_desc)
 
-        self._l2network_plugin.plug_interface(
-            tenant_id, new_net_dict[const.NET_ID],
-            port_dict[const.PORT_ID], vif_id)
-        self._l2network_plugin.unplug_interface(
-            tenant_id, new_net_dict[const.NET_ID],
-            port_dict[const.PORT_ID])
+        if conf.PLUGINS[const.PLUGINS].keys():
+            vif_description = self._l2network_plugin. associate_port(
+                instance_tenant_id,
+                instance_id,
+                instance_vif_desc)
+        else:
+            db.port_set_attachment_by_id(port_dict[const.PORT_ID],
+                                         instance_vif_desc['vif_id'] +
+                                         const.UNPLUGGED)
+
+        self._l2network_plugin.plug_interface(tenant_id,
+                                              new_net_dict[const.NET_ID],
+                                              port_dict[const.PORT_ID], vif_id)
+        self._l2network_plugin.unplug_interface(tenant_id,
+                                                new_net_dict[const.NET_ID],
+                                                port_dict[const.PORT_ID])
         port = db.port_get(new_net_dict[const.NET_ID],
                            port_dict[const.PORT_ID])
         vif_id_unplugged = vif_id + '(detached)'
         self.assertEqual(port[const.INTERFACEID], vif_id_unplugged)
-        self.tearDownNetworkPortInterface(
-            tenant_id, instance_tenant_id, instance_id, instance_vif_desc,
-            new_net_dict[const.NET_ID], port_dict[const.PORT_ID])
+        self.tearDownNetworkPortInterface(tenant_id, instance_tenant_id,
+                                          instance_id, instance_vif_desc,
+                                          new_net_dict[const.NET_ID],
+                                          port_dict[const.PORT_ID])
 
         LOG.debug("test_unplug_interface - END")
 
@@ -1020,8 +1040,11 @@ class CoreAPITestFunc(unittest.TestCase):
         """
         Tear down Network Port Interface
         """
-        self._l2network_plugin.detach_port(instance_tenant_id, instance_id,
-                                           instance_desc)
+        if not conf.PLUGINS[const.PLUGINS].keys():
+            db.port_unset_attachment_by_id(port_id)
+        else:
+            self._l2network_plugin.detach_port(instance_tenant_id, instance_id,
+                                               instance_desc)
         self.tearDownNetworkPort(tenant_id, network_dict_id, port_id)
 
     def tearDownPortProfile(self, tenant_id, port_profile_id):
index 1183aa85ae1cfc9be87f0b343ffb42a5bb770f13..537bc2e51953994648c2cc940bd8edc4446ce330 100644 (file)
@@ -29,10 +29,8 @@ from quantum.plugins.cisco.l2network_plugin import L2Network
 from quantum.plugins.cisco.ucs.cisco_ucs_inventory import UCSInventory
 
 
-logging.basicConfig(level=LOG.WARN)
 LOG = logging.getLogger(__name__)
 
-
 # Set some data to use in tests
 tenant = 'shubh'
 net_name = 'TestNetwork1'
index 5bcd74be8f40b9a4efa7e2e5426e8293c5dc4445..887359b89130546bf61b866087a35e7426c9a787 100644 (file)
@@ -29,9 +29,7 @@ from quantum.plugins.cisco.ucs import cisco_ucs_configuration as conf
 from quantum.plugins.cisco.ucs import cisco_ucs_inventory as ucsinv
 from quantum.plugins.cisco.ucs import cisco_ucs_plugin
 
-
-logging.basicConfig(level=LOG.WARN)
-LOG = logging.getLogger("cisco_ucs_plugin")
+LOG = logging.getLogger(__name__)
 
 
 class UCSVICTestPlugin(unittest.TestCase):