Fix database poison warnings, part 15
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 all the warnings from: unit.compute.test_compute_mgr.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: I4529b4bdc13b4079b1274034b44a1f44922c3bf2 Related-Bug: #1568414
This commit is contained in:
parent
c983a6a2bc
commit
0ada84cc54
|
@ -2932,7 +2932,8 @@ class ComputeManagerUnitTestCase(test.NoDBTestCase):
|
|||
mock.patch.object(self.compute, '_do_rebuild_instance_with_claim'),
|
||||
mock.patch.object(objects.Instance, 'save'),
|
||||
mock.patch.object(self.compute, '_set_migration_status'),
|
||||
) as (mock_get, mock_rebuild, mock_save, mock_set):
|
||||
mock.patch.object(compute_utils, 'EventReporter'),
|
||||
) as (mock_get, mock_rebuild, mock_save, mock_set, mock_event):
|
||||
self.compute.rebuild_instance(self.context, instance, None, None,
|
||||
None, None, None, None, False)
|
||||
self.assertFalse(mock_get.called)
|
||||
|
@ -2949,7 +2950,8 @@ class ComputeManagerUnitTestCase(test.NoDBTestCase):
|
|||
mock.patch.object(self.compute, '_do_rebuild_instance_with_claim'),
|
||||
mock.patch.object(objects.Instance, 'save'),
|
||||
mock.patch.object(self.compute, '_set_migration_status'),
|
||||
) as (mock_get, mock_rebuild, mock_save, mock_set):
|
||||
mock.patch.object(compute_utils, 'EventReporter'),
|
||||
) as (mock_get, mock_rebuild, mock_save, mock_set, mock_event):
|
||||
mock_get.return_value.hypervisor_hostname = 'new-node'
|
||||
self.compute.rebuild_instance(self.context, instance, None, None,
|
||||
None, None, None, None, True)
|
||||
|
@ -4661,8 +4663,15 @@ class ComputeManagerMigrationTestCase(test.NoDBTestCase):
|
|||
@mock.patch.object(self.migration, 'save')
|
||||
@mock.patch.object(self.instance, 'save')
|
||||
@mock.patch.object(self.compute, '_set_instance_info')
|
||||
@mock.patch.object(db, 'instance_fault_create')
|
||||
@mock.patch.object(objects.BlockDeviceMappingList,
|
||||
'get_by_instance_uuid')
|
||||
@mock.patch.object(compute_utils, 'EventReporter')
|
||||
@mock.patch.object(compute_utils, 'notify_about_instance_usage')
|
||||
def do_test(notify_about_instance_usage,
|
||||
event_reporter,
|
||||
get_by_instance_uuid,
|
||||
fault_create,
|
||||
set_instance_info,
|
||||
instance_save,
|
||||
migration_save,
|
||||
|
@ -4672,6 +4681,8 @@ class ComputeManagerMigrationTestCase(test.NoDBTestCase):
|
|||
finish_revert_migration,
|
||||
get_resource_tracker):
|
||||
|
||||
fault_create.return_value = (
|
||||
test_instance_fault.fake_faults['fake-uuid'][0])
|
||||
self.migration.source_compute = self.instance['host']
|
||||
self.migration.source_node = self.instance['host']
|
||||
self.compute.finish_revert_resize(context=self.context,
|
||||
|
|
Loading…
Reference in New Issue