From: Tom Barron Date: Mon, 29 Feb 2016 13:27:02 +0000 (-0500) Subject: Fix invalid uuid warnings in block device unit tests X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=55bade36754f77cd16e64955a299b81869d96d30;p=openstack-build%2Fcinder-build.git Fix invalid uuid warnings in block device unit tests Currently 'tox -epy27 -- --regex cinder.tests.unit.test_block_device' emits a dozen 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: Ia50b12e646d2f967a3275f1e9aa15ef2bc212c46 --- diff --git a/cinder/tests/unit/fake_constants.py b/cinder/tests/unit/fake_constants.py index bdcc73a18..a8f83ef53 100644 --- a/cinder/tests/unit/fake_constants.py +++ b/cinder/tests/unit/fake_constants.py @@ -18,6 +18,7 @@ volume_id = '1e5177e7-95e5-4a0f-b170-e45f4b469f6a' volume2_id = '43a09914-e495-475f-b862-0bda3c8918e4' volume3_id = '1b1cf149-219c-44ac-aee3-13121a7f86a7' volume_name_id = 'ee73d33c-52ed-4cb7-a8a9-2687c1205c22' +volume2_name_id = '41de4a80-2aab-4058-8293-7fc6343dcb82' snapshot_id = '253b2878-ec60-4793-ad19-e65496ec7aab' snapshot2_id = 'c02c44fa-5665-4a26-9e66-2ebaf25e5d2d' snapshot3_id = '454f9970-1e05-4193-a3ed-5c390c3faa18' diff --git a/cinder/tests/unit/test_block_device.py b/cinder/tests/unit/test_block_device.py index ab7543c5b..331220c13 100644 --- a/cinder/tests/unit/test_block_device.py +++ b/cinder/tests/unit/test_block_device.py @@ -22,6 +22,7 @@ import cinder.exception from cinder.objects import snapshot as obj_snap from cinder.objects import volume as obj_volume import cinder.test +from cinder.tests.unit import fake_constants as fake from cinder.volume import configuration as conf from cinder.volume.drivers import block_device from cinder.volume import utils as volutils @@ -46,7 +47,7 @@ class TestBlockDeviceDriver(cinder.test.TestCase): provider_location='1 2 3 /dev/loop1', provider_auth='a b c', attached_mode='rw', - id='fake-uuid') + id=fake.volume_id) TEST_CONNECTOR = {'host': 'localhost1'} data = self.drv.initialize_connection(TEST_VOLUME1, TEST_CONNECTOR) @@ -62,7 +63,7 @@ class TestBlockDeviceDriver(cinder.test.TestCase): provider_location='1 2 3 /dev/loop2', provider_auth='d e f', attached_mode='rw', - id='fake-uuid-2') + id=fake.volume2_id) _init_conn.return_value = 'data' data = self.drv.initialize_connection(TEST_VOLUME2, TEST_CONNECTOR) @@ -74,7 +75,7 @@ class TestBlockDeviceDriver(cinder.test.TestCase): 'target_iqn': '2', 'target_lun': 3, 'target_portal': '1', - 'volume_id': 'fake-uuid-2'}} + 'volume_id': fake.volume2_id}} self.assertEqual(expected_data['data'], data['data']) @@ -90,7 +91,7 @@ class TestBlockDeviceDriver(cinder.test.TestCase): @mock.patch('os.path.exists', return_value=True) @mock.patch('cinder.volume.utils.clear_volume') def test_delete_volume_path_exist(self, _clear_volume, _exists): - TEST_VOLUME = obj_volume.Volume(name_id='1234', + TEST_VOLUME = obj_volume.Volume(name_id=fake.volume_name_id, size=1, provider_location='/dev/loop1', display_name='vol1', @@ -119,7 +120,7 @@ class TestBlockDeviceDriver(cinder.test.TestCase): lp_mocked.assert_called_once_with(TEST_VOLUME2) def test__update_provider_location(self): - TEST_VOLUME = obj_volume.Volume(name_id='1234', + TEST_VOLUME = obj_volume.Volume(name_id=fake.volume_name_id, size=1, display_name='vol1') with mock.patch.object(obj_volume.Volume, 'update') as update_mocked, \ @@ -129,7 +130,7 @@ class TestBlockDeviceDriver(cinder.test.TestCase): save_mocked.assert_called_once_with() def test_create_volume(self): - TEST_VOLUME = obj_volume.Volume(name_id='1234', + TEST_VOLUME = obj_volume.Volume(name_id=fake.volume_name_id, size=1, display_name='vol1') @@ -166,11 +167,11 @@ class TestBlockDeviceDriver(cinder.test.TestCase): @mock.patch('cinder.volume.utils.copy_volume') def test_create_cloned_volume(self, _copy_volume): - TEST_SRC = obj_volume.Volume(id=1, - name_id='5678', + TEST_SRC = obj_volume.Volume(id=fake.volume_id, + name_id=fake.volume_name_id, size=1, provider_location='/dev/loop1') - TEST_VOLUME = obj_volume.Volume(name_id='1234', + TEST_VOLUME = obj_volume.Volume(name_id=fake.volume2_name_id, size=1, display_name='vol1') @@ -197,7 +198,7 @@ class TestBlockDeviceDriver(cinder.test.TestCase): @mock.patch.object(cinder.image.image_utils, 'fetch_to_raw') def test_copy_image_to_volume(self, _fetch_to_raw): - TEST_VOLUME = obj_volume.Volume(name_id='1234', + TEST_VOLUME = obj_volume.Volume(name_id=fake.volume_name_id, size=1, provider_location='/dev/loop1') TEST_IMAGE_SERVICE = "image_service" @@ -321,14 +322,14 @@ class TestBlockDeviceDriver(cinder.test.TestCase): @mock.patch('cinder.volume.utils.copy_volume') def test_create_snapshot(self, _copy_volume): - TEST_VOLUME = obj_volume.Volume(id=1, - name_id='1234', + TEST_VOLUME = obj_volume.Volume(id=fake.volume_id, + name_id=fake.volume_name_id, size=1, display_name='vol1', status='available', provider_location='/dev/loop1') - TEST_SNAP = obj_snap.Snapshot(id=1, - volume_id=1, + TEST_SNAP = obj_snap.Snapshot(id=fake.snapshot_id, + volume_id=fake.volume_id, volume_size=1024, provider_location='/dev/loop2', volume=TEST_VOLUME) @@ -351,14 +352,14 @@ class TestBlockDeviceDriver(cinder.test.TestCase): TEST_SNAP, '/dev/loop2') def test_create_snapshot_with_not_available_volume(self): - TEST_VOLUME = obj_volume.Volume(id=1, - name_id='1234', + TEST_VOLUME = obj_volume.Volume(id=fake.volume_id, + name_id=fake.volume_name_id, size=1, display_name='vol1', status='in use', provider_location='/dev/loop1') - TEST_SNAP = obj_snap.Snapshot(id=1, - volume_id=1, + TEST_SNAP = obj_snap.Snapshot(id=fake.snapshot_id, + volume_id=fake.volume_id, volume_size=1024, provider_location='/dev/loop2', volume=TEST_VOLUME) @@ -368,11 +369,11 @@ class TestBlockDeviceDriver(cinder.test.TestCase): @mock.patch('cinder.volume.utils.copy_volume') def test_create_volume_from_snapshot(self, _copy_volume): - TEST_SNAP = obj_snap.Snapshot(volume_id=1, + TEST_SNAP = obj_snap.Snapshot(volume_id=fake.volume_id, volume_size=1024, provider_location='/dev/loop1') - TEST_VOLUME = obj_volume.Volume(id=1, - name_id='1234', + TEST_VOLUME = obj_volume.Volume(id=fake.volume_id, + name_id=fake.volume_name_id, size=1, display_name='vol1', provider_location='/dev/loop2') @@ -399,7 +400,7 @@ class TestBlockDeviceDriver(cinder.test.TestCase): @mock.patch('os.path.exists', return_value=True) @mock.patch('cinder.volume.utils.clear_volume') def test_delete_snapshot(self, _clear_volume, _exists): - TEST_SNAP = obj_snap.Snapshot(volume_id=1, + TEST_SNAP = obj_snap.Snapshot(volume_id=fake.volume_id, provider_location='/dev/loop1', status='available')