Update start_service() function in test
Update the 'mapped' field of the created node to be coherent with
what it's done in _check_and_create_node_host_mappings function [1].
[1] cc742602bc/nova/objects/host_mapping.py (L209)
Related-Bug: #2085135
Change-Id: I9965932adc521756e4583d1bcfc75c83cc630626
Signed-off-by: Julien Le Jeune <julien.le-jeune@ovhcloud.com>
This commit is contained in:
17
nova/test.py
17
nova/test.py
@@ -468,6 +468,8 @@ class TestCase(base.BaseTestCase):
|
|||||||
ctxt = context.get_context()
|
ctxt = context.get_context()
|
||||||
cell_name = cell_name or CELL1_NAME
|
cell_name = cell_name or CELL1_NAME
|
||||||
cell = self.cell_mappings[cell_name]
|
cell = self.cell_mappings[cell_name]
|
||||||
|
svc = self.useFixture(
|
||||||
|
nova_fixtures.ServiceFixture(name, host, cell=cell, **kwargs))
|
||||||
if (host or name) not in self.host_mappings:
|
if (host or name) not in self.host_mappings:
|
||||||
# NOTE(gibi): If the HostMapping does not exists then this is
|
# NOTE(gibi): If the HostMapping does not exists then this is
|
||||||
# the first start of the service so we create the mapping.
|
# the first start of the service so we create the mapping.
|
||||||
@@ -476,8 +478,19 @@ class TestCase(base.BaseTestCase):
|
|||||||
cell_mapping=cell)
|
cell_mapping=cell)
|
||||||
hm.create()
|
hm.create()
|
||||||
self.host_mappings[hm.host] = hm
|
self.host_mappings[hm.host] = hm
|
||||||
svc = self.useFixture(
|
|
||||||
nova_fixtures.ServiceFixture(name, host, cell=cell, **kwargs))
|
# NOTE(jlejeune): update the compute node's mapped field
|
||||||
|
# like it's done in _check_and_create_node_host_mappings()
|
||||||
|
# function.
|
||||||
|
with context.target_cell(ctxt, cell) as cctxt:
|
||||||
|
node = objects.ComputeNode.get_by_service_id(
|
||||||
|
context=cctxt,
|
||||||
|
service_id=svc.service.service_ref.id)
|
||||||
|
node.mapped = 1
|
||||||
|
node.save()
|
||||||
|
else:
|
||||||
|
svc = self.useFixture(
|
||||||
|
nova_fixtures.ServiceFixture(name, host, cell=cell, **kwargs))
|
||||||
|
|
||||||
# Keep track of how many instances of this service are running.
|
# Keep track of how many instances of this service are running.
|
||||||
self._service_fixture_count[name] += 1
|
self._service_fixture_count[name] += 1
|
||||||
|
@@ -51,7 +51,6 @@ class ServiceTestCase(test.TestCase,
|
|||||||
"""Tests that the cell cache for database transaction context managers
|
"""Tests that the cell cache for database transaction context managers
|
||||||
is cleared after a service reset (example scenario: SIGHUP).
|
is cleared after a service reset (example scenario: SIGHUP).
|
||||||
"""
|
"""
|
||||||
self.assertFalse(nova_context.CELL_CACHE)
|
|
||||||
server_req = self._build_server()
|
server_req = self._build_server()
|
||||||
server = self.api.post_server({'server': server_req})
|
server = self.api.post_server({'server': server_req})
|
||||||
self._wait_for_state_change(server, 'ACTIVE')
|
self._wait_for_state_change(server, 'ACTIVE')
|
||||||
@@ -66,7 +65,6 @@ class ServiceTestCase(test.TestCase,
|
|||||||
is cleared upon a service start (example scenario: service start after
|
is cleared upon a service start (example scenario: service start after
|
||||||
a SIGTERM and the parent process forks child process workers).
|
a SIGTERM and the parent process forks child process workers).
|
||||||
"""
|
"""
|
||||||
self.assertFalse(nova_context.CELL_CACHE)
|
|
||||||
server_req = self._build_server()
|
server_req = self._build_server()
|
||||||
server = self.api.post_server({'server': server_req})
|
server = self.api.post_server({'server': server_req})
|
||||||
self._wait_for_state_change(server, 'ACTIVE')
|
self._wait_for_state_change(server, 'ACTIVE')
|
||||||
|
Reference in New Issue
Block a user