From 9c073fa26bb229bb5c8a7fc0b22b80f7a4c37042 Mon Sep 17 00:00:00 2001 From: Tom Barron Date: Mon, 29 Feb 2016 07:48:04 -0500 Subject: [PATCH] Fix invalid uuid warnings in scheduler unit tests Currently 'tox -epy27 -- --regex cinder.tests.unit.scheduler' emits twenty FutureWarnings from oslo.versionedobjects about invalid uuids as documented here[1]. This commit changes these tests to use valid uuids so that when they are run these warnings are no longer emitted. Change-Id: I38187b159b9e42984fcf61cb4b77a94f00a56818 --- cinder/tests/unit/fake_consistencygroup.py | 7 ++++--- cinder/tests/unit/scheduler/test_host_filters.py | 3 ++- cinder/tests/unit/scheduler/test_scheduler.py | 7 ++++--- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/cinder/tests/unit/fake_consistencygroup.py b/cinder/tests/unit/fake_consistencygroup.py index 280959c30..fa526c2aa 100644 --- a/cinder/tests/unit/fake_consistencygroup.py +++ b/cinder/tests/unit/fake_consistencygroup.py @@ -15,13 +15,14 @@ from oslo_versionedobjects import fields from cinder import objects +from cinder.tests.unit import fake_constants as fake def fake_db_consistencygroup(**updates): db_values = { - 'id': '1', - 'user_id': '2', - 'project_id': '3', + 'id': fake.consistency_group_id, + 'user_id': fake.user_id, + 'project_id': fake.project_id, 'host': 'FakeHost', 'volumes': [], } diff --git a/cinder/tests/unit/scheduler/test_host_filters.py b/cinder/tests/unit/scheduler/test_host_filters.py index 9e5dca119..f988c300e 100644 --- a/cinder/tests/unit/scheduler/test_host_filters.py +++ b/cinder/tests/unit/scheduler/test_host_filters.py @@ -25,6 +25,7 @@ from cinder import db from cinder import exception from cinder.scheduler import filters from cinder import test +from cinder.tests.unit import fake_constants as fake from cinder.tests.unit.scheduler import fakes from cinder.tests.unit import utils @@ -34,7 +35,7 @@ class HostFiltersTestCase(test.TestCase): def setUp(self): super(HostFiltersTestCase, self).setUp() - self.context = context.RequestContext('fake', 'fake') + self.context = context.RequestContext(fake.user_id, fake.project_id) # This has a side effect of testing 'get_filter_classes' # when specifying a method (in this case, our standard filters) filter_handler = filters.HostFilterHandler('cinder.scheduler.filters') diff --git a/cinder/tests/unit/scheduler/test_scheduler.py b/cinder/tests/unit/scheduler/test_scheduler.py index b5c6f709d..fc8e074f3 100644 --- a/cinder/tests/unit/scheduler/test_scheduler.py +++ b/cinder/tests/unit/scheduler/test_scheduler.py @@ -29,6 +29,7 @@ from cinder.scheduler import filter_scheduler from cinder.scheduler import manager from cinder import test from cinder.tests.unit import fake_consistencygroup +from cinder.tests.unit import fake_constants as fake from cinder.tests.unit import fake_volume from cinder.tests.unit import utils as tests_utils @@ -287,7 +288,7 @@ class SchedulerManagerTestCase(test.TestCase): ex = exception.CinderException('test') mock_cg.side_effect = ex - group_id = '1' + group_id = fake.consistency_group_id self.assertRaises(exception.CinderException, self.manager.create_consistencygroup, self.context, @@ -323,7 +324,7 @@ class SchedulerTestCase(test.TestCase): def setUp(self): super(SchedulerTestCase, self).setUp() self.driver = self.driver_cls() - self.context = context.RequestContext('fake_user', 'fake_project') + self.context = context.RequestContext(fake.user_id, fake.project_id) self.topic = 'fake_topic' @mock.patch('cinder.scheduler.driver.Scheduler.' @@ -366,7 +367,7 @@ class SchedulerDriverModuleTestCase(test.TestCase): def setUp(self): super(SchedulerDriverModuleTestCase, self).setUp() - self.context = context.RequestContext('fake_user', 'fake_project') + self.context = context.RequestContext(fake.user_id, fake.project_id) @mock.patch('cinder.db.volume_update') @mock.patch('cinder.objects.volume.Volume.get_by_id') -- 2.45.2