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 9271654adf
commit b1c7d5519e
5 changed files with 105 additions and 76 deletions

View 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

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
** 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
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
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

View 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):

View 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'

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_plugin
logging.basicConfig(level=LOG.WARN)
LOG = logging.getLogger("cisco_ucs_plugin")
LOG = logging.getLogger(__name__)
class UCSVICTestPlugin(unittest.TestCase):