Fix database poison warnings, part 17

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.api.openstack.compute.test_serversV21.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: I88264e54fd135e56612ae3066e1c160f6643f9c4
Related-Bug: #1568414
This commit is contained in:
Diana Clarke 2016-09-24 15:55:35 -04:00
parent c983a6a2bc
commit 8c753e9a84
1 changed files with 7 additions and 4 deletions

View File

@ -58,6 +58,7 @@ from nova import objects
from nova.objects import instance as instance_obj
from nova import policy
from nova import test
from nova.tests import fixtures as nova_fixtures
from nova.tests.unit.api.openstack import fakes
from nova.tests.unit import fake_instance
from nova.tests.unit import fake_network
@ -3553,11 +3554,11 @@ class ServersControllerCreateTestV237(test.NoDBTestCase):
@mock.patch.object(objects.Flavor, 'get_by_flavor_id',
side_effect=exception.FlavorNotFound(flavor_id='2'))
def test_create_server_auto_flavornotfound(self,
get_flavor):
def test_create_server_auto_flavornotfound(self, get_flavor):
"""Tests that requesting auto networking is OK. This test
short-circuits on a FlavorNotFound error.
"""
self.useFixture(nova_fixtures.AllServicesCurrent())
ex = self.assertRaises(
webob.exc.HTTPBadRequest, self._create_server, 'auto')
# make sure it was a flavor not found error and not something else
@ -3565,11 +3566,11 @@ class ServersControllerCreateTestV237(test.NoDBTestCase):
@mock.patch.object(objects.Flavor, 'get_by_flavor_id',
side_effect=exception.FlavorNotFound(flavor_id='2'))
def test_create_server_none_flavornotfound(self,
get_flavor):
def test_create_server_none_flavornotfound(self, get_flavor):
"""Tests that requesting none for networking is OK. This test
short-circuits on a FlavorNotFound error.
"""
self.useFixture(nova_fixtures.AllServicesCurrent())
ex = self.assertRaises(
webob.exc.HTTPBadRequest, self._create_server, 'none')
# make sure it was a flavor not found error and not something else
@ -3582,6 +3583,7 @@ class ServersControllerCreateTestV237(test.NoDBTestCase):
"""Tests that requesting multiple specific network IDs is OK. This test
short-circuits on a FlavorNotFound error.
"""
self.useFixture(nova_fixtures.AllServicesCurrent())
ex = self.assertRaises(
webob.exc.HTTPBadRequest, self._create_server,
[{'uuid': 'e3b686a8-b91d-4a61-a3fc-1b74bb619ddb'},
@ -4352,6 +4354,7 @@ class ServersPolicyEnforcementV21(test.NoDBTestCase):
def setUp(self):
super(ServersPolicyEnforcementV21, self).setUp()
self.useFixture(nova_fixtures.AllServicesCurrent())
ext_info = extension_info.LoadedExtensionInfo()
ext_info.extensions.update({'os-networks': 'fake'})
self.controller = servers.ServersController(extension_info=ext_info)