From 7b6fb274524987cb708a900bc6f9a1b882e37cd4 Mon Sep 17 00:00:00 2001 From: Matt Riedemann Date: Wed, 13 Jun 2018 17:18:44 -0400 Subject: [PATCH] Ignore UserWarning for scope checks during test runs Placement API policy rules are defaulting to system scope. Scope checks are disabled by default in oslo.policy, but if you hit the API with a token that doesn't match the scope, it generates a UserWarning, for every policy check on that request. This is pretty annoying, so just filter those warnings during our test runs. Change-Id: I30ed00a96390d2c76cfc2a40c5a47c16eb51711c --- nova/tests/fixtures.py | 4 ++++ .../functional/api/openstack/placement/fixtures/gabbits.py | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/nova/tests/fixtures.py b/nova/tests/fixtures.py index 876679c0c87b..cb689d4c64e6 100644 --- a/nova/tests/fixtures.py +++ b/nova/tests/fixtures.py @@ -756,6 +756,10 @@ class WarningsFixture(fixtures.Fixture): # about any deprecations coming from it warnings.filterwarnings('ignore', module='mox3.mox') + # NOTE(mriedem): Ignore scope check UserWarnings from oslo.policy. + warnings.filterwarnings('ignore', + message="Policy .* failed scope check", + category=UserWarning) self.addCleanup(warnings.resetwarnings) diff --git a/nova/tests/functional/api/openstack/placement/fixtures/gabbits.py b/nova/tests/functional/api/openstack/placement/fixtures/gabbits.py index c84f8f6b86ec..65f5a88acb74 100644 --- a/nova/tests/functional/api/openstack/placement/fixtures/gabbits.py +++ b/nova/tests/functional/api/openstack/placement/fixtures/gabbits.py @@ -50,6 +50,9 @@ class APIFixture(fixture.GabbiFixture): self.standard_logging_fixture.setUp() self.output_stream_fixture = fixtures.OutputStreamCapture() self.output_stream_fixture.setUp() + # Filter ignorable warnings during test runs. + self.warnings_fixture = fixtures.WarningsFixture() + self.warnings_fixture.setUp() self.conf = CONF self.conf.set_override('auth_strategy', 'noauth2', group='api') @@ -102,6 +105,7 @@ class APIFixture(fixture.GabbiFixture): # are flushed. self._reset_db_flags() + self.warnings_fixture.cleanUp() self.output_stream_fixture.cleanUp() self.standard_logging_fixture.cleanUp() if self.conf: