Merge "Cleanup some redundant USES_DB_SELF usage"

This commit is contained in:
Jenkins 2016-10-18 02:34:45 +00:00 committed by Gerrit Code Review
commit 819b3b415e
2 changed files with 10 additions and 14 deletions
nova
test.py
tests/functional/db

@ -169,7 +169,14 @@ class TestCase(testtools.TestCase):
Due to the slowness of DB access, please consider deriving from Due to the slowness of DB access, please consider deriving from
`NoDBTestCase` first. `NoDBTestCase` first.
""" """
# USES_DB is set to False for tests that inherit from NoDBTestCase.
USES_DB = True USES_DB = True
# USES_DB_SELF is set to True in tests that specifically want to use the
# database but need to configure it themselves, for example to setup the
# API DB but not the cell DB. In those cases the test will override
# USES_DB_SELF = True but inherit from the NoDBTestCase class so it does
# not get the default fixture setup when using a database (which is the
# API and cell DBs, and adding the default flavors).
USES_DB_SELF = False USES_DB_SELF = False
REQUIRES_LOCKING = False REQUIRES_LOCKING = False

@ -21,7 +21,6 @@ from nova.db.sqlalchemy import api as db_api
from nova.db.sqlalchemy import api_models from nova.db.sqlalchemy import api_models
from nova import exception from nova import exception
from nova import test from nova import test
from nova.tests import fixtures
from nova.tests.unit import matchers from nova.tests.unit import matchers
from nova.tests.unit.objects.test_objects import compare_obj as base_compare from nova.tests.unit.objects.test_objects import compare_obj as base_compare
from nova.tests import uuidsentinel from nova.tests import uuidsentinel
@ -110,14 +109,10 @@ def _aggregate_metadata_get_all(context, aggregate_id):
return metadata return metadata
class AggregateObjectDbTestCase(test.NoDBTestCase): class AggregateObjectDbTestCase(test.TestCase):
USES_DB_SELF = True
def setUp(self): def setUp(self):
super(AggregateObjectDbTestCase, self).setUp() super(AggregateObjectDbTestCase, self).setUp()
self.useFixture(fixtures.Database())
self.useFixture(fixtures.Database(database='api'))
self.context = context.RequestContext('fake-user', 'fake-project') self.context = context.RequestContext('fake-user', 'fake-project')
def test_in_api(self): def test_in_api(self):
@ -495,15 +490,12 @@ def compare_obj(test, result, source):
comparators={'updated_at': updated_at_comparator}) comparators={'updated_at': updated_at_comparator})
class AggregateObjectCellTestCase(test.NoDBTestCase): class AggregateObjectCellTestCase(test.TestCase):
"""Tests for the case where all aggregate data is in Cell DB""" """Tests for the case where all aggregate data is in Cell DB"""
USES_DB_SELF = True
def setUp(self): def setUp(self):
super(AggregateObjectCellTestCase, self).setUp() super(AggregateObjectCellTestCase, self).setUp()
self.context = context.RequestContext('fake-user', 'fake-project') self.context = context.RequestContext('fake-user', 'fake-project')
self.useFixture(fixtures.Database())
self.useFixture(fixtures.Database(database='api'))
self._seed_data() self._seed_data()
def _seed_data(self): def _seed_data(self):
@ -610,13 +602,10 @@ class AggregateObjectMigrationTestCase(AggregateObjectCellTestCase):
self.assertEqual(new_agg.name, result.name) self.assertEqual(new_agg.name, result.name)
class AggregateMigrationTestCase(test.NoDBTestCase): class AggregateMigrationTestCase(test.TestCase):
USES_DB_SELF = True
def setUp(self): def setUp(self):
super(AggregateMigrationTestCase, self).setUp() super(AggregateMigrationTestCase, self).setUp()
self.useFixture(fixtures.Database())
self.useFixture(fixtures.Database(database='api'))
self.context = context.get_admin_context() self.context = context.get_admin_context()
def test_migration(self): def test_migration(self):