Fix database poison warnings, part 14
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.xenapi.test_xenapi.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: I41537e6b062b169cc6934d525560eb96ca58c55b Related-Bug: #1568414
This commit is contained in:
parent
794c0f8ced
commit
d98096bd92
@ -3568,34 +3568,38 @@ class XenAPILiveMigrateTestCase(stubs.XenAPITestBaseNoDB):
|
||||
{'host': 'host'},
|
||||
dest_check_data)
|
||||
|
||||
def test_check_can_live_migrate_works(self):
|
||||
@mock.patch.object(objects.AggregateList, 'get_by_host')
|
||||
def test_check_can_live_migrate_works(self, mock_get_by_host):
|
||||
stubs.stubout_session(self.stubs, stubs.FakeSessionForVMTests)
|
||||
self.conn = xenapi_conn.XenAPIDriver(fake.FakeVirtAPI(), False)
|
||||
|
||||
def fake_aggregate_get_by_host(context, host, key=None):
|
||||
self.assertEqual(CONF.host, host)
|
||||
return [dict(test_aggregate.fake_aggregate,
|
||||
metadetails={"host": "test_host_uuid"})]
|
||||
metadata = {'host': 'test_host_uuid'}
|
||||
aggregate = objects.Aggregate(metadata=metadata)
|
||||
aggregate_list = objects.AggregateList(objects=[aggregate])
|
||||
mock_get_by_host.return_value = aggregate_list
|
||||
|
||||
self.stub_out("nova.db.aggregate_get_by_host",
|
||||
fake_aggregate_get_by_host)
|
||||
self.conn.check_can_live_migrate_destination(self.context,
|
||||
{'host': 'host'}, False, False)
|
||||
instance = objects.Instance(host='host')
|
||||
self.conn.check_can_live_migrate_destination(
|
||||
self.context, instance, None, None)
|
||||
mock_get_by_host.assert_called_once_with(
|
||||
self.context, CONF.host, key='hypervisor_pool')
|
||||
|
||||
def test_check_can_live_migrate_fails(self):
|
||||
@mock.patch.object(objects.AggregateList, 'get_by_host')
|
||||
def test_check_can_live_migrate_fails(self, mock_get_by_host):
|
||||
stubs.stubout_session(self.stubs, stubs.FakeSessionForVMTests)
|
||||
self.conn = xenapi_conn.XenAPIDriver(fake.FakeVirtAPI(), False)
|
||||
|
||||
def fake_aggregate_get_by_host(context, host, key=None):
|
||||
self.assertEqual(CONF.host, host)
|
||||
return [dict(test_aggregate.fake_aggregate,
|
||||
metadetails={"dest_other": "test_host_uuid"})]
|
||||
metadata = {'dest_other': 'test_host_uuid'}
|
||||
aggregate = objects.Aggregate(metadata=metadata)
|
||||
aggregate_list = objects.AggregateList(objects=[aggregate])
|
||||
mock_get_by_host.return_value = aggregate_list
|
||||
|
||||
self.stub_out("nova.db.aggregate_get_by_host",
|
||||
fake_aggregate_get_by_host)
|
||||
instance = objects.Instance(host='host')
|
||||
self.assertRaises(exception.MigrationError,
|
||||
self.conn.check_can_live_migrate_destination,
|
||||
self.context, {'host': 'host'}, None, None)
|
||||
self.context, instance, None, None)
|
||||
mock_get_by_host.assert_called_once_with(
|
||||
self.context, CONF.host, key='hypervisor_pool')
|
||||
|
||||
def test_live_migration(self):
|
||||
stubs.stubout_session(self.stubs, stubs.FakeSessionForVMTests)
|
||||
|
Loading…
Reference in New Issue
Block a user