diff --git a/nova/test.py b/nova/test.py index 335bb759dd45..eca3e2c151f0 100644 --- a/nova/test.py +++ b/nova/test.py @@ -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 diff --git a/nova/tests/functional/test_service.py b/nova/tests/functional/test_service.py index 9ffab96da3fd..a3cdbee5d99f 100644 --- a/nova/tests/functional/test_service.py +++ b/nova/tests/functional/test_service.py @@ -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')