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:
Julien Le Jeune
2025-10-06 09:40:12 +02:00
parent cc742602bc
commit 38d1b14170
2 changed files with 15 additions and 4 deletions

View File

@@ -468,6 +468,8 @@ class TestCase(base.BaseTestCase):
ctxt = context.get_context()
cell_name = cell_name or CELL1_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:
# NOTE(gibi): If the HostMapping does not exists then this is
# the first start of the service so we create the mapping.
@@ -476,8 +478,19 @@ class TestCase(base.BaseTestCase):
cell_mapping=cell)
hm.create()
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.
self._service_fixture_count[name] += 1

View File

@@ -51,7 +51,6 @@ class ServiceTestCase(test.TestCase,
"""Tests that the cell cache for database transaction context managers
is cleared after a service reset (example scenario: SIGHUP).
"""
self.assertFalse(nova_context.CELL_CACHE)
server_req = self._build_server()
server = self.api.post_server({'server': server_req})
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
a SIGTERM and the parent process forks child process workers).
"""
self.assertFalse(nova_context.CELL_CACHE)
server_req = self._build_server()
server = self.api.post_server({'server': server_req})
self._wait_for_state_change(server, 'ACTIVE')