From 438d4a83b0967f97bef2fc4c86f956e5fa6ca685 Mon Sep 17 00:00:00 2001 From: Ihar Hrachyshka Date: Thu, 29 Sep 2016 20:11:07 +0000 Subject: [PATCH] TestSanityCheck: drop test tables during cleanup The tests were creating tables in the memory but were not cleaning them up, making them clash on attempt to create floatingips table. Change-Id: If28ef4ce76cd36e7240d106b75e43d16f43e2c16 Closes-Bug: #1629347 --- neutron/tests/functional/db/test_migrations.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/neutron/tests/functional/db/test_migrations.py b/neutron/tests/functional/db/test_migrations.py index 07b3c8a8dad..5414f44559f 100644 --- a/neutron/tests/functional/db/test_migrations.py +++ b/neutron/tests/functional/db/test_migrations.py @@ -356,6 +356,10 @@ class TestSanityCheck(testlib_api.SqlTestCaseLight): self.alembic_config = migration.get_neutron_config() self.alembic_config.neutron_config = cfg.CONF + def _drop_table(self, table): + with self.engine.begin() as conn: + table.drop(conn) + def test_check_sanity_1df244e556f5(self): ha_router_agent_port_bindings = sqlalchemy.Table( 'ha_router_agent_port_bindings', sqlalchemy.MetaData(), @@ -365,6 +369,7 @@ class TestSanityCheck(testlib_api.SqlTestCaseLight): with self.engine.connect() as conn: ha_router_agent_port_bindings.create(conn) + self.addCleanup(self._drop_table, ha_router_agent_port_bindings) conn.execute(ha_router_agent_port_bindings.insert(), [ {'port_id': '1234', 'router_id': '12345', 'l3_agent_id': '123'}, @@ -386,6 +391,7 @@ class TestSanityCheck(testlib_api.SqlTestCaseLight): with self.engine.connect() as conn: routerports.create(conn) + self.addCleanup(self._drop_table, routerports) conn.execute(routerports.insert(), [ {'router_id': '1234', 'port_id': '12345', 'port_type': '123'}, @@ -407,6 +413,7 @@ class TestSanityCheck(testlib_api.SqlTestCaseLight): with self.engine.connect() as conn: floatingips.create(conn) + self.addCleanup(self._drop_table, floatingips) conn.execute(floatingips.insert(), [ {'floating_network_id': '12345', 'fixed_port_id': '1234567', @@ -430,6 +437,7 @@ class TestSanityCheck(testlib_api.SqlTestCaseLight): with self.engine.connect() as conn: floatingips.create(conn) + self.addCleanup(self._drop_table, floatingips) conn.execute(floatingips.insert(), [ {'floating_network_id': '12345', 'fixed_port_id': '1234567',