From: Matt Riedemann Date: Thu, 18 Jun 2015 15:16:52 +0000 (-0700) Subject: Use a hard-coded project_id in racy cinder.tests.unit.test_volume tests X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=bfcc27ea5c19e8aacce95cb56c10a95c5f1373b3;p=openstack-build%2Fcinder-build.git Use a hard-coded project_id in racy cinder.tests.unit.test_volume tests Since concurrent unit test runs have been turned on with ostestr there are races with the notifications causing the assertions in test_volume.py tests to fail. A few attempts have been made at writing an elastic-recheck query to identify the failures but they are too generic, e.g. querying for "fake_notifier.NOTIFICATIONS" or "MismatchError 0 != ", which could hit on anything that fails with those, e.g. anything that uses "self.assertEqual(0, " in the code could hit that kind of query - and we want to avoid those types of queries running against changes in the check queue since they could mask legitimate test failures. So we add something unique in these tests to identify them from other test failures in Cinder by using a hard-coded uuid for the project_id so that if we have an assertion failure with notifications, the notification payload is dumped (due to commit 4bbe1c87e26150c62e1dc8a2a5b8979896c1ddd9) and we can query on the assertion failure plus the hard-coded project_id used only in these tests. Related-Bug: #1412513 Change-Id: I57f597a1bb2fdfeb24c17ac9020cc96f1ebf3fdd --- diff --git a/cinder/tests/unit/test_volume.py b/cinder/tests/unit/test_volume.py index 651a8174b..b2fd36fc8 100644 --- a/cinder/tests/unit/test_volume.py +++ b/cinder/tests/unit/test_volume.py @@ -116,7 +116,11 @@ class BaseVolumeTestCase(test.TestCase): self.configuration = mock.Mock(conf.Configuration) self.context = context.get_admin_context() self.context.user_id = 'fake' - self.context.project_id = 'fake' + # NOTE(mriedem): The id is hard-coded here for tracking race fail + # assertions with the notification code, it's part of an + # elastic-recheck query so don't remove it or change it. + self.project_id = '7f265bd4-3a85-465e-a899-5dc4854a86d3' + self.context.project_id = self.project_id self.volume_params = { 'status': 'creating', 'host': CONF.host, @@ -546,7 +550,7 @@ class VolumeTestCase(BaseVolumeTestCase): 'host': socket.gethostname(), 'display_name': 'test_volume', 'availability_zone': 'nova', - 'tenant_id': 'fake', + 'tenant_id': self.context.project_id, 'created_at': 'DONTCARE', 'volume_id': volume_id, 'volume_type': None, @@ -4547,7 +4551,7 @@ class VolumeTestCase(BaseVolumeTestCase): 'status': 'available', 'name': 'test_cg', 'availability_zone': 'nova', - 'tenant_id': 'fake', + 'tenant_id': self.context.project_id, 'created_at': 'DONTCARE', 'user_id': 'fake', 'consistencygroup_id': group_id @@ -4629,7 +4633,7 @@ class VolumeTestCase(BaseVolumeTestCase): 'status': 'available', 'name': 'test_cg', 'availability_zone': 'nova', - 'tenant_id': 'fake', + 'tenant_id': self.context.project_id, 'created_at': 'DONTCARE', 'user_id': 'fake', 'consistencygroup_id': group_id @@ -4728,7 +4732,7 @@ class VolumeTestCase(BaseVolumeTestCase): 'status': 'available', 'name': 'test_cg', 'availability_zone': 'nova', - 'tenant_id': 'fake', + 'tenant_id': self.context.project_id, 'created_at': 'DONTCARE', 'user_id': 'fake', 'consistencygroup_id': group2_id