Public bug reported: The nova processes for functional tests are started by the 'start_service' method of the 'TestCase' class in nova/test.py. A cell can be specified to run a process in the cell.
https://github.com/openstack/nova/blob/00b19c73cfc72a79ab5ae4830a25dd53476a3b08/nova/test.py#L409-L427 ------------------------------------------------------------------------------- def start_service(self, name, host=None, **kwargs): if name == 'compute' and self.USES_DB: # NOTE(danms): We need to create the HostMapping first, because # otherwise we'll fail to update the scheduler while running # the compute node startup routines below. ctxt = context.get_context() cell = self.cell_mappings[kwargs.pop('cell', CELL1_NAME)] <=== hm = objects.HostMapping(context=ctxt, host=host or name, cell_mapping=cell) <=== hm.create() self.host_mappings[hm.host] = hm if host is not None: # Make sure that CONF.host is relevant to the right hostname self.useFixture(nova_fixtures.ConfPatcher(host=host)) svc = self.useFixture( nova_fixtures.ServiceFixture(name, host, **kwargs)) return svc.service ------------------------------------------------------------------------------- But multiple cells are not considered in ServiceFixture. So all compute nodes are registered to only one cell (cell1) database regardless of their cells. The nova.context.get_admin_context() is called in the inside of self.service.start(). It returns a context that is not aware of its cell. So the compute node is registered to only one cell (cell1) database regardless of its cell. https://github.com/openstack/nova/blob/00b19c73cfc72a79ab5ae4830a25dd53476a3b08/nova/tests/fixtures.py#L65-L82 ------------------------------------------------------------------------------- class ServiceFixture(fixtures.Fixture): """Run a service as a test fixture.""" def __init__(self, name, host=None, **kwargs): name = name # If not otherwise specified, the host will default to the # name of the service. Some things like aggregates care that # this is stable. host = host or name kwargs.setdefault('host', host) kwargs.setdefault('binary', 'nova-%s' % name) self.kwargs = kwargs def setUp(self): super(ServiceFixture, self).setUp() self.service = service.Service.create(**self.kwargs) self.service.start() <=== self.addCleanup(self.service.kill) ------------------------------------------------------------------------------- Environment ----------- nova master (commit 00b19c73cfc72a79ab5ae4830a25dd53476a3b08) ** Affects: nova Importance: Undecided Assignee: Takashi NATSUME (natsume-takashi) Status: In Progress ** Tags: testing ** Changed in: nova Status: New => In Progress -- You received this bug notification because you are a member of Yahoo! Engineering Team, which is subscribed to OpenStack Compute (nova). https://bugs.launchpad.net/bugs/1759792 Title: [Testing] Compute nodes are registered to only one cell database regardless of their cells Status in OpenStack Compute (nova): In Progress Bug description: The nova processes for functional tests are started by the 'start_service' method of the 'TestCase' class in nova/test.py. A cell can be specified to run a process in the cell. https://github.com/openstack/nova/blob/00b19c73cfc72a79ab5ae4830a25dd53476a3b08/nova/test.py#L409-L427 ------------------------------------------------------------------------------- def start_service(self, name, host=None, **kwargs): if name == 'compute' and self.USES_DB: # NOTE(danms): We need to create the HostMapping first, because # otherwise we'll fail to update the scheduler while running # the compute node startup routines below. ctxt = context.get_context() cell = self.cell_mappings[kwargs.pop('cell', CELL1_NAME)] <=== hm = objects.HostMapping(context=ctxt, host=host or name, cell_mapping=cell) <=== hm.create() self.host_mappings[hm.host] = hm if host is not None: # Make sure that CONF.host is relevant to the right hostname self.useFixture(nova_fixtures.ConfPatcher(host=host)) svc = self.useFixture( nova_fixtures.ServiceFixture(name, host, **kwargs)) return svc.service ------------------------------------------------------------------------------- But multiple cells are not considered in ServiceFixture. So all compute nodes are registered to only one cell (cell1) database regardless of their cells. The nova.context.get_admin_context() is called in the inside of self.service.start(). It returns a context that is not aware of its cell. So the compute node is registered to only one cell (cell1) database regardless of its cell. https://github.com/openstack/nova/blob/00b19c73cfc72a79ab5ae4830a25dd53476a3b08/nova/tests/fixtures.py#L65-L82 ------------------------------------------------------------------------------- class ServiceFixture(fixtures.Fixture): """Run a service as a test fixture.""" def __init__(self, name, host=None, **kwargs): name = name # If not otherwise specified, the host will default to the # name of the service. Some things like aggregates care that # this is stable. host = host or name kwargs.setdefault('host', host) kwargs.setdefault('binary', 'nova-%s' % name) self.kwargs = kwargs def setUp(self): super(ServiceFixture, self).setUp() self.service = service.Service.create(**self.kwargs) self.service.start() <=== self.addCleanup(self.service.kill) ------------------------------------------------------------------------------- Environment ----------- nova master (commit 00b19c73cfc72a79ab5ae4830a25dd53476a3b08) To manage notifications about this bug go to: https://bugs.launchpad.net/nova/+bug/1759792/+subscriptions -- Mailing list: https://launchpad.net/~yahoo-eng-team Post to : [email protected] Unsubscribe : https://launchpad.net/~yahoo-eng-team More help : https://help.launchpad.net/ListHelp

