From 5c96864e60b71743aa56c119d37a552e63df5d18 Mon Sep 17 00:00:00 2001 From: Ghanshyam Mann Date: Mon, 25 Nov 2019 18:39:03 +0000 Subject: [PATCH] Suppress policy deprecated warnings in tests Every unit tests init the policy via fixture[1] which will log the deprecation warnings. As per our new policy defaults work, we are going to deprecate almost all the policies due to their change in default value. Logging all the deprecation warning for every unit tests will overflow the log files and leads to error[2]. Oslo policy has a way to supress the deprecation warning for tests, so let's supress the deprecation warning for unti tests. This will not be issue on production cloud as there are only one time policy initialization. Bump oslo.policy version tod 2.3.0 which includes the suppress warning flag - https://docs.openstack.org/oslo.policy/latest/user/history.html#id3 [1] https://github.com/openstack/nova/blob/872a823d9a02f31e266882bfb499673c51fb4075/nova/tests/unit/policy_fixture.py#L53 [2] https://logs.opendev.org/80/648480/7/check/openstack-tox-py36/9289426/job-output.txt.gz Change-Id: I10880e7c8fcf57494d7a01eb694bd3cf3f7d36fe --- lower-constraints.txt | 2 +- nova/tests/unit/policy_fixture.py | 4 ++++ requirements.txt | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/lower-constraints.txt b/lower-constraints.txt index 5b755c46f5..e8841e7ec6 100644 --- a/lower-constraints.txt +++ b/lower-constraints.txt @@ -82,7 +82,7 @@ oslo.i18n==3.15.3 oslo.log==3.36.0 oslo.messaging==10.3.0 oslo.middleware==3.31.0 -oslo.policy==1.38.0 +oslo.policy==2.3.0 oslo.privsep==1.33.2 oslo.reports==1.18.0 oslo.rootwrap==5.8.0 diff --git a/nova/tests/unit/policy_fixture.py b/nova/tests/unit/policy_fixture.py index a076afa93d..e27b541e37 100644 --- a/nova/tests/unit/policy_fixture.py +++ b/nova/tests/unit/policy_fixture.py @@ -51,6 +51,10 @@ class RealPolicyFixture(fixtures.Fixture): CONF.set_override('policy_file', self.policy_file, group='oslo_policy') nova.policy.reset() nova.policy.init() + # NOTE(gmann): Logging all the deprecation warning for every unit + # test will overflow the log files and leads to error. Suppress + # the deprecation warning for tests only. + nova.policy._ENFORCER.suppress_deprecation_warnings = True self.addCleanup(nova.policy.reset) def set_rules(self, rules, overwrite=True): diff --git a/requirements.txt b/requirements.txt index 4c24a45ef8..1bc368217d 100644 --- a/requirements.txt +++ b/requirements.txt @@ -46,7 +46,7 @@ oslo.utils>=3.40.2 # Apache-2.0 oslo.db>=4.44.0 # Apache-2.0 oslo.rootwrap>=5.8.0 # Apache-2.0 oslo.messaging>=10.3.0 # Apache-2.0 -oslo.policy>=1.38.0 # Apache-2.0 +oslo.policy>=2.3.0 # Apache-2.0 oslo.privsep>=1.33.2 # Apache-2.0 oslo.i18n>=3.15.3 # Apache-2.0 oslo.service>=1.40.1 # Apache-2.0