From 09090c8277284848007a8de1187b5cdc68c37d09 Mon Sep 17 00:00:00 2001 From: Chris Dent Date: Mon, 4 Mar 2019 20:08:28 +0000 Subject: [PATCH] Use a placement conf when testing report client It turns out that the independent wsgi interceptors in test_report_client were using nova's global configuration when creating the intercepts using code from placement. This was working because until [1] placement's set of conf options had not diverged from nova's and nova still has placement_database config settings. This change takes advantage of new functionality in the PlacementFixture to allow the fixtur to manage config and database, but _not_ run the interceptor. This means it can set up a config that is later used by the independent interceptors that are used in the report client tests. [1] Ie43a69be8b75250d9deca6a911eda7b722ef8648 Change-Id: I05326e0f917ca1b9a6ef8d3bd463f68bd00e217e Closes-Bug: #1818560 Depends-On: I8c36f35dbe85b0c0db1a5b6b5389b160b68ca488 --- nova/tests/functional/test_report_client.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/nova/tests/functional/test_report_client.py b/nova/tests/functional/test_report_client.py index b6bf1747cb29..10d409fac95c 100644 --- a/nova/tests/functional/test_report_client.py +++ b/nova/tests/functional/test_report_client.py @@ -20,7 +20,7 @@ from oslo_config import fixture as config_fixture from oslo_utils.fixture import uuidsentinel as uuids import pkg_resources from placement import direct -from placement.tests import fixtures as placement_db +from placement.tests.functional.fixtures import placement from nova.cmd import status from nova.compute import provider_tree @@ -89,10 +89,13 @@ class SchedulerReportClientTestBase(test.TestCase): def setUp(self): super(SchedulerReportClientTestBase, self).setUp() # Because these tests use PlacementDirect we need to manage - # the database ourselves. + # the database and other config ourselves. config = cfg.ConfigOpts() placement_conf = self.useFixture(config_fixture.Config(config)) - self.useFixture(placement_db.Database(placement_conf, set_config=True)) + self.useFixture( + placement.PlacementFixture(conf_fixture=placement_conf, db=True, + use_intercept=False)) + self.placement_conf = placement_conf.conf def _interceptor(self, app=None, latest_microversion=True): """Set up an intercepted placement API to test against. @@ -122,7 +125,7 @@ class SchedulerReportClientTestBase(test.TestCase): return client interceptor = ReportClientInterceptor( - CONF, latest_microversion=latest_microversion) + self.placement_conf, latest_microversion=latest_microversion) if app: interceptor.app = app return interceptor