Unit test and Readme changes related to cisco plugin.

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
This commit is contained in:
root 2012-06-18 06:09:00 -04:00 committed by Shweta P
parent 0c0d8f00a9
commit f7ccaac6f0
5 changed files with 105 additions and 76 deletions

View File

@ -1,7 +1,7 @@
[PLUGINS] [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 #nexus_plugin=quantum.plugins.cisco.nexus.cisco_nexus_plugin.NexusPlugin
[INVENTORY] [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 #nexus_plugin=quantum.plugins.cisco.nexus.cisco_nexus_inventory.NexusInventory

View File

@ -46,6 +46,7 @@ If you plan to just leverage the plugin framework, you do not need these.)
** Ubuntu 11.10 or above ** Ubuntu 11.10 or above
** Package: python-configobj-4.6.0-3.el6.noarch (or newer) ** Package: python-configobj-4.6.0-3.el6.noarch (or newer)
** Package: python-routes-1.12.3-2.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 If you are using a Nexus switch in your topology, you'll need the following
NX-OS version and packages to enable Nexus support: 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): 1. All unit tests (needs environment setup as indicated in the pre-requisites):
./run_tests.sh -N quantum.plugins.cisco.tests.unit Modify the environment variable to point to the plugin directory
or by modifying the environment variable to point to the plugin directory
In bash : export PLUGIN_DIR=quantum/plugins/cisco In bash : export PLUGIN_DIR=quantum/plugins/cisco
tcsh/csh : setenv 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
Another option is to execute the python script run_tests.py Execute the l2networkApi tests only using:
./run_tests.sh quantum.plugins.cisco.tests.unit.test_l2networkApi
python run_tests.py quantum.plugins.cisco.tests.unit If just the ucs or both ucs and the nexus plugins are configured then all the tests could be executed by
./run_tests.sh
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 2. Testing the core API (without UCS/Nexus/RHEL hardware, and can be run on
Ubuntu): 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 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 enabling just the UCS plugins, and finally enabling both the UCS and the
Nexus plugins. 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: 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 or
@ -395,7 +400,7 @@ result the run_tests.py script.
3. Specific Plugin unit test (needs environment setup as indicated in the 3. Specific Plugin unit test (needs environment setup as indicated in the
pre-requisites): 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 or
@ -405,6 +410,11 @@ result the run_tests.py script.
python run_tests.py quantum.plugins.cisco.tests.unit.test_ucs_plugin python run_tests.py quantum.plugins.cisco.tests.unit.test_ucs_plugin
To run specific tests, use the following: 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 python run_tests.py
quantum.plugins.cisco.tests.unit.<name_of_the_module>:<ClassName>.<funcName> 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 Location quantum/plugins/cisco/tests/unit/test_cisco_extension.py
The script can be executed by : 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 or

View File

@ -113,10 +113,13 @@ class CoreAPITestFunc(unittest.TestCase):
instance_vif_desc = {'project_id': tenant_id, instance_vif_desc = {'project_id': tenant_id,
'user_id': nova_user_id, 'user_id': nova_user_id,
'vif_id': vif_id} 'vif_id': vif_id}
vif_description = self._l2network_plugin.associate_port( if conf.PLUGINS[const.PLUGINS].keys():
instance_tenant_id, instance_id, vif_description = self._l2network_plugin.associate_port(
instance_vif_desc) 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.assertRaises(exc.NetworkInUse,
self._l2network_plugin.delete_network, tenant_id, self._l2network_plugin.delete_network, tenant_id,
new_net_dict[const.NET_ID]) new_net_dict[const.NET_ID])
@ -359,7 +362,6 @@ class CoreAPITestFunc(unittest.TestCase):
""" """
Tests deletion of Ports when port is in Use. Tests deletion of Ports when port is in Use.
""" """
LOG.debug("test_delete_portInUse - START") LOG.debug("test_delete_portInUse - START")
new_net_dict = self._l2network_plugin.create_network( new_net_dict = self._l2network_plugin.create_network(
tenant_id, self.network_name) tenant_id, self.network_name)
@ -374,12 +376,17 @@ class CoreAPITestFunc(unittest.TestCase):
instance_vif_desc = {'project_id': tenant_id, instance_vif_desc = {'project_id': tenant_id,
'user_id': nova_user_id, 'user_id': nova_user_id,
'vif_id': vif_id} 'vif_id': vif_id}
vif_description = self._l2network_plugin.associate_port( if conf.PLUGINS[const.PLUGINS].keys():
instance_tenant_id, instance_id, vif_description = self._l2network_plugin.associate_port(
instance_vif_desc) instance_tenant_id, instance_id, instance_vif_desc)
self.assertRaises(exc.PortInUse, else:
self._l2network_plugin.delete_port, tenant_id, db.port_set_attachment_by_id(port_dict[const.PORT_ID],
new_net_dict[const.NET_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( self.tearDownNetworkPortInterface(
tenant_id, instance_tenant_id, instance_id, instance_vif_desc, tenant_id, instance_tenant_id, instance_id, instance_vif_desc,
new_net_dict[const.NET_ID], port_dict[const.PORT_ID]) 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, instance_vif_desc = {'project_id': tenant_id,
'user_id': nova_user_id, 'user_id': nova_user_id,
'vif_id': vif_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( if conf.PLUGINS[const.PLUGINS].keys():
tenant_id, new_net_dict[const.NET_ID], vif_description = self._l2network_plugin.associate_port(
port_dict[const.PORT_ID], vif_id) 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 = db.port_get(new_net_dict[const.NET_ID],
port_dict[const.PORT_ID]) port_dict[const.PORT_ID])
self.assertEqual(port[const.INTERFACEID], vif_id) self.assertEqual(port[const.INTERFACEID], vif_id)
@ -543,13 +556,13 @@ class CoreAPITestFunc(unittest.TestCase):
""" """
Tests attachment of interface port does not exist Tests attachment of interface port does not exist
""" """
LOG.debug("test_plug_interface_portDNE - START") LOG.debug("test_plug_interface_portDNE - START")
new_net_dict = self._l2network_plugin.create_network(tenant_id, new_net_dict = self._l2network_plugin.create_network(tenant_id,
self.network_name) self.network_name)
self.assertRaises( self.assertRaises(exc.PortNotFound,
exc.PortNotFound, self._l2network_plugin.plug_interface, tenant_id, self._l2network_plugin.plug_interface,
new_net_dict[const.NET_ID], port_id, remote_interface) tenant_id, new_net_dict[const.NET_ID], port_id,
remote_interface)
self.tearDownNetwork(tenant_id, new_net_dict[const.NET_ID]) self.tearDownNetwork(tenant_id, new_net_dict[const.NET_ID])
LOG.debug("test_plug_interface_portDNE - END") 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 Tests attachment of new interface to the port when there is an
existing attachment existing attachment
""" """
LOG.debug("test_plug_interface_portInUse - START") LOG.debug("test_plug_interface_portInUse - START")
new_net_dict = self._l2network_plugin.create_network( new_net_dict = self._l2network_plugin.create_network(tenant_id,
tenant_id, self.network_name) self.network_name)
port_dict = self._l2network_plugin.create_port( 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, instance_desc = {'project_id': tenant_id, 'user_id': nova_user_id}
'user_id': nova_user_id}
host_list = self._l2network_plugin.schedule_host(instance_tenant_id, host_list = self._l2network_plugin.schedule_host(instance_tenant_id,
instance_id, instance_id,
instance_desc) instance_desc)
instance_vif_desc = {'project_id': tenant_id, instance_vif_desc = {'project_id': tenant_id, 'user_id': nova_user_id,
'user_id': nova_user_id,
'vif_id': vif_id} 'vif_id': vif_id}
vif_description = self._l2network_plugin.associate_port(
instance_tenant_id, instance_id,
instance_vif_desc)
self.assertRaises(exc.PortInUse, if conf.PLUGINS[const.PLUGINS].keys():
self._l2network_plugin.plug_interface, tenant_id, vif_description = self._l2network_plugin.associate_port(
new_net_dict[const.NET_ID], 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) port_dict[const.PORT_ID], remote_interface)
self.tearDownNetworkPortInterface( self.tearDownNetworkPortInterface(tenant_id, instance_tenant_id,
tenant_id, instance_tenant_id, instance_id, instance_vif_desc, instance_id, instance_vif_desc,
new_net_dict[const.NET_ID], port_dict[const.PORT_ID]) new_net_dict[const.NET_ID],
port_dict[const.PORT_ID])
LOG.debug("test_plug_interface_portInUse - END") LOG.debug("test_plug_interface_portInUse - END")
@ -599,38 +614,43 @@ class CoreAPITestFunc(unittest.TestCase):
""" """
Tests detaachment of an interface to a port Tests detaachment of an interface to a port
""" """
LOG.debug("test_unplug_interface - START") LOG.debug("test_unplug_interface - START")
new_net_dict = self._l2network_plugin.create_network( new_net_dict = self._l2network_plugin.create_network(tenant_id,
tenant_id, self.network_name) self.network_name)
port_dict = self._l2network_plugin.create_port( port_dict = self._l2network_plugin.create_port(
tenant_id, new_net_dict[const.NET_ID], tenant_id, new_net_dict[const.NET_ID], self.state)
self.state)
instance_desc = {'project_id': tenant_id, instance_desc = {'project_id': tenant_id,
'user_id': nova_user_id} 'user_id': nova_user_id}
host_list = self._l2network_plugin.schedule_host(instance_tenant_id, host_list = self._l2network_plugin.schedule_host(instance_tenant_id,
instance_id, instance_id,
instance_desc) instance_desc)
instance_vif_desc = {'project_id': tenant_id, instance_vif_desc = {'project_id': tenant_id, 'user_id': nova_user_id,
'user_id': nova_user_id,
'vif_id': vif_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( if conf.PLUGINS[const.PLUGINS].keys():
tenant_id, new_net_dict[const.NET_ID], vif_description = self._l2network_plugin. associate_port(
port_dict[const.PORT_ID], vif_id) instance_tenant_id,
self._l2network_plugin.unplug_interface( instance_id,
tenant_id, new_net_dict[const.NET_ID], instance_vif_desc)
port_dict[const.PORT_ID]) 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 = db.port_get(new_net_dict[const.NET_ID],
port_dict[const.PORT_ID]) port_dict[const.PORT_ID])
vif_id_unplugged = vif_id + '(detached)' vif_id_unplugged = vif_id + '(detached)'
self.assertEqual(port[const.INTERFACEID], vif_id_unplugged) self.assertEqual(port[const.INTERFACEID], vif_id_unplugged)
self.tearDownNetworkPortInterface( self.tearDownNetworkPortInterface(tenant_id, instance_tenant_id,
tenant_id, instance_tenant_id, instance_id, instance_vif_desc, instance_id, instance_vif_desc,
new_net_dict[const.NET_ID], port_dict[const.PORT_ID]) new_net_dict[const.NET_ID],
port_dict[const.PORT_ID])
LOG.debug("test_unplug_interface - END") LOG.debug("test_unplug_interface - END")
@ -1020,8 +1040,11 @@ class CoreAPITestFunc(unittest.TestCase):
""" """
Tear down Network Port Interface Tear down Network Port Interface
""" """
self._l2network_plugin.detach_port(instance_tenant_id, instance_id, if not conf.PLUGINS[const.PLUGINS].keys():
instance_desc) 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) self.tearDownNetworkPort(tenant_id, network_dict_id, port_id)
def tearDownPortProfile(self, tenant_id, port_profile_id): def tearDownPortProfile(self, tenant_id, port_profile_id):

View File

@ -29,10 +29,8 @@ from quantum.plugins.cisco.l2network_plugin import L2Network
from quantum.plugins.cisco.ucs.cisco_ucs_inventory import UCSInventory from quantum.plugins.cisco.ucs.cisco_ucs_inventory import UCSInventory
logging.basicConfig(level=LOG.WARN)
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
# Set some data to use in tests # Set some data to use in tests
tenant = 'shubh' tenant = 'shubh'
net_name = 'TestNetwork1' net_name = 'TestNetwork1'

View 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_inventory as ucsinv
from quantum.plugins.cisco.ucs import cisco_ucs_plugin from quantum.plugins.cisco.ucs import cisco_ucs_plugin
LOG = logging.getLogger(__name__)
logging.basicConfig(level=LOG.WARN)
LOG = logging.getLogger("cisco_ucs_plugin")
class UCSVICTestPlugin(unittest.TestCase): class UCSVICTestPlugin(unittest.TestCase):