From 4e1d511d7661e1156fcb608145f0530979789d31 Mon Sep 17 00:00:00 2001 From: Shweta P Date: Wed, 24 Aug 2011 00:02:10 -0700 Subject: [PATCH] Review Changes --- quantum/plugins/cisco/README | 17 ++- .../plugins/cisco/conf/quantum.conf.ciscoext | 4 +- .../cisco/tests/unit/test_cisco_extension.py | 144 ++++++++++++++++-- .../cisco/tests/unit/test_l2networkApi.py | 71 +++------ .../cisco/tests/unit/test_nexus_plugin.py | 18 +-- .../cisco/tests/unit/test_ucs_driver.py | 3 +- .../cisco/tests/unit/test_ucs_plugin.py | 90 ++++++++++- 7 files changed, 261 insertions(+), 86 deletions(-) diff --git a/quantum/plugins/cisco/README b/quantum/plugins/cisco/README index 586997e73..9b8e622c4 100755 --- a/quantum/plugins/cisco/README +++ b/quantum/plugins/cisco/README @@ -186,7 +186,8 @@ result the quantum/plugins/cisco/run_tests.py script. Set the environment variable PLUGIN_DIR to the location of the plugin directory. This is manadatory if the run_tests.sh script is used. - export PLUGIN_DIR=quantum/plugins/cisco + In bash : export PLUGIN_DIR=quantum/plugins/cisco + tcsh/csh : setenv PLUGIN_DIR quantum/plugins/cisco ./run_tests.sh quantum.plugins.cisco.tests.unit.test_l2networkApi or @@ -197,7 +198,8 @@ result the quantum/plugins/cisco/run_tests.py script. 2. Specific Plugin unit test (needs environment setup as indicated in the pre-requisites): - export PLUGIN_DIR=quantum/plugins/cisco + In bash : export PLUGIN_DIR=quantum/plugins/cisco + tcsh/csh : setenv PLUGIN_DIR quantum/plugins/cisco ./run_tests.sh quantum.plugins.cisco.tests.unit. or @@ -211,7 +213,9 @@ result the quantum/plugins/cisco/run_tests.py script. 3. All unit tests (needs environment setup as indicated in the pre-requisites): - export PLUGIN_DIR=quantum/plugins/cisco + In bash : export PLUGIN_DIR=quantum/plugins/cisco + tcsh/csh : setenv PLUGIN_DIR quantum/plugins/cisco + ./run_tests.sh quantum.plugins.cisco.tests.unit or @@ -223,6 +227,13 @@ result the quantum/plugins/cisco/run_tests.py script. change later. Location quantum/plugins/cisco/tests/unit/test_cisco_extension.py + The script can be executed by : + ./run_tests.sh quantum.plugins.cisco.tests.unit.test_cisco_extension + + or + + python run_tests.py quantum.plugins.cisco.tests.unit.test_cisco_extension + Additional installation required on Nova Compute ------------------------------------------------ 1. Create a table in the "nova" database for ports. This can be diff --git a/quantum/plugins/cisco/conf/quantum.conf.ciscoext b/quantum/plugins/cisco/conf/quantum.conf.ciscoext index 925a5ae90..116a6d9a7 100644 --- a/quantum/plugins/cisco/conf/quantum.conf.ciscoext +++ b/quantum/plugins/cisco/conf/quantum.conf.ciscoext @@ -12,7 +12,7 @@ bind_host = 0.0.0.0 bind_port = 9696 # Path to the extensions -api_extensions_path = ../extensions +api_extensions_path = ../../../../extensions [pipeline:extensions_app_with_filter] pipeline = extensions extensions_test_app @@ -21,4 +21,4 @@ pipeline = extensions extensions_test_app paste.filter_factory = quantum.common.extensions:plugin_aware_extension_middleware_factory [app:extensions_test_app] -paste.app_factory = tests.unit.test_cisco_extension:app_factory +paste.app_factory = quantum.plugins.cisco.tests.unit.test_cisco_extension:app_factory diff --git a/quantum/plugins/cisco/tests/unit/test_cisco_extension.py b/quantum/plugins/cisco/tests/unit/test_cisco_extension.py index 36e8d5234..a6bbe3c64 100644 --- a/quantum/plugins/cisco/tests/unit/test_cisco_extension.py +++ b/quantum/plugins/cisco/tests/unit/test_cisco_extension.py @@ -17,12 +17,12 @@ # @authors: Shweta Padubidri, Cisco Systems, Inc. # Peter Strunk , Cisco Systems, Inc. # Shubhangi Satras , Cisco Systems, Inc. -import json -import os.path -import routes import unittest import logging import webob +import json +import os.path +import routes from webtest import TestApp from extensions import credential from extensions import portprofile @@ -41,9 +41,9 @@ from quantum.manager import QuantumManager from quantum.plugins.cisco import l2network_plugin TEST_CONF_FILE = os.path.join(os.path.dirname(__file__), os.pardir, - os.pardir, 'etc', 'quantum.conf.ciscoext') -EXTENSIONS_PATH = os.path.join(os.path.dirname(__file__), os.pardir, - os.pardir, "extensions") + os.pardir, 'conf', 'quantum.conf.ciscoext') +EXTENSIONS_PATH = os.path.join(os.path.dirname(__file__), os.pardir, os.pardir, + os.pardir, os.pardir, os.pardir, "extensions") LOG = logging.getLogger('quantum.plugins.cisco.tests.test_cisco_extensions') @@ -62,6 +62,9 @@ class ExtensionsTestApp(wsgi.Router): class PortprofileExtensionTest(unittest.TestCase): def setUp(self): + + """ Set up function """ + parent_resource = dict(member_name="tenant", collection_name="extensions/csco/tenants") member_actions = {'associate_portprofile': "PUT", @@ -89,6 +92,8 @@ class PortprofileExtensionTest(unittest.TestCase): def test_list_portprofile(self): + """ Test List Portprofile""" + LOG.debug("test_list_portprofile - START") req_body1 = json.dumps(self.test_port_profile) create_response1 = self.test_app.post( @@ -121,6 +126,8 @@ class PortprofileExtensionTest(unittest.TestCase): def test_create_portprofile(self): + """ Test create Portprofile""" + LOG.debug("test_create_portprofile - START") req_body = json.dumps(self.test_port_profile) index_response = self.test_app.post(self.profile_path, req_body, @@ -138,6 +145,8 @@ class PortprofileExtensionTest(unittest.TestCase): def test_create_portprofileBADRequest(self): + """ Test create Portprofile Bad Request""" + LOG.debug("test_create_portprofileBADRequest - START") index_response = self.test_app.post(self.profile_path, 'BAD_REQUEST', content_type=self.contenttype, @@ -147,6 +156,8 @@ class PortprofileExtensionTest(unittest.TestCase): def test_show_portprofile(self): + """ Test show Portprofile """ + LOG.debug("test_show_portprofile - START") req_body = json.dumps(self.test_port_profile) index_response = self.test_app.post(self.profile_path, req_body, @@ -165,6 +176,8 @@ class PortprofileExtensionTest(unittest.TestCase): def test_show_portprofileDNE(self, portprofile_id='100'): + """ Test show Portprofile does not exist""" + LOG.debug("test_show_portprofileDNE - START") show_path_temp = self.portprofile_path + portprofile_id show_port_path = str(show_path_temp) @@ -174,6 +187,8 @@ class PortprofileExtensionTest(unittest.TestCase): def test_update_portprofile(self): + """ Test update Portprofile""" + LOG.debug("test_update_portprofile - START") req_body = json.dumps(self.test_port_profile) index_response = self.test_app.post( @@ -197,6 +212,8 @@ class PortprofileExtensionTest(unittest.TestCase): def test_update_portprofileBADRequest(self): + """ Test update Portprofile Bad Request""" + LOG.debug("test_update_portprofileBADRequest - START") req_body = json.dumps(self.test_port_profile) index_response = self.test_app.post( @@ -217,6 +234,8 @@ class PortprofileExtensionTest(unittest.TestCase): def test_update_portprofileDNE(self, portprofile_id='100'): + """ Test update Portprofile does not exist""" + LOG.debug("test_update_portprofileiDNE - START") rename_port_profile = {'portprofile': {'portprofile_name': 'cisco_rename_portprofile', @@ -231,6 +250,8 @@ class PortprofileExtensionTest(unittest.TestCase): def test_delete_portprofile(self): + """ Test delete Portprofile""" + LOG.debug("test_delete_portprofile - START") req_body = json.dumps(self.test_port_profile) index_response = self.test_app.post( @@ -248,6 +269,8 @@ class PortprofileExtensionTest(unittest.TestCase): def test_delete_portprofileDNE(self, portprofile_id='100'): + """ Test delete Portprofile does not exist""" + LOG.debug("test_delete_portprofileDNE - START") delete_path_temp = self.portprofile_path + portprofile_id delete_path = str(delete_path_temp) @@ -257,6 +280,8 @@ class PortprofileExtensionTest(unittest.TestCase): def create_request(self, path, body, content_type, method='GET'): + """ Test create request""" + LOG.debug("test_create_request - START") req = webob.Request.blank(path) req.method = method @@ -268,6 +293,8 @@ class PortprofileExtensionTest(unittest.TestCase): def _create_network(self, name=None): + """ Test create network""" + LOG.debug("Creating network - START") if name: net_name = name @@ -286,6 +313,8 @@ class PortprofileExtensionTest(unittest.TestCase): def _create_port(self, network_id, port_state): + """ Test create port""" + LOG.debug("Creating port for network %s - START", network_id) port_path = "/tenants/tt/networks/%s/ports" % network_id port_req_data = {'port': {'port-state': '%s' % port_state}} @@ -301,6 +330,8 @@ class PortprofileExtensionTest(unittest.TestCase): def test_associate_portprofile(self): + """ Test associate portprofile""" + LOG.debug("test_associate_portprofile - START") net_id = self._create_network() port_id = self._create_port(net_id, "ACTIVE") @@ -336,6 +367,8 @@ class PortprofileExtensionTest(unittest.TestCase): def test_associate_portprofileDNE(self, portprofile_id='100'): + """ Test associate portprofile does not exist""" + LOG.debug("test_associate_portprofileDNE - START") test_port_assign_data = {'portprofile': {'network-id': '001', 'port-id': '1'}} @@ -350,6 +383,8 @@ class PortprofileExtensionTest(unittest.TestCase): def test_disassociate_portprofile(self): + """ Test disassociate portprofile""" + LOG.debug("test_disassociate_portprofile - START") net_id = self._create_network() port_id = self._create_port(net_id, "ACTIVE") @@ -388,21 +423,33 @@ class PortprofileExtensionTest(unittest.TestCase): LOG.debug("test_disassociate_portprofile - END") def tear_down_profile(self, delete_profile_path): + + """ Tear down profile""" + self.test_app.delete(delete_profile_path) def tear_down_associate_profile(self, delete_profile_path, dissociate_profile_path, req_body): + + """ Tear down associate profile""" + self.test_app.post(dissociate_profile_path, req_body, content_type=self.contenttype) self.tear_down_profile(delete_profile_path) def tearDown(self): + + """ Tear down """ + db.clear_db() class NovatenantExtensionTest(unittest.TestCase): def setUp(self): + + """ Set up function""" + parent_resource = dict(member_name="tenant", collection_name="extensions/csco/tenants") member_actions = {'get_host': "PUT", @@ -421,6 +468,9 @@ class NovatenantExtensionTest(unittest.TestCase): 'key2': '2'}}} def test_get_host(self): + + """ Test get host""" + LOG.debug("test_get_host - START") req_body = json.dumps(self.test_instance_data) host_path = self.novatenants_path + "001/get_host" @@ -431,6 +481,9 @@ class NovatenantExtensionTest(unittest.TestCase): LOG.debug("test_get_host - END") def test_get_hostBADRequest(self): + + """ Test get host bad request""" + LOG.debug("test_get_hostBADRequest - START") host_path = self.novatenants_path + "001/get_host" host_response = self.test_app.put( @@ -440,6 +493,9 @@ class NovatenantExtensionTest(unittest.TestCase): LOG.debug("test_get_hostBADRequest - END") def test_instance_port(self): + + """ Test get instance port """ + LOG.debug("test_instance_port - START") req_body = json.dumps(self.test_instance_data) instance_port_path = self.novatenants_path + "001/get_instance_port" @@ -454,6 +510,8 @@ class QosExtensionTest(unittest.TestCase): def setUp(self): + """ Set up function """ + parent_resource = dict(member_name="tenant", collection_name="extensions/csco/tenants") controller = qos.QosController(QuantumManager.get_plugin()) @@ -470,6 +528,8 @@ class QosExtensionTest(unittest.TestCase): def test_create_qos(self): + """ Test create qos """ + LOG.debug("test_create_qos - START") req_body = json.dumps(self.test_qos_data) index_response = self.test_app.post(self.qos_path, @@ -488,6 +548,8 @@ class QosExtensionTest(unittest.TestCase): def test_create_qosBADRequest(self): + """ Test create qos bad request """ + LOG.debug("test_create_qosBADRequest - START") index_response = self.test_app.post(self.qos_path, 'BAD_REQUEST', @@ -497,6 +559,9 @@ class QosExtensionTest(unittest.TestCase): LOG.debug("test_create_qosBADRequest - END") def test_list_qoss(self): + + """ Test list qoss """ + LOG.debug("test_list_qoss - START") req_body1 = json.dumps(self.test_qos_data) create_resp1 = self.test_app.post(self.qos_path, req_body1, @@ -524,6 +589,9 @@ class QosExtensionTest(unittest.TestCase): LOG.debug("test_list_qoss - END") def test_show_qos(self): + + """ Test show qos """ + LOG.debug("test_show_qos - START") req_body = json.dumps(self.test_qos_data) index_response = self.test_app.post(self.qos_path, req_body, @@ -541,6 +609,9 @@ class QosExtensionTest(unittest.TestCase): LOG.debug("test_show_qos - END") def test_show_qosDNE(self, qos_id='100'): + + """ Test show qos does not exist""" + LOG.debug("test_show_qosDNE - START") show_path_temp = self.qos_second_path + qos_id show_qos_path = str(show_path_temp) @@ -550,6 +621,8 @@ class QosExtensionTest(unittest.TestCase): def test_update_qos(self): + """ Test update qos """ + LOG.debug("test_update_qos - START") req_body = json.dumps(self.test_qos_data) index_response = self.test_app.post(self.qos_path, req_body, @@ -567,6 +640,9 @@ class QosExtensionTest(unittest.TestCase): LOG.debug("test_update_qos - END") def test_update_qosDNE(self, qos_id='100'): + + """ Test update qos does not exist """ + LOG.debug("test_update_qosDNE - START") rename_req_body = json.dumps({'qos': {'qos_name': 'cisco_rename_qos', 'qos_desc': {'PPS': 50, 'TTL': 5}}}) @@ -578,6 +654,9 @@ class QosExtensionTest(unittest.TestCase): LOG.debug("test_update_qosDNE - END") def test_update_qosBADRequest(self): + + """ Test update qos bad request """ + LOG.debug("test_update_qosBADRequest - START") req_body = json.dumps(self.test_qos_data) index_response = self.test_app.post(self.qos_path, req_body, @@ -597,6 +676,8 @@ class QosExtensionTest(unittest.TestCase): def test_delete_qos(self): + """ Test delte qos """ + LOG.debug("test_delete_qos - START") req_body = json.dumps({'qos': {'qos_name': 'cisco_test_qos', 'qos_desc': {'PPS': 50, 'TTL': 5}}}) @@ -612,6 +693,9 @@ class QosExtensionTest(unittest.TestCase): LOG.debug("test_delete_qos - END") def test_delete_qosDNE(self, qos_id='100'): + + """ Test delte qos does not exist""" + LOG.debug("test_delete_qosDNE - START") delete_path_temp = self.qos_second_path + qos_id delete_path = str(delete_path_temp) @@ -620,12 +704,18 @@ class QosExtensionTest(unittest.TestCase): LOG.debug("test_delete_qosDNE - END") def tearDownQos(self, delete_profile_path): + + """ Tear Down Qos """ + self.test_app.delete(delete_profile_path) class CredentialExtensionTest(unittest.TestCase): def setUp(self): + + """ Set up function """ + parent_resource = dict(member_name="tenant", collection_name="extensions/csco/tenants") controller = credential.CredentialController( @@ -640,10 +730,12 @@ class CredentialExtensionTest(unittest.TestCase): self.test_credential_data = {'credential': {'credential_name': 'cred8', 'user_name': 'newUser2', - 'password': 'newPasswd1' - }} + 'password': 'newPasswd1'}} def test_list_credentials(self): + + """ Test list credentials """ + #Create Credential before listing LOG.debug("test_list_credentials - START") req_body1 = json.dumps(self.test_credential_data) @@ -653,8 +745,7 @@ class CredentialExtensionTest(unittest.TestCase): req_body2 = json.dumps({'credential': {'credential_name': 'cred9', 'user_name': 'newUser2', - 'password': 'newPasswd2' - }}) + 'password': 'newPasswd2'}}) create_response2 = self.test_app.post( self.credential_path, req_body2, content_type=self.contenttype) @@ -677,6 +768,9 @@ class CredentialExtensionTest(unittest.TestCase): LOG.debug("test_list_credentials - END") def test_create_credential(self): + + """ Test create credential """ + LOG.debug("test_create_credential - START") req_body = json.dumps(self.test_credential_data) index_response = self.test_app.post( @@ -693,6 +787,9 @@ class CredentialExtensionTest(unittest.TestCase): LOG.debug("test_create_credential - END") def test_create_credentialBADRequest(self): + + """ Test create credential bad request """ + LOG.debug("test_create_credentialBADRequest - START") index_response = self.test_app.post( self.credential_path, 'BAD_REQUEST', @@ -701,6 +798,9 @@ class CredentialExtensionTest(unittest.TestCase): LOG.debug("test_create_credentialBADRequest - END") def test_show_credential(self): + + """ Test show credential """ + LOG.debug("test_show_credential - START") req_body = json.dumps(self.test_credential_data) index_response = self.test_app.post( @@ -716,6 +816,9 @@ class CredentialExtensionTest(unittest.TestCase): LOG.debug("test_show_credential - END") def test_show_credentialDNE(self, credential_id='100'): + + """ Test show credential does not exist """ + LOG.debug("test_show_credentialDNE - START") show_path_temp = self.cred_second_path + credential_id show_cred_path = str(show_path_temp) @@ -724,6 +827,9 @@ class CredentialExtensionTest(unittest.TestCase): LOG.debug("test_show_credentialDNE - END") def test_update_credential(self): + + """ Test update credential """ + LOG.debug("test_update_credential - START") req_body = json.dumps(self.test_credential_data) @@ -735,8 +841,7 @@ class CredentialExtensionTest(unittest.TestCase): rename_req_body = json.dumps({'credential': {'credential_name': 'cred3', 'user_name': 'RenamedUser', - 'password': 'Renamedpassword' - }}) + 'password': 'Renamedpassword'}}) rename_path_temp = self.cred_second_path +\ resp_body['credentials']['credential']['id'] rename_path = str(rename_path_temp) @@ -747,6 +852,9 @@ class CredentialExtensionTest(unittest.TestCase): LOG.debug("test_update_credential - END") def test_update_credBADReq(self): + + """ Test update credential bad request """ + LOG.debug("test_update_credBADReq - START") req_body = json.dumps(self.test_credential_data) index_response = self.test_app.post( @@ -763,12 +871,14 @@ class CredentialExtensionTest(unittest.TestCase): LOG.debug("test_update_credBADReq - END") def test_update_credentialDNE(self, credential_id='100'): + + """ Test update credential does not exist""" + LOG.debug("test_update_credentialDNE - START") rename_req_body = json.dumps({'credential': {'credential_name': 'cred3', 'user_name': 'RenamedUser', - 'password': 'Renamedpassword' - }}) + 'password': 'Renamedpassword'}}) rename_path_temp = self.cred_second_path + credential_id rename_path = str(rename_path_temp) rename_response = self.test_app.put(rename_path, rename_req_body, @@ -777,6 +887,9 @@ class CredentialExtensionTest(unittest.TestCase): LOG.debug("test_update_credentialDNE - END") def test_delete_credential(self): + + """ Test delete credential """ + LOG.debug("test_delete_credential - START") req_body = json.dumps(self.test_credential_data) index_response = self.test_app.post( @@ -792,6 +905,9 @@ class CredentialExtensionTest(unittest.TestCase): LOG.debug("test_delete_credential - END") def test_delete_credentialDNE(self, credential_id='100'): + + """ Test delete credential does not exist """ + LOG.debug("test_delete_credentialDNE - START") delete_path_temp = self.cred_second_path + credential_id delete_path = str(delete_path_temp) diff --git a/quantum/plugins/cisco/tests/unit/test_l2networkApi.py b/quantum/plugins/cisco/tests/unit/test_l2networkApi.py index aff7b6c13..c6bafa6fc 100644 --- a/quantum/plugins/cisco/tests/unit/test_l2networkApi.py +++ b/quantum/plugins/cisco/tests/unit/test_l2networkApi.py @@ -19,13 +19,12 @@ import logging import unittest -#import time from quantum.common import exceptions as exc from quantum.plugins.cisco.common import cisco_constants as const from quantum.plugins.cisco.common import cisco_exceptions as cexc from quantum.plugins.cisco import l2network_plugin from quantum.plugins.cisco import l2network_plugin_configuration as conf -#from quantum.plugins.cisco.common import cisco_utils as utils +from quantum.plugins.cisco.common import cisco_utils as utils from quantum.plugins.cisco.db import api as db from quantum.plugins.cisco.db import l2network_db as cdb @@ -72,7 +71,6 @@ class CoreAPITestFunc(unittest.TestCase): tenant_id, new_net_dict[const.NET_ID]) self.assertRaises(exc.NetworkNotFound, db.network_get, new_net_dict[const.NET_ID]) - #self.assertEqual(net, None) self.assertEqual( new_net_dict[const.NET_ID], delete_net_dict[const.NET_ID]) LOG.debug("test_delete_network - END") @@ -303,11 +301,6 @@ class CoreAPITestFunc(unittest.TestCase): port_dict[const.PORT_ID]) self.assertRaises(exc.PortNotFound, db.port_get, new_net_dict[const.NET_ID], port_dict[const.PORT_ID]) - #self.assertEqual(port, None) - # self.assertEqual(delete_port_dict[const.PORT_STATE], port_state) -# self.assertEqual(delete_port_dict[const.NET_ID], new_net_dict[NET_ID]) -# self.assertEqual(delete_port_dict[const.PORT_ID], -# new_net_dict[PORT_ID]) self.tearDownNetwork(tenant_id, new_net_dict[const.NET_ID]) self.assertEqual(delete_port_dict[const.PORT_ID], port_dict[const.PORT_ID]) @@ -470,10 +463,6 @@ class CoreAPITestFunc(unittest.TestCase): port_dict[const.PORT_ID], remote_interface) port = db.port_get(new_net_dict[const.NET_ID], port_dict[const.PORT_ID]) - # self.assertEqual( - # self._l2network_plugin._networks[new_net_dict[const.NET_ID]] - # [const.NET_PORTS][port_dict[const.PORT_ID]] - # [const.ATTACHMENT], remote_interface) self.assertEqual(port[const.INTERFACEID], remote_interface) self.tearDownNetworkPortInterface( tenant_id, new_net_dict[const.NET_ID], @@ -553,9 +542,6 @@ class CoreAPITestFunc(unittest.TestCase): port_dict[const.PORT_ID]) port = db.port_get(new_net_dict[const.NET_ID], port_dict[const.PORT_ID]) - # self.assertEqual(self._l2network_plugin._networks - # [new_net_dict[const.NET_ID]][const.NET_PORTS] - # [port_dict[const.PORT_ID]][const.ATTACHMENT], None) self.assertEqual(port[const.INTERFACEID], None) self.tearDownNetworkPort(tenant_id, new_net_dict[const.NET_ID], port_dict[const.PORT_ID]) @@ -616,12 +602,6 @@ class CoreAPITestFunc(unittest.TestCase): port_profile = cdb.get_portprofile(tenant_id, port_profile_id) self.assertEqual(port_profile[const.PPNAME], profile_name) self.assertEqual(port_profile[const.PPQOS], qos) - # self.assertEqual( - # self._l2network_plugin._portprofiles[port_profile_id]['vlan-id'], - # vlan_id) - #self.assertEqual( - # self._l2network_plugin._portprofiles[port_profile_id] - # ['profile-name'], profile_name) self.tearDownPortProfile(tenant_id, port_profile_id) LOG.debug("test_create_portprofile - tenant id: %s - END", net_tenant_id) @@ -641,10 +621,7 @@ class CoreAPITestFunc(unittest.TestCase): tenant_id, self.profile_name, self.qos) port_profile_id = port_profile_dict['profile_id'] self._l2network_plugin.delete_portprofile(tenant_id, port_profile_id) -# port_profile = cdb.get_portprofile(tenant_id, port_profile_id) self.assertRaises(Exception, cdb.get_portprofile, port_profile_id) -# self.assertEqual(port_profile, {}) -# self.assertEqual(self._l2network_plugin._portprofiles, {}) LOG.debug("test_delete_portprofile - tenant id: %s - END", net_tenant_id) @@ -714,14 +691,6 @@ class CoreAPITestFunc(unittest.TestCase): new_pplist.append(new_pp) self.assertTrue(new_pplist[0] in port_profile_list) self.assertTrue(new_pplist[1] in port_profile_list) -# self.assertEqual(self._l2network_plugin._portprofiles - # [port_profile_id1]['vlan-id'], self.vlan_id) - # self.assertEqual(self._l2network_plugin._portprofiles - # [port_profile_id1]['profile-name'], self.profile_name) - # self.assertEqual(self._l2network_plugin._portprofiles - # [port_profile_id2]['vlan-id'], vlan_id2) - # self.assertEqual(self._l2network_plugin._portprofiles - # [port_profile_id2]['profile-name'], profile_name2) self.tearDownPortProfile(tenant_id, port_profile_id1) self.tearDownPortProfile(tenant_id, port_profile_id2) @@ -816,9 +785,6 @@ class CoreAPITestFunc(unittest.TestCase): port_profile_associate = cdb.get_pp_binding(tenant_id, port_profile_id) self.assertEqual(port_profile_associate[const.PORTID], port_dict[const.PORT_ID]) - #self.assertEqual( - # self._l2network_plugin._portprofiles[port_profile_id] - # [const.PROFILE_ASSOCIATIONS][0], port_id) self.tearDownAssociatePortProfile( tenant_id, new_net_dict[const.NET_ID], port_dict[const.PORT_ID], port_profile_id) @@ -863,8 +829,6 @@ class CoreAPITestFunc(unittest.TestCase): port_dict[const.PORT_ID], port_profile_id) port_profile_associate = cdb.get_pp_binding(tenant_id, port_profile_id) self.assertEqual(port_profile_associate, []) -# self.assertEqual(self._l2network_plugin._portprofiles - # [port_profile_id][const.PROFILE_ASSOCIATIONS], []) self.tearDownPortProfile(tenant_id, port_profile_id) self.tearDownNetworkPort( tenant_id, new_net_dict[const.NET_ID], @@ -883,7 +847,6 @@ class CoreAPITestFunc(unittest.TestCase): tenant_id, net_id, port_id, profile_id) LOG.debug("test_disassociate_portprofileDNE - END") -# def test_disassociate_portprofile_Unassociated def test_get_vlan_name(self, net_tenant_id=None, vlan_id="NewVlan", vlan_prefix=conf.VLAN_NAME_PREFIX): """ @@ -923,22 +886,17 @@ class CoreAPITestFunc(unittest.TestCase): LOG.debug("test_validate_port_state - END") def setUp(self): + """ + Set up function + """ self.tenant_id = "test_tenant" self.network_name = "test_network" self.profile_name = "test_tenant_port_profile" - # self.vlan_id = "test_tenant_vlanid300" self.qos = "test_qos" self.port_state = const.PORT_UP self.net_id = '00005' self.port_id = 'p0005' self.remote_interface = 'new_interface' - #sql_query = "drop database quantum_l2network" - #sql_query_2 = "create database quantum_l2network" - #self._utils = utils.DBUtils() - #self._utils.execute_db_query(sql_query) - #time.sleep(10) - #self._utils.execute_db_query(sql_query_2) - #time.sleep(10) self._l2network_plugin = l2network_plugin.L2Network() """ @@ -950,29 +908,50 @@ class CoreAPITestFunc(unittest.TestCase): db.clear_db() def tearDownNetwork(self, tenant_id, network_dict_id): + """ + Tear down the Network + """ self._l2network_plugin.delete_network(tenant_id, network_dict_id) def tearDownPortOnly(self, tenant_id, network_dict_id, port_id): + """ + Tear doen the port + """ self._l2network_plugin.delete_port(tenant_id, network_dict_id, port_id) def tearDownNetworkPort(self, tenant_id, network_dict_id, port_id): + """ + Tear down Network Port + """ self._l2network_plugin.delete_port(tenant_id, network_dict_id, port_id) self.tearDownNetwork(tenant_id, network_dict_id) def tearDownNetworkPortInterface(self, tenant_id, network_dict_id, port_id): + """ + Tear down Network Port Interface + """ self._l2network_plugin.unplug_interface(tenant_id, network_dict_id, port_id) self.tearDownNetworkPort(tenant_id, network_dict_id, port_id) def tearDownPortProfile(self, tenant_id, port_profile_id): + """ + Tear down Port Profile + """ self._l2network_plugin.delete_portprofile(tenant_id, port_profile_id) def tearDownPortProfileBinding(self, tenant_id, port_profile_id): + """ + Tear down port profile binding + """ self._l2network_plugin.delete_portprofile(tenant_id, port_profile_id) def tearDownAssociatePortProfile(self, tenant_id, net_id, port_id, port_profile_id): + """ + Tear down associate port profile + """ self._l2network_plugin.disassociate_portprofile( tenant_id, net_id, port_id, port_profile_id) self.tearDownPortProfile(tenant_id, port_profile_id) diff --git a/quantum/plugins/cisco/tests/unit/test_nexus_plugin.py b/quantum/plugins/cisco/tests/unit/test_nexus_plugin.py index e9f95f1fc..454f5b703 100644 --- a/quantum/plugins/cisco/tests/unit/test_nexus_plugin.py +++ b/quantum/plugins/cisco/tests/unit/test_nexus_plugin.py @@ -27,6 +27,9 @@ LOG = logging.getLogger('quantum.tests.test_nexus') class TestNexusPlugin(unittest.TestCase): def setUp(self): + """ + Set up function + """ self.tenant_id = "test_tenant_cisco1" self.net_name = "test_network_cisco1" @@ -265,18 +268,3 @@ class TestNexusPlugin(unittest.TestCase): Clean up functions after the tests """ self._cisco_nexus_plugin.delete_network(tenant_id, network_dict_id) - -# def test_create_network(self): -# _test_create_network(self._cisco_nexus_plugin) - -# def test_delete_network(self): -# _test_delete_network(self._cisco_nexus_plugin) - -# def test_rename_network(self): -# _test_rename_network(self._cisco_nexus_plugin) - -# def test_show_network(self): -# _test_get_network_details(self._cisco_nexus_plugin) - -# def test_list_networks(self): -# _test_list_all_networks(self._cisco_nexus_plugin) diff --git a/quantum/plugins/cisco/tests/unit/test_ucs_driver.py b/quantum/plugins/cisco/tests/unit/test_ucs_driver.py index eaf646ff5..9da92e5b0 100644 --- a/quantum/plugins/cisco/tests/unit/test_ucs_driver.py +++ b/quantum/plugins/cisco/tests/unit/test_ucs_driver.py @@ -73,6 +73,7 @@ ASSOCIATE_PROFILE_OUTPUT = "