From ed6d50bed642b01d005563866ab9f211632cff5b Mon Sep 17 00:00:00 2001 From: Eric Harney Date: Thu, 31 Mar 2016 15:50:16 -0400 Subject: [PATCH] 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 --- cinder/test.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/cinder/test.py b/cinder/test.py index 5ef1e0d971a..5fd0a6b5f77 100644 --- a/cinder/test.py +++ b/cinder/test.py @@ -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."""