Fix database poison warnings, part 19
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: nova.tests.unit.virt.ironic.test_driver.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: I4181775eb0e89e8a21e6af8dddb3c9ffd09a6b83 Related-Bug: #1568414
This commit is contained in:
parent
c983a6a2bc
commit
62e818ab14
|
@ -599,7 +599,10 @@ class IronicDriverTestCase(test.NoDBTestCase):
|
|||
|
||||
@mock.patch.object(FAKE_CLIENT.node, 'list')
|
||||
@mock.patch.object(FAKE_CLIENT.node, 'get')
|
||||
def test_node_is_available_empty_cache_empty_list(self, mock_get,
|
||||
@mock.patch.object(objects.InstanceList, 'get_uuids_by_host')
|
||||
@mock.patch.object(objects.ServiceList, 'get_all_computes_by_hv_type')
|
||||
def test_node_is_available_empty_cache_empty_list(self, mock_services,
|
||||
mock_instances, mock_get,
|
||||
mock_list):
|
||||
node = ironic_utils.get_test_node()
|
||||
mock_get.return_value = node
|
||||
|
@ -614,7 +617,10 @@ class IronicDriverTestCase(test.NoDBTestCase):
|
|||
|
||||
@mock.patch.object(FAKE_CLIENT.node, 'list')
|
||||
@mock.patch.object(FAKE_CLIENT.node, 'get')
|
||||
def test_node_is_available_empty_cache(self, mock_get, mock_list):
|
||||
@mock.patch.object(objects.InstanceList, 'get_uuids_by_host')
|
||||
@mock.patch.object(objects.ServiceList, 'get_all_computes_by_hv_type')
|
||||
def test_node_is_available_empty_cache(self, mock_services, mock_instances,
|
||||
mock_get, mock_list):
|
||||
node = ironic_utils.get_test_node()
|
||||
mock_get.return_value = node
|
||||
mock_list.return_value = [node]
|
||||
|
@ -624,7 +630,10 @@ class IronicDriverTestCase(test.NoDBTestCase):
|
|||
|
||||
@mock.patch.object(FAKE_CLIENT.node, 'list')
|
||||
@mock.patch.object(FAKE_CLIENT.node, 'get')
|
||||
def test_node_is_available_with_cache(self, mock_get, mock_list):
|
||||
@mock.patch.object(objects.InstanceList, 'get_uuids_by_host')
|
||||
@mock.patch.object(objects.ServiceList, 'get_all_computes_by_hv_type')
|
||||
def test_node_is_available_with_cache(self, mock_services, mock_instances,
|
||||
mock_get, mock_list):
|
||||
node = ironic_utils.get_test_node()
|
||||
mock_get.return_value = node
|
||||
mock_list.return_value = [node]
|
||||
|
@ -707,9 +716,10 @@ class IronicDriverTestCase(test.NoDBTestCase):
|
|||
provision_state=ironic_states.AVAILABLE)
|
||||
self.assertFalse(self.driver._node_resources_used(unused_node))
|
||||
|
||||
@mock.patch.object(objects.ServiceList, 'get_all_computes_by_hv_type')
|
||||
@mock.patch.object(objects.InstanceList, 'get_uuids_by_host')
|
||||
@mock.patch.object(FAKE_CLIENT.node, 'list')
|
||||
def test_get_available_nodes(self, mock_list, mock_gi):
|
||||
def test_get_available_nodes(self, mock_list, mock_gi, mock_services):
|
||||
instance = fake_instance.fake_instance_obj(self.ctx,
|
||||
uuid=self.instance_uuid)
|
||||
mock_gi.return_value = [instance.uuid]
|
||||
|
@ -743,8 +753,11 @@ class IronicDriverTestCase(test.NoDBTestCase):
|
|||
|
||||
@mock.patch.object(FAKE_CLIENT.node, 'get')
|
||||
@mock.patch.object(FAKE_CLIENT.node, 'list')
|
||||
@mock.patch.object(objects.InstanceList, 'get_uuids_by_host')
|
||||
@mock.patch.object(objects.ServiceList, 'get_all_computes_by_hv_type')
|
||||
@mock.patch.object(ironic_driver.IronicDriver, '_node_resource')
|
||||
def test_get_available_resource(self, mock_nr, mock_list, mock_get):
|
||||
def test_get_available_resource(self, mock_nr, mock_services,
|
||||
mock_instances, mock_list, mock_get):
|
||||
node = ironic_utils.get_test_node()
|
||||
node_2 = ironic_utils.get_test_node(uuid=uuidutils.generate_uuid())
|
||||
fake_resource = 'fake-resource'
|
||||
|
@ -761,8 +774,11 @@ class IronicDriverTestCase(test.NoDBTestCase):
|
|||
|
||||
@mock.patch.object(FAKE_CLIENT.node, 'get')
|
||||
@mock.patch.object(FAKE_CLIENT.node, 'list')
|
||||
@mock.patch.object(objects.InstanceList, 'get_uuids_by_host')
|
||||
@mock.patch.object(objects.ServiceList, 'get_all_computes_by_hv_type')
|
||||
@mock.patch.object(ironic_driver.IronicDriver, '_node_resource')
|
||||
def test_get_available_resource_with_cache(self, mock_nr, mock_list,
|
||||
def test_get_available_resource_with_cache(self, mock_nr, mock_services,
|
||||
mock_instances, mock_list,
|
||||
mock_get):
|
||||
node = ironic_utils.get_test_node()
|
||||
fake_resource = 'fake-resource'
|
||||
|
@ -1706,9 +1722,10 @@ class IronicDriverTestCase(test.NoDBTestCase):
|
|||
@mock.patch.object(configdrive, 'ConfigDriveBuilder')
|
||||
class IronicDriverGenerateConfigDriveTestCase(test.NoDBTestCase):
|
||||
|
||||
@mock.patch.object(objects.ServiceList, 'get_all_computes_by_hv_type')
|
||||
@mock.patch.object(cw, 'IronicClientWrapper',
|
||||
lambda *_: FAKE_CLIENT_WRAPPER)
|
||||
def setUp(self):
|
||||
def setUp(self, mock_services):
|
||||
super(IronicDriverGenerateConfigDriveTestCase, self).setUp()
|
||||
self.driver = ironic_driver.IronicDriver(None)
|
||||
self.driver.virtapi = fake.FakeVirtAPI()
|
||||
|
@ -1749,8 +1766,10 @@ class IronicDriverGenerateConfigDriveTestCase(test.NoDBTestCase):
|
|||
|
||||
|
||||
class HashRingTestCase(test.NoDBTestCase):
|
||||
|
||||
@mock.patch.object(objects.ServiceList, 'get_all_computes_by_hv_type')
|
||||
@mock.patch.object(servicegroup, 'API', autospec=True)
|
||||
def setUp(self, mock_sg):
|
||||
def setUp(self, mock_sg, mock_services):
|
||||
super(HashRingTestCase, self).setUp()
|
||||
|
||||
self.driver = ironic_driver.IronicDriver(None)
|
||||
|
@ -1814,7 +1833,9 @@ class HashRingTestCase(test.NoDBTestCase):
|
|||
|
||||
|
||||
class NodeCacheTestCase(test.NoDBTestCase):
|
||||
def setUp(self):
|
||||
|
||||
@mock.patch.object(objects.ServiceList, 'get_all_computes_by_hv_type')
|
||||
def setUp(self, mock_services):
|
||||
super(NodeCacheTestCase, self).setUp()
|
||||
|
||||
self.driver = ironic_driver.IronicDriver(None)
|
||||
|
|
Loading…
Reference in New Issue