From 4df3f17853c2be1bf4533dfff0f7298e2cf1b8d0 Mon Sep 17 00:00:00 2001 From: Matt Riedemann Date: Tue, 5 Mar 2019 19:42:07 -0500 Subject: [PATCH] Fix ProviderUsageBaseTestCase._run_periodics for multi-cell The _run_periodics() method is using a non-targeted context when running the update_available_resource method on all computes created in the test. For tests that use multiple cells where the compute services/nodes are created in multiple cells, the periodic running on the non-cell1 services would not find the ComputeNode because the context is not targeted. By default, the CellDatabase fixture is targeted at cell1 in the base TestCase._setup_cells() method, so when querying the database without a targeted context, it will look in cell1 which could be wrong if you're trying to update resources in cell2. This fixes the issue by simply getting the CellMapping per host and targeting the context before calling update_available_resource. Change-Id: Ieeac3bdb82a23179ff6c652b2e9e05a3f6bc9032 --- nova/tests/functional/integrated_helpers.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/nova/tests/functional/integrated_helpers.py b/nova/tests/functional/integrated_helpers.py index 0595ee3535e8..416dbfbc078a 100644 --- a/nova/tests/functional/integrated_helpers.py +++ b/nova/tests/functional/integrated_helpers.py @@ -768,10 +768,13 @@ class ProviderUsageBaseTestCase(test.TestCase, InstanceHelperMixin): """ ctx = context.get_admin_context() - for compute in self.computes.values(): - LOG.info('Running periodic for compute (%s)', - compute.manager.host) - compute.manager.update_available_resource(ctx) + for host, compute in self.computes.items(): + LOG.info('Running periodic for compute (%s)', host) + # Make sure the context is targeted to the proper cell database + # for multi-cell tests. + with context.target_cell( + ctx, self.host_mappings[host].cell_mapping) as cctxt: + compute.manager.update_available_resource(cctxt) LOG.info('Finished with periodics') def _move_and_check_allocations(self, server, request, old_flavor,