diff --git a/neutron/tests/fullstack/base.py b/neutron/tests/fullstack/base.py index 71e634f10b8..a8902181fe6 100644 --- a/neutron/tests/fullstack/base.py +++ b/neutron/tests/fullstack/base.py @@ -48,6 +48,11 @@ class BaseFullStackTestCase(testlib_api.MySQLTestCaseMixin, BUILD_WITH_MIGRATIONS = True + # NOTE(slaweq): In fullstack tests there need to be new database created + # for every test, and one db shouldn't be really shared between tests + # running by the same worker + CLEAN_DB_AFTER_TEST = True + def setUp(self, environment): super(BaseFullStackTestCase, self).setUp() diff --git a/neutron/tests/fullstack/test_securitygroup.py b/neutron/tests/fullstack/test_securitygroup.py index 687cd7ef56d..4d2bb22f590 100644 --- a/neutron/tests/fullstack/test_securitygroup.py +++ b/neutron/tests/fullstack/test_securitygroup.py @@ -49,12 +49,6 @@ class OVSVersionChecker(object): class BaseSecurityGroupsSameNetworkTest(base.BaseFullStackTestCase): - # NOTE(slaweq): Those SG tests are run serially by same worker thus we need - # to run db migration script before each test because in some cases cleanup - # after one test may clean data from the db and next test run by same - # worker will have empty tables - FORCE_DB_MIGRATION = True - def setUp(self): debug_iptables = self.firewall_driver.startswith("iptables") host_descriptions = [ diff --git a/neutron/tests/unit/testlib_api.py b/neutron/tests/unit/testlib_api.py index 0fd78a1a03b..38cc2ad69bc 100644 --- a/neutron/tests/unit/testlib_api.py +++ b/neutron/tests/unit/testlib_api.py @@ -122,10 +122,7 @@ class OpportunisticSqlFixture(lib_fixtures.SqlFixture): def _init_resources(self): testresources.setUpResources( self.test, self.test.resources, testresources._get_result()) - self.addCleanup( - testresources.tearDownResources, - self.test, self.test.resources, testresources._get_result() - ) + self.addCleanup(self._cleanup_resources) # unfortunately, fixtures won't let us call a skip() from # here. So the test has to check this also. @@ -133,6 +130,14 @@ class OpportunisticSqlFixture(lib_fixtures.SqlFixture): if hasattr(self.test, 'db'): self.engine = self.test.engine = self.test.db.engine + def _cleanup_resources(self): + testresources.tearDownResources( + self.test, self.test.resources, testresources._get_result()) + + if self.test.CLEAN_DB_AFTER_TEST: + self.test._database_resources.pop(self.test.DRIVER) + self.test._schema_resources.pop((self.test.DRIVER, None)) + @classmethod def resources_collection(cls, test): # reimplement current oslo.db code. @@ -156,7 +161,7 @@ class OpportunisticSqlFixture(lib_fixtures.SqlFixture): key = (driver, None) if test.BUILD_SCHEMA: - if test.FORCE_DB_MIGRATION or key not in test._schema_resources: + if key not in test._schema_resources: test._schema_resources[key] = provision.SchemaResource( database_resource, cls._generate_schema_w_migrations @@ -209,7 +214,7 @@ class OpportunisticDBTestMixin(object): FIXTURE = OpportunisticSqlFixture BUILD_WITH_MIGRATIONS = False - FORCE_DB_MIGRATION = False + CLEAN_DB_AFTER_TEST = False def _setup_database_fixtures(self): self.useFixture(self.FIXTURE(self)) diff --git a/zuul.d/base.yaml b/zuul.d/base.yaml index f85049cae85..7ac0ee010cd 100644 --- a/zuul.d/base.yaml +++ b/zuul.d/base.yaml @@ -59,7 +59,7 @@ - job: name: neutron-fullstack parent: neutron-functional - timeout: 9000 + timeout: 10800 vars: tox_envlist: dsvm-fullstack-gate Q_BUILD_OVS_FROM_GIT: False