From 131686f66c80834470529eb70710dbeffbbaad96 Mon Sep 17 00:00:00 2001 From: Diana Clarke Date: Mon, 25 Jul 2016 14:00:32 -0600 Subject: [PATCH] Fix database poison warnings, part 13 The following warning appears in the unit test logs a number of times. "UserWarning: This test uses methods that set internal oslo_db state, but it does not claim to use the database. This will conflict with the setup of tests that do use the database and cause failures later." This patch fixes the warnings from: unit.virt.vmwareapi.test_driver_api.py Note that this warning is only emitted once per unit test worker, so new offenders will show up in the logs each time you fix a test until they are all gone. Change-Id: I2dd21ec8c970161f695b2f37ae0973343678a0c4 Related-Bug: #1568414 --- .../unit/virt/vmwareapi/test_driver_api.py | 24 ++++++++++++------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/nova/tests/unit/virt/vmwareapi/test_driver_api.py b/nova/tests/unit/virt/vmwareapi/test_driver_api.py index 1fa0ba7b9588..318514d2f88d 100644 --- a/nova/tests/unit/virt/vmwareapi/test_driver_api.py +++ b/nova/tests/unit/virt/vmwareapi/test_driver_api.py @@ -1876,7 +1876,7 @@ class VMwareAPIVMTestCase(test.NoDBTestCase): instance=None) @mock.patch.object(objects.block_device.BlockDeviceMappingList, - 'get_by_instance_uuid') + 'get_by_instance_uuids') def test_image_aging_image_used(self, mock_get_by_inst): self._create_vm() all_instances = [self.instance] @@ -1914,7 +1914,9 @@ class VMwareAPIVMTestCase(test.NoDBTestCase): self._cached_files_exist() self._timestamp_file_exists() - def test_image_aging_image_marked_for_deletion(self): + @mock.patch.object(objects.block_device.BlockDeviceMappingList, + 'get_by_instance_uuids') + def test_image_aging_image_marked_for_deletion(self, mock_get_by_inst): self._override_time() self._image_aging_image_marked_for_deletion() @@ -1925,11 +1927,13 @@ class VMwareAPIVMTestCase(test.NoDBTestCase): uuid=uuidutils.generate_uuid()) self._timestamp_file_exists(exists=False) - def test_timestamp_file_removed_spawn(self): + @mock.patch.object(objects.block_device.BlockDeviceMappingList, + 'get_by_instance_uuids') + def test_timestamp_file_removed_spawn(self, mock_get_by_inst): self._timestamp_file_removed() @mock.patch.object(objects.block_device.BlockDeviceMappingList, - 'get_by_instance_uuid') + 'get_by_instance_uuids') def test_timestamp_file_removed_aging(self, mock_get_by_inst): self._timestamp_file_removed() ts = self._get_timestamp_filename() @@ -1941,9 +1945,7 @@ class VMwareAPIVMTestCase(test.NoDBTestCase): self.conn.manage_image_cache(self.context, all_instances) self._timestamp_file_exists(exists=False) - @mock.patch.object(objects.block_device.BlockDeviceMappingList, - 'get_by_instance_uuid') - def test_image_aging_disabled(self, mock_get_by_inst): + def test_image_aging_disabled(self): self._override_time() self.flags(remove_unused_base_images=False) self._create_vm() @@ -1962,11 +1964,15 @@ class VMwareAPIVMTestCase(test.NoDBTestCase): self.useFixture(utils_fixture.TimeFixture(cur_time)) self.conn.manage_image_cache(self.context, all_instances) - def test_image_aging_aged(self): + @mock.patch.object(objects.block_device.BlockDeviceMappingList, + 'get_by_instance_uuids') + def test_image_aging_aged(self, mock_get_by_inst): self._image_aging_aged(aging_time=8) self._cached_files_exist(exists=False) - def test_image_aging_not_aged(self): + @mock.patch.object(objects.block_device.BlockDeviceMappingList, + 'get_by_instance_uuids') + def test_image_aging_not_aged(self, mock_get_by_inst): self._image_aging_aged() self._cached_files_exist()