Use placement context in placement functional tests
A few placement functional tests were importing and using nova.context for a RequestContext. Placement has its own in nova.api.openstack.placement.context so use that instead. In the process, stop using an 'admin' context. It is not necessary in placement as we do not do any policy checking at the database level. Change-Id: I1f6e6db6aca7dd160d3e94bb0b6ebf9b4f8dfd7d
This commit is contained in:
parent
58aed34f52
commit
13bbe6e891
|
@ -14,13 +14,13 @@
|
|||
|
||||
from oslo_utils import uuidutils
|
||||
|
||||
from nova.api.openstack.placement import context
|
||||
from nova.api.openstack.placement import deploy
|
||||
from nova.api.openstack.placement import exception
|
||||
from nova.api.openstack.placement.objects import consumer as consumer_obj
|
||||
from nova.api.openstack.placement.objects import project as project_obj
|
||||
from nova.api.openstack.placement.objects import resource_provider as rp_obj
|
||||
from nova.api.openstack.placement.objects import user as user_obj
|
||||
from nova import context
|
||||
from nova import test
|
||||
from nova.tests import fixtures
|
||||
from nova.tests import uuidsentinel as uuids
|
||||
|
|
|
@ -13,13 +13,13 @@
|
|||
from oslo_config import cfg
|
||||
import sqlalchemy as sa
|
||||
|
||||
from nova.api.openstack.placement import context
|
||||
from nova.api.openstack.placement import db_api
|
||||
from nova.api.openstack.placement import exception
|
||||
from nova.api.openstack.placement.objects import consumer as consumer_obj
|
||||
from nova.api.openstack.placement.objects import project as project_obj
|
||||
from nova.api.openstack.placement.objects import resource_provider as rp_obj
|
||||
from nova.api.openstack.placement.objects import user as user_obj
|
||||
from nova import context
|
||||
from nova import rc_fields as fields
|
||||
from nova import test
|
||||
from nova.tests import fixtures
|
||||
|
|
|
@ -16,6 +16,7 @@ from gabbi import fixture
|
|||
from oslo_middleware import cors
|
||||
from oslo_utils import uuidutils
|
||||
|
||||
from nova.api.openstack.placement import context
|
||||
from nova.api.openstack.placement import deploy
|
||||
from nova.api.openstack.placement import exception
|
||||
from nova.api.openstack.placement.objects import consumer as consumer_obj
|
||||
|
@ -25,7 +26,6 @@ from nova.api.openstack.placement.objects import user as user_obj
|
|||
from nova.api.openstack.placement import policies
|
||||
from nova import conf
|
||||
from nova import config
|
||||
from nova import context
|
||||
from nova import rc_fields as fields
|
||||
from nova.tests import fixtures
|
||||
from nova.tests.functional.api.openstack.placement.db import test_base as tb
|
||||
|
@ -69,6 +69,8 @@ class APIFixture(fixture.GabbiFixture):
|
|||
self.conf.set_override('connection', "sqlite://",
|
||||
group='placement_database')
|
||||
|
||||
self.context = context.RequestContext()
|
||||
|
||||
# Register CORS opts, but do not set config. This has the
|
||||
# effect of exercising the "don't use cors" path in
|
||||
# deploy.py. Without setting some config the group will not
|
||||
|
@ -136,7 +138,6 @@ class AllocationFixture(APIFixture):
|
|||
# TODO(jaypipes): Simplify and restructure this fixture
|
||||
def start_fixture(self):
|
||||
super(AllocationFixture, self).start_fixture()
|
||||
self.context = context.get_admin_context()
|
||||
|
||||
# For use creating and querying allocations/usages
|
||||
os.environ['ALT_USER_ID'] = uuidutils.generate_uuid()
|
||||
|
@ -279,7 +280,6 @@ class SharedStorageFixture(APIFixture):
|
|||
|
||||
def start_fixture(self):
|
||||
super(SharedStorageFixture, self).start_fixture()
|
||||
self.context = context.get_admin_context()
|
||||
|
||||
agg_uuid = uuidutils.generate_uuid()
|
||||
|
||||
|
@ -339,7 +339,6 @@ class NonSharedStorageFixture(APIFixture):
|
|||
"""
|
||||
def start_fixture(self):
|
||||
super(NonSharedStorageFixture, self).start_fixture()
|
||||
self.context = context.get_admin_context()
|
||||
|
||||
cn1_uuid = uuidutils.generate_uuid()
|
||||
cn2_uuid = uuidutils.generate_uuid()
|
||||
|
@ -472,7 +471,7 @@ class GranularFixture(APIFixture):
|
|||
def _create_provider(self, name, *aggs, **kwargs):
|
||||
# TODO(efried): Common with test_allocation_candidates.ProviderDBBase
|
||||
parent = kwargs.get('parent')
|
||||
rp = rp_obj.ResourceProvider(self.ctx, name=name,
|
||||
rp = rp_obj.ResourceProvider(self.context, name=name,
|
||||
uuid=getattr(uuids, name))
|
||||
if parent:
|
||||
rp.parent_provider_uuid = parent
|
||||
|
@ -483,9 +482,9 @@ class GranularFixture(APIFixture):
|
|||
|
||||
def start_fixture(self):
|
||||
super(GranularFixture, self).start_fixture()
|
||||
self.ctx = context.get_admin_context()
|
||||
|
||||
rp_obj.ResourceClass(context=self.ctx, name='CUSTOM_NET_MBPS').create()
|
||||
rp_obj.ResourceClass(
|
||||
context=self.context, name='CUSTOM_NET_MBPS').create()
|
||||
|
||||
os.environ['AGGA'] = uuids.aggA
|
||||
os.environ['AGGB'] = uuids.aggB
|
||||
|
|
|
@ -12,9 +12,9 @@
|
|||
|
||||
from oslo_config import cfg
|
||||
|
||||
from nova.api.openstack.placement import context
|
||||
from nova.api.openstack.placement import direct
|
||||
from nova.api.openstack.placement.objects import resource_provider
|
||||
from nova import context
|
||||
from nova import test
|
||||
from nova.tests import fixtures
|
||||
from nova.tests import uuidsentinel
|
||||
|
@ -31,7 +31,7 @@ class TestDirect(test.NoDBTestCase):
|
|||
super(TestDirect, self).setUp()
|
||||
self.api_db = self.useFixture(fixtures.Database(database='placement'))
|
||||
self._reset_traits_synced()
|
||||
self.context = context.get_admin_context()
|
||||
self.context = context.RequestContext()
|
||||
self.addCleanup(self._reset_traits_synced)
|
||||
|
||||
@staticmethod
|
||||
|
|
Loading…
Reference in New Issue