Fixes to the tests which were breaking, including fixes to the test cases.

changes/68/468/1
Sumit Naiksatam 12 years ago
parent 0b69d5e656
commit 4b16715fa6

@ -20,7 +20,7 @@
PLUGINS = 'PLUGINS'
PORT_STATE = 'port-state'
PORT_UP = "UP"
PORT_UP = "ACTIVE"
PORT_DOWN = "DOWN"
UUID = 'uuid'

@ -142,7 +142,7 @@ class L2Network(QuantumPluginBase):
network = db.network_rename(tenant_id, net_id, new_name)
net_dict = self._make_net_dict(network[const.UUID],
network[const.NETWORKNAME],
None)
[])
return net_dict
def get_all_ports(self, tenant_id, net_id):
@ -256,13 +256,13 @@ class L2Network(QuantumPluginBase):
pp[const.UUID],
pp[const.PPNAME],
pp[const.PPQOS])
new_pplist.append(pp)
new_pplist.append(new_pp)
return new_pplist
def get_portprofile_details(self, tenant_id, profile_id):
#return self._get_portprofile(tenant_id, profile_id)
pp = cdb.get_portprofile(profile_id)
pp = cdb.get_portprofile(tenant_id, profile_id)
new_pp = self._make_portprofile_dict(tenant_id,
pp[const.UUID],
pp[const.PPNAME],
@ -270,7 +270,8 @@ class L2Network(QuantumPluginBase):
return new_pp
def create_portprofile(self, tenant_id, profile_name, qos):
pp = cdb.add_portprofile(profile_name, const.NO_VLAN_ID, qos)
pp = cdb.add_portprofile(tenant_id, profile_name,
const.NO_VLAN_ID, qos)
new_pp = self._make_portprofile_dict(tenant_id,
pp[const.UUID],
pp[const.PPNAME],
@ -279,25 +280,25 @@ class L2Network(QuantumPluginBase):
def delete_portprofile(self, tenant_id, profile_id):
try:
pp = cdb.get_portprofile(profile_id)
pp = cdb.get_portprofile(tenant_id, profile_id)
except Exception, e:
raise cexc.PortProfileNotFound(tenant_id=tenant_id,
portprofile_id=profile_id)
portprofile_id=profile_id)
plist = cdb.get_pp_binding(profile_id)
plist = cdb.get_pp_binding(tenant_id, profile_id)
if plist:
raise cexc.PortProfileInvalidDelete(tenant_id=tenant_id,
profile_id=profile_id)
profile_id=profile_id)
else:
cdb.remove_portprofile(profile_id)
cdb.remove_portprofile(tenant_id, profile_id)
def rename_portprofile(self, tenant_id, profile_id, new_name):
try:
pp = cdb.get_portprofile(profile_id)
pp = cdb.get_portprofile(tenant_id, profile_id)
except Exception, e:
raise cexc.PortProfileNotFound(tenant_id=tenant_id,
profile_id=profile_id)
pp = cdb.update_portprofile(profile_id, new_name)
portprofile_id=profile_id)
pp = cdb.update_portprofile(tenant_id, profile_id, new_name)
new_pp = self._make_portprofile_dict(tenant_id,
pp[const.UUID],
pp[const.PPNAME],
@ -307,7 +308,7 @@ class L2Network(QuantumPluginBase):
def associate_portprofile(self, tenant_id, net_id,
port_id, portprofile_id):
try:
pp = cdb.get_portprofile(portprofile_id)
pp = cdb.get_portprofile(tenant_id, portprofile_id)
except Exception, e:
raise cexc.PortProfileNotFound(tenant_id=tenant_id,
portprofile_id=portprofile_id)
@ -317,16 +318,17 @@ class L2Network(QuantumPluginBase):
def disassociate_portprofile(self, tenant_id, net_id,
port_id, portprofile_id):
try:
pp = cdb.get_portprofile(portprofile_id)
pp = cdb.get_portprofile(tenant_id, portprofile_id)
except Exception, e:
raise cexc.PortProfileNotFound(tenant_id=tenant_id,
portprofile_id=portprofile_id)
cdb.remove_pp_binding(port_id, portprofile_id)
cdb.remove_pp_binding(tenant_id, port_id, portprofile_id)
def create_defaultPProfile(self, tenant_id, network_id, profile_name,
qos):
pp = cdb.add_portprofile(profile_name, const.NO_VLAN_ID, qos)
pp = cdb.add_portprofile(tenant_id, profile_name,
const.NO_VLAN_ID, qos)
new_pp = self._make_portprofile_dict(tenant_id,
pp[const.UUID],
pp[const.PPNAME],
@ -381,7 +383,8 @@ class L2Network(QuantumPluginBase):
def _make_portprofile_dict(self, tenant_id, profile_id, profile_name,
qos):
profile_associations = self._make_portprofile_assc_list(profile_id)
profile_associations = self._make_portprofile_assc_list(tenant_id,
profile_id)
res = {const.PROFILE_ID: str(profile_id),
const.PROFILE_NAME: profile_name,
const.PROFILE_ASSOCIATIONS: profile_associations,
@ -389,8 +392,8 @@ class L2Network(QuantumPluginBase):
const.PROFILE_QOS: qos}
return res
def _make_portprofile_assc_list(self, profile_id):
plist = cdb.get_pp_binding(profile_id)
def _make_portprofile_assc_list(self, tenant_id, profile_id):
plist = cdb.get_pp_binding(tenant_id, profile_id)
assc_list = []
for port in plist:
assc_list.append(port[const.PORTID])

@ -72,7 +72,7 @@ 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(net, None)
self.assertEqual(
new_net_dict[const.NET_ID], delete_net_dict[const.NET_ID])
LOG.debug("test_delete_network - END")
@ -390,7 +390,7 @@ class CoreAPITestFunc(unittest.TestCase):
LOG.debug("test_update_port_networkDNE - START")
self.assertRaises(exc.NetworkNotFound,
self._l2network_plugin.update_port, tenant_id,
net_id, port_id, 'ACTIVE')
net_id, port_id, const.PORT_UP)
LOG.debug("test_update_port_networkDNE - END")
def test_update_portDNE(self, tenant_id='test_tenant', port_id='p0005'):
@ -403,7 +403,7 @@ class CoreAPITestFunc(unittest.TestCase):
tenant_id, self.network_name)
self.assertRaises(
exc.PortNotFound, self._l2network_plugin.update_port, tenant_id,
new_net_dict[const.NET_ID], port_id, self.port_state)
new_net_dict[const.NET_ID], port_id, const.PORT_UP)
self.tearDownNetwork(tenant_id, new_net_dict[const.NET_ID])
LOG.debug("test_update_portDNE - END")
@ -613,7 +613,7 @@ class CoreAPITestFunc(unittest.TestCase):
port_profile_dict = self._l2network_plugin.create_portprofile(
tenant_id, profile_name, qos)
port_profile_id = port_profile_dict['profile-id']
port_profile = cdb.get_portprofile(port_profile_id)
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(
@ -641,7 +641,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(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, {})
@ -670,13 +670,18 @@ class CoreAPITestFunc(unittest.TestCase):
port_profile_dict = self._l2network_plugin.create_portprofile(
tenant_id, self.profile_name, self.qos)
port_profile_id = port_profile_dict['profile-id']
new_net_dict = self._l2network_plugin.create_network(
tenant_id, 'test_network')
port_dict = self._l2network_plugin.create_port(
tenant_id, new_net_dict[const.NET_ID], 'const.PORT_UP')
self._l2network_plugin.associate_portprofile(
tenant_id, self.net_id, self.port_id, port_profile_id)
tenant_id, new_net_dict[const.NET_ID], port_dict[const.PORT_ID], port_profile_id)
self.assertRaises(cexc.PortProfileInvalidDelete,
self._l2network_plugin.delete_portprofile,
tenant_id, port_profile_id)
self.tearDownAssociatePortProfile(tenant_id, self.net_id,
self.port_id, port_profile_id)
self.tearDownAssociatePortProfile(tenant_id, new_net_dict[const.NET_ID],
port_dict[const.PORT_ID], port_profile_id)
self.tearDownNetworkPort(tenant_id, new_net_dict[const.NET_ID], port_dict[const.PORT_ID])
LOG.debug("test_delete_portprofileAssociated - END")
def test_list_portprofile(self, tenant_id='test_tenant'):
@ -714,7 +719,10 @@ class CoreAPITestFunc(unittest.TestCase):
# [port_profile_id2]['vlan-id'], vlan_id2)
# self.assertEqual(self._l2network_plugin._portprofiles
# [port_profile_id2]['profile-name'], profile_name2)
LOG.debug("test_create_portprofile - tenant id: %s - END", tenant_id)
self.tearDownPortProfile(tenant_id, port_profile_id1)
self.tearDownPortProfile(tenant_id, port_profile_id2)
LOG.debug("test_list_portprofile - tenant id: %s - END", tenant_id)
def test_show_portprofile(self, net_tenant_id=None):
"""
@ -731,7 +739,7 @@ class CoreAPITestFunc(unittest.TestCase):
port_profile_id = port_profile_dict['profile-id']
result_port_profile = self._l2network_plugin.get_portprofile_details(
tenant_id, port_profile_id)
port_profile = cdb.get_portprofile(port_profile_id)
port_profile = cdb.get_portprofile(tenant_id, port_profile_id)
self.assertEqual(port_profile[const.PPQOS], self.qos)
self.assertEqual(port_profile[const.PPNAME], self.profile_name)
self.assertEqual(result_port_profile[const.PROFILE_QOS],
@ -765,7 +773,7 @@ class CoreAPITestFunc(unittest.TestCase):
port_profile_id = port_profile_dict['profile-id']
result_port_profile_dict = self._l2network_plugin.rename_portprofile(
tenant_id, port_profile_id, new_profile_name)
port_profile = cdb.get_portprofile(port_profile_id)
port_profile = cdb.get_portprofile(tenant_id, port_profile_id)
self.assertEqual(port_profile[const.PPNAME], new_profile_name)
self.assertEqual(result_port_profile_dict[const.PROFILE_NAME],
new_profile_name)
@ -803,7 +811,7 @@ class CoreAPITestFunc(unittest.TestCase):
self._l2network_plugin.associate_portprofile(
tenant_id, net_id, port_dict[const.PORT_ID],
port_profile_id)
port_profile_associate = cdb.get_pp_binding(port_profile_id)
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(
@ -851,7 +859,7 @@ class CoreAPITestFunc(unittest.TestCase):
self._l2network_plugin.disassociate_portprofile(
tenant_id, new_net_dict[const.NET_ID],
port_dict[const.PORT_ID], port_profile_id)
port_profile_associate = cdb.get_pp_binding(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], [])
@ -925,15 +933,19 @@ class CoreAPITestFunc(unittest.TestCase):
#sql_query = "drop database quantum_l2network"
#sql_query_2 = "create database quantum_l2network"
#self._utils = utils.DBUtils()
#self._utils.execute_db_query(sql_query)
#self._utils.execute_db_query(sql_query)
#time.sleep(10)
#self._utils.execute_db_query(sql_query_2)
#self._utils.execute_db_query(sql_query_2)
#time.sleep(10)
self._l2network_plugin = l2network_plugin.L2Network()
"""
Clean up functions after the tests
"""
def tearDown(self):
"""Clear the test environment"""
# Remove database contents
db.clear_db()
def tearDownNetwork(self, tenant_id, network_dict_id):
self._l2network_plugin.delete_network(tenant_id, network_dict_id)
@ -954,6 +966,9 @@ class CoreAPITestFunc(unittest.TestCase):
def tearDownPortProfile(self, tenant_id, port_profile_id):
self._l2network_plugin.delete_portprofile(tenant_id, port_profile_id)
def tearDownPortProfileBinding(self, tenant_id, port_profile_id):
self._l2network_plugin.delete_portprofile(tenant_id, port_profile_id)
def tearDownAssociatePortProfile(self, tenant_id, net_id, port_id,
port_profile_id):
self._l2network_plugin.disassociate_portprofile(
@ -973,7 +988,7 @@ class CoreAPITestFunc(unittest.TestCase):
def _make_portprofile_dict(self, tenant_id, profile_id, profile_name,
qos):
profile_associations = self._make_portprofile_assc_list(profile_id)
profile_associations = self._make_portprofile_assc_list(tenant_id, profile_id)
res = {const.PROFILE_ID: str(profile_id),
const.PROFILE_NAME: profile_name,
const.PROFILE_ASSOCIATIONS: profile_associations,
@ -981,8 +996,8 @@ class CoreAPITestFunc(unittest.TestCase):
const.PROFILE_QOS: qos}
return res
def _make_portprofile_assc_list(self, profile_id):
plist = cdb.get_pp_binding(profile_id)
def _make_portprofile_assc_list(self, tenant_id, profile_id):
plist = cdb.get_pp_binding(tenant_id, profile_id)
assc_list = []
for port in plist:
assc_list.append(port[const.PORTID])

@ -253,10 +253,9 @@ class UCSVICPlugin(L2DevicePluginBase):
network = self._get_network(tenant_id, network_id)
for port in network[const.NET_PORTS].values():
if port[const.ATTACHMENT] == remote_interface_id:
raise exc.AlreadyAttached(net_id=network_id,
port_id=port_id,
att_id=port[const.ATTACHMENT],
att_port_id=port[const.PORT_ID])
raise exc.PortInUse(net_id=network_id,
port_id=port_id,
att_id=port[const.ATTACHMENT])
def _get_network(self, tenant_id, network_id):
network = self._networks.get(network_id)

Loading…
Cancel
Save