Fix database poison warnings, part 6

The following warning appears in the unit test logs a number of times.
This patch fixes all the warnings in unit.compute.test_compute_utils.

    "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."

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: I593c9f7a2d5f688fe316347c61c34339b79e8929
Related-Bug: #1568414
This commit is contained in:
Diana Clarke 2016-04-26 21:27:58 -04:00
parent 84983f91cf
commit c263995b13
1 changed files with 4 additions and 5 deletions

View File

@ -36,6 +36,7 @@ from nova.image import glance
from nova.network import api as network_api
from nova.network import model
from nova import objects
from nova.objects import base
from nova.objects import block_device as block_device_obj
from nova import rpc
from nova import test
@ -99,12 +100,10 @@ class ComputeValidateDeviceTestCase(test.NoDBTestCase):
self.data = []
self.stub_out('nova.db.block_device_mapping_get_all_by_instance',
lambda context, instance: self.data)
def _validate_device(self, device=None):
bdms = objects.BlockDeviceMappingList.get_by_instance_uuid(
self.context, self.instance['uuid'])
bdms = base.obj_make_list(self.context,
objects.BlockDeviceMappingList(), objects.BlockDeviceMapping,
self.data)
return compute_utils.get_device_name_for_instance(
self.instance, bdms, device)