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
This commit is contained in:
Ghanshyam Mann
2019-11-25 18:39:03 +00:00
parent bee15b5681
commit 5c96864e60
3 changed files with 6 additions and 2 deletions
+1 -1
View File
@@ -82,7 +82,7 @@ oslo.i18n==3.15.3
oslo.log==3.36.0 oslo.log==3.36.0
oslo.messaging==10.3.0 oslo.messaging==10.3.0
oslo.middleware==3.31.0 oslo.middleware==3.31.0
oslo.policy==1.38.0 oslo.policy==2.3.0
oslo.privsep==1.33.2 oslo.privsep==1.33.2
oslo.reports==1.18.0 oslo.reports==1.18.0
oslo.rootwrap==5.8.0 oslo.rootwrap==5.8.0
+4
View File
@@ -51,6 +51,10 @@ class RealPolicyFixture(fixtures.Fixture):
CONF.set_override('policy_file', self.policy_file, group='oslo_policy') CONF.set_override('policy_file', self.policy_file, group='oslo_policy')
nova.policy.reset() nova.policy.reset()
nova.policy.init() 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) self.addCleanup(nova.policy.reset)
def set_rules(self, rules, overwrite=True): def set_rules(self, rules, overwrite=True):
+1 -1
View File
@@ -46,7 +46,7 @@ oslo.utils>=3.40.2 # Apache-2.0
oslo.db>=4.44.0 # Apache-2.0 oslo.db>=4.44.0 # Apache-2.0
oslo.rootwrap>=5.8.0 # Apache-2.0 oslo.rootwrap>=5.8.0 # Apache-2.0
oslo.messaging>=10.3.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.privsep>=1.33.2 # Apache-2.0
oslo.i18n>=3.15.3 # Apache-2.0 oslo.i18n>=3.15.3 # Apache-2.0
oslo.service>=1.40.1 # Apache-2.0 oslo.service>=1.40.1 # Apache-2.0