Tests: Fail if oslo.versionedobjects issues Invalid UUID warnings

There are many places in Cinder where we break this rule.

Filter them out ahead of time, before oslo.versionedobjects no
longer allows this behavior.

Change-Id: I34c48ff55a7d3e1b607fb8630bddbe5a1a14764d
This commit is contained in:
Eric Harney 2016-03-31 15:50:16 -04:00 committed by Tom Barron
parent 1fe4ed1a0e
commit ed6d50bed6

View File

@ -227,6 +227,7 @@ class TestCase(testtools.TestCase):
group='oslo_policy')
self._disable_osprofiler()
self._disallow_invalid_uuids()
# NOTE(geguileo): This is required because common get_by_id method in
# cinder.db.sqlalchemy.api caches get methods and if we use a mocked
@ -250,6 +251,17 @@ class TestCase(testtools.TestCase):
return_value=mock_decorator)
p.start()
def _disallow_invalid_uuids(self):
def catch_uuid_warning(message, *args, **kwargs):
ovo_message = "invalid UUID. Using UUIDFields with invalid UUIDs " \
"is no longer supported"
if ovo_message in message:
raise AssertionError(message)
p = mock.patch("warnings.warn",
side_effect=catch_uuid_warning)
p.start()
def _common_cleanup(self):
"""Runs after each test method to tear down test environment."""