Browse Source

Suppress policy deprecation warnings in unit tests

Since the WSGI app is reinitialized pretty much for every unit test, and
we have deprecated so many policies, we get hundreds of megabytes of
deprecation warnings in the unit test logs. This is unnecessary for unit
tests, a noisy hindrance to developers, and causes a high failure rate
in our CI due to the huge logs. This change fixes the issue for the unit
tests by adding warnings filters for DeprecationWarnings and
UserWarnings from oslo.policy and oslo.context.

This does not solve the issue that deployers see a lot of noise in their
logs. However, since production servers aren't reinitializing the WSGI
app quite so often, it's a less severe issue.

Related-bug: #1836568

Change-Id: Iaa7eae03bde7ab43a8c5a5886686f834cf7ec620
Depends-on: https://review.opendev.org/673932
tags/16.0.0.0rc1
Colleen Murphy 1 year ago
parent
commit
e8151070c0
4 changed files with 7 additions and 2 deletions
  1. +4
    -0
      keystone/common/rbac_enforcer/enforcer.py
  2. +1
    -0
      keystone/tests/unit/ksfixtures/policy.py
  3. +1
    -1
      lower-constraints.txt
  4. +1
    -1
      requirements.txt

+ 4
- 0
keystone/common/rbac_enforcer/enforcer.py View File

@@ -45,6 +45,8 @@ class RBACEnforcer(object):
__shared_state__ = {}
__ENFORCER = None
ACTION_STORE_ATTR = 'keystone:RBAC:action_name'
# FOR TESTS ONLY
suppress_deprecation_warnings = False

def __init__(self):
# NOTE(morgan): All Enforcer Instances use the same shared state;
@@ -92,6 +94,8 @@ class RBACEnforcer(object):
# The raw oslo-policy enforcer object
if self.__ENFORCER is None:
self.__ENFORCER = common_policy.Enforcer(CONF)
if self.suppress_deprecation_warnings:
self.__ENFORCER.suppress_deprecation_warnings = True
self.register_rules(self.__ENFORCER)
return self.__ENFORCER



+ 1
- 0
keystone/tests/unit/ksfixtures/policy.py View File

@@ -29,4 +29,5 @@ class Policy(fixtures.Fixture):
opts.set_defaults(self._config_fixture.conf)
self._config_fixture.config(group='oslo_policy',
policy_file=self._policy_file)
policy._ENFORCER.suppress_deprecation_warnings = True
self.addCleanup(policy.reset)

+ 1
- 1
lower-constraints.txt View File

@@ -34,7 +34,7 @@ oslo.i18n==3.15.3
oslo.log==3.44.0
oslo.messaging==5.29.0
oslo.middleware==3.31.0
oslo.policy==1.43.1
oslo.policy==2.3.0
oslo.serialization==2.18.0
oslo.upgradecheck==0.1.0
oslo.utils==3.33.0


+ 1
- 1
requirements.txt View File

@@ -29,7 +29,7 @@ oslo.db>=4.27.0 # Apache-2.0
oslo.i18n>=3.15.3 # Apache-2.0
oslo.log>=3.44.0 # Apache-2.0
oslo.middleware>=3.31.0 # Apache-2.0
oslo.policy>=1.43.1 # Apache-2.0
oslo.policy>=2.3.0 # Apache-2.0
oslo.serialization!=2.19.1,>=2.18.0 # Apache-2.0
oslo.upgradecheck>=0.1.0 # Apache-2.0
oslo.utils>=3.33.0 # Apache-2.0


Loading…
Cancel
Save