Review Changes

This commit is contained in:
Shweta P 2011-08-24 00:02:10 -07:00
parent 36c4a0462c
commit 4e1d511d76
7 changed files with 261 additions and 86 deletions

View File

@ -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.<name_of_the file>
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

View File

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

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -73,6 +73,7 @@ ASSOCIATE_PROFILE_OUTPUT = "<configConfMos cookie=\"cookie_placeholder\" "\
class TestUCSDriver(unittest.TestCase):
def setUp(self):
""" Set up function"""
self.ucsm_driver = cisco_ucs_network_driver.CiscoUCSMDriver()
self.vlan_name = 'New Vlan'
self.vlan_id = '200'
@ -136,8 +137,6 @@ class TestUCSDriver(unittest.TestCase):
"""
LOG.debug("test_create_profile_post_data - START")
#profile_details = self.ucsm_driver._create_profile_post_data(
# self.profile_name, self.vlan_name)
self.ucsm_driver._create_profile_post_data(
self.profile_name, self.vlan_name)
profile_delete_details = self.ucsm_driver._delete_profile_post_data(

View File

@ -29,6 +29,9 @@ LOG.getLogger("cisco_plugin")
class UCSVICTestPlugin(unittest.TestCase):
def setUp(self):
"""
Set up function.
"""
self.tenant_id = "test_tenant_cisco12"
self.net_name = "test_network_cisco12"
@ -141,6 +144,9 @@ class UCSVICTestPlugin(unittest.TestCase):
self.tearDownNetwork(self.tenant_id, self.net_id)
def test_rename_network(self):
"""
Tests rename network.
"""
self._test_rename_network("new_test_network1")
def _test_create_port(self, port_state):
@ -166,6 +172,9 @@ class UCSVICTestPlugin(unittest.TestCase):
self.tearDownNetworkPort(self.tenant_id, self.net_id, self.port_id)
def test_create_port(self):
"""
Tests create port.
"""
self._test_create_port(const.PORT_UP)
def _test_delete_port(self, port_state):
@ -188,6 +197,9 @@ class UCSVICTestPlugin(unittest.TestCase):
self.tearDownNetwork(self.tenant_id, self.net_id)
def test_delete_port(self):
"""
Tests delete port.
"""
self._test_delete_port(const.PORT_UP)
def _test_update_port(self, port_state):
@ -207,9 +219,15 @@ class UCSVICTestPlugin(unittest.TestCase):
self.tearDownNetworkPort(self.tenant_id, self.net_id, self.port_id)
def test_update_port_state_up(self):
"""
Tests update port state up
"""
self._test_update_port(const.PORT_UP)
def test_update_port_state_down(self):
"""
Tests update port state down
"""
self._test_update_port(const.PORT_DOWN)
def _test_get_port_details_state_up(self, port_state):
@ -266,12 +284,21 @@ class UCSVICTestPlugin(unittest.TestCase):
self.tearDownNetworkPort(self.tenant_id, self.net_id, self.port_id)
def test_get_port_details_state_up(self):
"""
Tests get port details state up
"""
self._test_get_port_details_state_up(const.PORT_UP)
def test_show_port_state_down(self):
"""
Tests show port state down
"""
self._test_show_port_state_down(const.PORT_DOWN)
def test_create_port_profile(self):
"""
Tests create port profile
"""
LOG.debug("UCSVICTestPlugin:test_create_port_profile() called\n")
new_port_profile = self._cisco_ucs_plugin._create_port_profile(
self.tenant_id, self.net_id, self.port_id,
@ -284,6 +311,9 @@ class UCSVICTestPlugin(unittest.TestCase):
self._cisco_ucs_plugin._delete_port_profile(self.port_id, profile_name)
def test_delete_port_profile(self):
"""
Tests delete port profile
"""
LOG.debug("UCSVICTestPlugin:test_delete_port_profile() called\n")
self._cisco_ucs_plugin._create_port_profile(
self.tenant_id, self.net_id, self.port_id, self.vlan_name,
@ -313,7 +343,6 @@ class UCSVICTestPlugin(unittest.TestCase):
self.tenant_id, self.net_id, self.port_id)
self.assertEqual(port[const.ATTACHMENT], remote_interface_id)
port_profile = port[const.PORT_PROFILE]
#profile_name = port_profile[const.PROFILE_NAME]
new_vlan_name = self._cisco_ucs_plugin._get_vlan_name_for_network(
self.tenant_id, self.net_id)
new_vlan_id = self._cisco_ucs_plugin._get_vlan_id_for_network(
@ -323,7 +352,10 @@ class UCSVICTestPlugin(unittest.TestCase):
self.tearDownNetworkPortInterface(self.tenant_id, self.net_id,
self.port_id)
def test_plug_interface(self):
def test_plug_interface(self):
"""
Tests test plug interface
"""
self._test_plug_interface("4")
def _test_unplug_interface(self, remote_interface_id):
@ -346,17 +378,22 @@ class UCSVICTestPlugin(unittest.TestCase):
self.tenant_id, self.net_id, self.port_id)
self.assertEqual(port[const.ATTACHMENT], None)
port_profile = port[const.PORT_PROFILE]
#profile_name = port_profile[const.PROFILE_NAME]
self.assertEqual(port_profile[const.PROFILE_VLAN_NAME],
conf.DEFAULT_VLAN_NAME)
self.assertEqual(port_profile[const.PROFILE_VLAN_ID],
conf.DEFAULT_VLAN_ID)
self.tearDownNetworkPort(self.tenant_id, self.net_id, self.port_id)
def test_unplug_interface(self):
def test_unplug_interface(self):
"""
Tests unplug interface
"""
self._test_unplug_interface("4")
def test_get_vlan_name_for_network(self):
"""
Tests get vlan name for network
"""
LOG.debug("UCSVICTestPlugin:test_get_vlan_name_for_network() called\n")
net = self._cisco_ucs_plugin.create_network(
self.tenant_id, self.net_name, self.net_id,
@ -365,6 +402,9 @@ class UCSVICTestPlugin(unittest.TestCase):
self.tearDownNetwork(self.tenant_id, self.net_id)
def test_get_vlan_id_for_network(self):
"""
Tests get vlan id for network
"""
LOG.debug("UCSVICTestPlugin:test_get_vlan_id_for_network() called\n")
net = self._cisco_ucs_plugin.create_network(
self.tenant_id, self.net_name, self.net_id, self.vlan_name,
@ -373,6 +413,9 @@ class UCSVICTestPlugin(unittest.TestCase):
self.tearDownNetwork(self.tenant_id, self.net_id)
def test_get_network(self):
"""
Tests get network
"""
LOG.debug("UCSVICTestPlugin:test_get_network() called\n")
net = self._cisco_ucs_plugin.create_network(
self.tenant_id, self.net_name, self.net_id, self.vlan_name,
@ -381,6 +424,9 @@ class UCSVICTestPlugin(unittest.TestCase):
self.tearDownNetwork(self.tenant_id, self.net_id)
def test_get_port(self):
"""
Tests get port
"""
LOG.debug("UCSVICTestPlugin:test_get_port() called\n")
self._cisco_ucs_plugin.create_network(self.tenant_id, self.net_name,
self.net_id, self.vlan_name,
@ -392,19 +438,31 @@ class UCSVICTestPlugin(unittest.TestCase):
self.tearDownNetworkPort(self.tenant_id, self.net_id, self.port_id)
def test_get_network_NetworkNotFound(self):
"""
Tests get network not found
"""
self.assertRaises(exc.NetworkNotFound,
self._cisco_ucs_plugin._get_network,
self.tenant_id, self.net_id)
def test_delete_network_NetworkNotFound(self):
"""
Tests delete network not found
"""
self.assertRaises(exc.NetworkNotFound,
self._cisco_ucs_plugin.delete_network,
self.tenant_id, self.net_id)
def test_delete_port_PortInUse(self):
"""
Tests delete port in use
"""
self._test_delete_port_PortInUse("4")
def _test_delete_port_PortInUse(self, remote_interface_id):
"""
Tests delete port in use
"""
self._cisco_ucs_plugin.create_network(self.tenant_id, self.net_name,
self.net_id, self.vlan_name,
self.vlan_id)
@ -419,6 +477,9 @@ class UCSVICTestPlugin(unittest.TestCase):
self.port_id)
def test_delete_port_PortNotFound(self):
"""
Tests delete port not found
"""
self._cisco_ucs_plugin.create_network(self.tenant_id, self.net_name,
self.net_id, self.vlan_name,
self.vlan_id)
@ -427,10 +488,16 @@ class UCSVICTestPlugin(unittest.TestCase):
self.tearDownNetwork(self.tenant_id, self.net_id)
def test_plug_interface_PortInUse(self):
"""
Tests plug interface port in use
"""
self._test_plug_interface_PortInUse("6", "5")
def _test_plug_interface_PortInUse(self, remote_interface_id1,
remote_interface_id2):
"""
Tests plug interface port in use
"""
LOG.debug("UCSVICTestPlugin:_test_plug_interface_PortInUse() called\n")
self._cisco_ucs_plugin.create_network(self.tenant_id, self.net_name,
self.net_id, self.vlan_name,
@ -447,10 +514,16 @@ class UCSVICTestPlugin(unittest.TestCase):
self.port_id)
def test_attachment_exists(self):
"""
Tests attachment exists
"""
LOG.debug("UCSVICTestPlugin:testValidateAttachmentAlreadyAttached")
self._test_attachment_exists("4")
def _test_attachment_exists(self, remote_interface_id):
"""
Tests attachment exists
"""
LOG.debug("UCSVICTestPlugin:_test_validate_attachmentAlreadyAttached")
self._cisco_ucs_plugin.create_network(self.tenant_id, self.net_name,
self.net_id, self.vlan_name,
@ -467,14 +540,23 @@ class UCSVICTestPlugin(unittest.TestCase):
self.port_id)
def tearDownNetwork(self, tenant_id, net_id):
"""
Tear down network
"""
self._cisco_ucs_plugin.delete_network(tenant_id, net_id)
def tearDownNetworkPort(self, tenant_id, net_id, port_id):
"""
Tear down network port
"""
self._cisco_ucs_plugin.delete_port(tenant_id, net_id,
port_id)
self.tearDownNetwork(tenant_id, net_id)
def tearDownNetworkPortInterface(self, tenant_id, net_id, port_id):
"""
Tear down network port interface
"""
self._cisco_ucs_plugin.unplug_interface(tenant_id, net_id,
port_id)
self.tearDownNetworkPort(tenant_id, net_id, port_id)