Fix database poison warnings, part 5
The following warning appears in the unit test logs a number of times. This patch fixes the last warnings in unit.compute.test_compute_api. "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: I9f81e22fda8dbab2007aa7d2aa972b9dce364b5f Related-Bug: #1568414
This commit is contained in:
parent
07590ab880
commit
5e4c9dec01
|
@ -53,7 +53,6 @@ from nova.tests.unit.image import fake as fake_image
|
|||
from nova.tests.unit import matchers
|
||||
from nova.tests.unit.objects import test_flavor
|
||||
from nova.tests.unit.objects import test_migration
|
||||
from nova.tests.unit.objects import test_service
|
||||
from nova.tests import uuidsentinel as uuids
|
||||
from nova import utils
|
||||
from nova.volume import cinder
|
||||
|
@ -954,7 +953,7 @@ class _ComputeAPIUnitTestMixIn(object):
|
|||
'get_by_instance_uuid')
|
||||
self.mox.StubOutWithMock(quota.QUOTAS, 'reserve')
|
||||
self.mox.StubOutWithMock(self.context, 'elevated')
|
||||
self.mox.StubOutWithMock(db, 'service_get_by_compute_host')
|
||||
self.mox.StubOutWithMock(objects.Service, 'get_by_compute_host')
|
||||
self.mox.StubOutWithMock(self.compute_api.servicegroup_api,
|
||||
'service_is_up')
|
||||
self.mox.StubOutWithMock(compute_utils, 'downsize_quota_delta')
|
||||
|
@ -968,6 +967,7 @@ class _ComputeAPIUnitTestMixIn(object):
|
|||
self.mox.StubOutWithMock(compute_utils,
|
||||
'notify_about_instance_usage')
|
||||
self.mox.StubOutWithMock(quota.QUOTAS, 'commit')
|
||||
self.mox.StubOutWithMock(quota.QUOTAS, 'rollback')
|
||||
rpcapi = self.compute_api.compute_rpcapi
|
||||
self.mox.StubOutWithMock(rpcapi, 'confirm_resize')
|
||||
|
||||
|
@ -1015,9 +1015,8 @@ class _ComputeAPIUnitTestMixIn(object):
|
|||
soft_delete = True
|
||||
if inst.vm_state != vm_states.SHELVED_OFFLOADED:
|
||||
self.context.elevated().AndReturn(self.context)
|
||||
db.service_get_by_compute_host(
|
||||
self.context, inst.host).AndReturn(
|
||||
test_service.fake_service)
|
||||
objects.Service.get_by_compute_host(self.context,
|
||||
inst.host).AndReturn(objects.Service())
|
||||
self.compute_api.servicegroup_api.service_is_up(
|
||||
mox.IsA(objects.Service)).AndReturn(
|
||||
inst.host != 'down-host')
|
||||
|
@ -1048,6 +1047,11 @@ class _ComputeAPIUnitTestMixIn(object):
|
|||
reservations=cast_reservations,
|
||||
delete_type=delete_type)
|
||||
|
||||
if soft_delete:
|
||||
quota.QUOTAS.rollback(self.context, reservations,
|
||||
project_id=inst.project_id,
|
||||
user_id=inst.user_id)
|
||||
|
||||
if commit_quotas:
|
||||
# Local delete or when we're testing API cell.
|
||||
quota.QUOTAS.commit(self.context, reservations,
|
||||
|
|
Loading…
Reference in New Issue