Fixup patch for stable-compute-uuid series
Minor cleanups from feedback on earlier patches. Related to blueprint stable-compute-uuid Change-Id: I00505f1df47b46ed36645c781354258e255f0dcc
This commit is contained in:
parent
23c5f3d585
commit
f41ee33e01
@ -66,7 +66,6 @@ from nova.tests import fixtures as nova_fixtures
|
|||||||
from nova.tests.unit import matchers
|
from nova.tests.unit import matchers
|
||||||
from nova import utils
|
from nova import utils
|
||||||
from nova.virt import images
|
from nova.virt import images
|
||||||
from nova.virt import node
|
|
||||||
|
|
||||||
CONF = cfg.CONF
|
CONF = cfg.CONF
|
||||||
|
|
||||||
@ -302,7 +301,6 @@ class TestCase(base.BaseTestCase):
|
|||||||
|
|
||||||
# Reset our local node uuid cache (and avoid writing to the
|
# Reset our local node uuid cache (and avoid writing to the
|
||||||
# local filesystem when we generate a new one).
|
# local filesystem when we generate a new one).
|
||||||
node.LOCAL_NODE_UUID = None
|
|
||||||
self.useFixture(nova_fixtures.ComputeNodeIdFixture())
|
self.useFixture(nova_fixtures.ComputeNodeIdFixture())
|
||||||
|
|
||||||
def _setup_cells(self):
|
def _setup_cells(self):
|
||||||
|
2
nova/tests/fixtures/nova.py
vendored
2
nova/tests/fixtures/nova.py
vendored
@ -65,6 +65,7 @@ from nova.scheduler import weights
|
|||||||
from nova import service
|
from nova import service
|
||||||
from nova.tests.functional.api import client
|
from nova.tests.functional.api import client
|
||||||
from nova import utils
|
from nova import utils
|
||||||
|
from nova.virt import node
|
||||||
|
|
||||||
CONF = cfg.CONF
|
CONF = cfg.CONF
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
@ -1855,6 +1856,7 @@ class ComputeNodeIdFixture(fixtures.Fixture):
|
|||||||
def setUp(self):
|
def setUp(self):
|
||||||
super().setUp()
|
super().setUp()
|
||||||
|
|
||||||
|
node.LOCAL_NODE_UUID = None
|
||||||
self.useFixture(fixtures.MockPatch(
|
self.useFixture(fixtures.MockPatch(
|
||||||
'nova.virt.node.read_local_node_uuid',
|
'nova.virt.node.read_local_node_uuid',
|
||||||
lambda: None))
|
lambda: None))
|
||||||
|
@ -1230,8 +1230,6 @@ class _IntegratedTestBase(test.TestCase, PlacementInstanceHelperMixin):
|
|||||||
self.glance = self.useFixture(nova_fixtures.GlanceFixture(self))
|
self.glance = self.useFixture(nova_fixtures.GlanceFixture(self))
|
||||||
self.policy = self.useFixture(nova_fixtures.RealPolicyFixture())
|
self.policy = self.useFixture(nova_fixtures.RealPolicyFixture())
|
||||||
|
|
||||||
self.useFixture(nova_fixtures.ComputeNodeIdFixture())
|
|
||||||
|
|
||||||
self.notifier = self.useFixture(
|
self.notifier = self.useFixture(
|
||||||
nova_fixtures.NotificationFixture(self))
|
nova_fixtures.NotificationFixture(self))
|
||||||
|
|
||||||
@ -1303,8 +1301,6 @@ class ProviderUsageBaseTestCase(test.TestCase, PlacementInstanceHelperMixin):
|
|||||||
self.placement = self.useFixture(func_fixtures.PlacementFixture()).api
|
self.placement = self.useFixture(func_fixtures.PlacementFixture()).api
|
||||||
self.useFixture(nova_fixtures.AllServicesCurrent())
|
self.useFixture(nova_fixtures.AllServicesCurrent())
|
||||||
|
|
||||||
self.useFixture(nova_fixtures.ComputeNodeIdFixture())
|
|
||||||
|
|
||||||
self.notifier = self.useFixture(
|
self.notifier = self.useFixture(
|
||||||
nova_fixtures.NotificationFixture(self))
|
nova_fixtures.NotificationFixture(self))
|
||||||
|
|
||||||
|
@ -72,7 +72,8 @@ class TestNodeIdentity(testtools.TestCase):
|
|||||||
|
|
||||||
def test_generate_local_node_uuid_unexpected_write_fail(self):
|
def test_generate_local_node_uuid_unexpected_write_fail(self):
|
||||||
with mock.patch('builtins.open') as mock_open:
|
with mock.patch('builtins.open') as mock_open:
|
||||||
mock_open.return_value.write.side_effect = IndexError()
|
mock_write = mock_open.return_value.__enter__.return_value.write
|
||||||
|
mock_write.side_effect = IndexError()
|
||||||
e = self.assertRaises(exception.InvalidNodeConfiguration,
|
e = self.assertRaises(exception.InvalidNodeConfiguration,
|
||||||
node.write_local_node_uuid, 'foo')
|
node.write_local_node_uuid, 'foo')
|
||||||
self.assertIn('Unable to write uuid to %s' % (
|
self.assertIn('Unable to write uuid to %s' % (
|
||||||
|
@ -35,7 +35,8 @@ def write_local_node_uuid(node_uuid):
|
|||||||
# Try to create the identity file and write our uuid into it. Fail
|
# Try to create the identity file and write our uuid into it. Fail
|
||||||
# if the file exists (since it shouldn't if we made it here).
|
# if the file exists (since it shouldn't if we made it here).
|
||||||
try:
|
try:
|
||||||
open(fn, 'x').write(node_uuid)
|
with open(fn, 'x') as f:
|
||||||
|
f.write(node_uuid)
|
||||||
except FileExistsError:
|
except FileExistsError:
|
||||||
# If the file exists, we must either fail or re-survey all the
|
# If the file exists, we must either fail or re-survey all the
|
||||||
# potential files. If we just read and return it, it could be
|
# potential files. If we just read and return it, it could be
|
||||||
|
Loading…
x
Reference in New Issue
Block a user