diff --git a/placement/db_api.py b/placement/db_api.py index eb5fce403..f7baff97a 100644 --- a/placement/db_api.py +++ b/placement/db_api.py @@ -23,7 +23,9 @@ placement_context_manager = enginefacade.transaction_context() def _get_db_conf(conf_group): conf_dict = dict(conf_group.items()) # Remove the 'sync_on_startup' conf setting, enginefacade does not use it. - del conf_dict['sync_on_startup'] + # Use pop since it might not be present in testing situations and we + # don't want to care here. + conf_dict.pop('sync_on_startup', None) return conf_dict diff --git a/placement/tests/functional/fixtures/placement.py b/placement/tests/functional/fixtures/placement.py index 6e910f9b0..ca008e074 100644 --- a/placement/tests/functional/fixtures/placement.py +++ b/placement/tests/functional/fixtures/placement.py @@ -30,6 +30,9 @@ class PlacementFixture(fixtures.Fixture): Runs a local WSGI server bound on a free port and having the Placement application with NoAuth middleware. + Optionally, the caller can choose to not use a wsgi-intercept and use + this fixture to set up configuration and (optionally) the database. + It's possible to ask for a specific token when running the fixtures so all calls would be passing this token. @@ -38,9 +41,21 @@ class PlacementFixture(fixtures.Fixture): Used by other services, including nova, for functional tests. """ - def __init__(self, token='admin', conf_fixture=None, db=True): + def __init__(self, token='admin', conf_fixture=None, db=True, + use_intercept=True): + """Create a Placement Fixture. + + :param token: The value to be used when passing an auth token + header in HTTP requests. + :param conf_fixture: An oslo_conf.fixture.Config. If provided, config + will be based from it. + :param db: Whether to start the Database fixture. + :param use_intercept: If true, install a wsgi-intercept of the + placement WSGI app. + """ self.token = token self.db = db + self.use_intercept = use_intercept self.conf_fixture = conf_fixture def setUp(self): @@ -60,9 +75,10 @@ class PlacementFixture(fixtures.Fixture): self.useFixture(policy_fixture.PolicyFixture(self.conf_fixture)) - loader = deploy.loadapp(self.conf_fixture.conf) - app = lambda: loader - self.endpoint = 'http://%s/placement' % uuidutils.generate_uuid() - intercept = interceptor.RequestsInterceptor(app, url=self.endpoint) - intercept.install_intercept() - self.addCleanup(intercept.uninstall_intercept) + if self.use_intercept: + loader = deploy.loadapp(self.conf_fixture.conf) + app = lambda: loader + self.endpoint = 'http://%s/placement' % uuidutils.generate_uuid() + intercept = interceptor.RequestsInterceptor(app, url=self.endpoint) + intercept.install_intercept() + self.addCleanup(intercept.uninstall_intercept)