From 06a94e1ce9cb910cb229937321da85cdf5daed46 Mon Sep 17 00:00:00 2001 From: Tyler Smith Date: Sat, 8 Jan 2011 01:40:40 -0500 Subject: [PATCH] Fixing issues discussed in merge prop. The UCS Inventory clears the DB on teardown. The multiblade tests now check to see if a port exists in the db before deleting it. It checks to make sure the UCSInventory is set in the config. --- .../tests/unit/test_l2network_multi_blade.py | 23 +++++++++++++------ .../cisco/tests/unit/test_ucs_inventory.py | 1 + 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/quantum/plugins/cisco/tests/unit/test_l2network_multi_blade.py b/quantum/plugins/cisco/tests/unit/test_l2network_multi_blade.py index bbbcf1e8456..6e46381db90 100644 --- a/quantum/plugins/cisco/tests/unit/test_l2network_multi_blade.py +++ b/quantum/plugins/cisco/tests/unit/test_l2network_multi_blade.py @@ -55,11 +55,7 @@ def vlan_name(id): class TestMultiBlade(unittest.TestCase): """ - Implements the L2NetworkModelBase - This implementation works with UCS and Nexus plugin for the - following topology: - One or more UCSM (each with one or more chasses connected) - All UCSM connected to a single Nexus Switch + Tests for the multi-blade model for the L2Network plugin """ _plugins = {} _inventory = {} @@ -83,8 +79,9 @@ class TestMultiBlade(unittest.TestCase): # Get UCS inventory to make sure all UCSs are affected by tests for key in conf.PLUGINS[const.PLUGINS].keys(): - self._inventory[key] = utils.import_object( - conf.PLUGINS[const.INVENTORY][key]) + if key in conf.PLUGINS[const.INVENTORY].keys(): + self._inventory[key] = utils.import_object( + conf.PLUGINS[const.INVENTORY][key]) self.ucs_count = self._inventory['ucs_plugin'].\ _inventory.__len__() @@ -92,13 +89,18 @@ class TestMultiBlade(unittest.TestCase): def tearDown(self): """Tear down our tests""" try: + port = db.port_get(self.net_id, self.port_id) self._l2network_multiblade.delete_port([tenant_id, self.net_id, self.port_id]) + except exc.NetworkNotFound: + # We won't always have a port to remove + pass except exc.PortNotFound: # We won't always have a port to remove pass try: + net = db.network_get(self.net_id) self._l2network_multiblade.delete_network([tenant_id, self.net_id]) except exc.NetworkNotFound: # We won't always have a network to remove @@ -245,6 +247,13 @@ class TestMultiBlade(unittest.TestCase): self.port_id]) self.assertEqual(self.port_id, port[0][const.PORTID]) + + # Recreating port so tear down doesn't cause an error + self.port_id = db.port_create(self.net_id, port_state)[const.UUID] + self._l2network_multiblade.create_port([tenant_id, + self.net_id, + port_state, self.port_id]) + LOG.debug("test_delete_port - END") def test_get_all_ports(self): diff --git a/quantum/plugins/cisco/tests/unit/test_ucs_inventory.py b/quantum/plugins/cisco/tests/unit/test_ucs_inventory.py index 7276f4e0ddb..a3e30034f97 100644 --- a/quantum/plugins/cisco/tests/unit/test_ucs_inventory.py +++ b/quantum/plugins/cisco/tests/unit/test_ucs_inventory.py @@ -104,6 +104,7 @@ class TestUCSInventory(unittest.TestCase): self._l2network.delete_port(tenant, net[const.NET_ID], port[const.PORT_ID]) self._l2network.delete_network(tenant, net[const.NET_ID]) + db.clear_db() LOG.debug("test_%s - END", cmd)