From de89b2d83faed631d00ee3814ba1d7bdbb3cdf1b Mon Sep 17 00:00:00 2001 From: Stephen Finucane Date: Mon, 2 Sep 2019 15:03:46 +0100 Subject: [PATCH] libvirt: Make scheduler filters customizable Most of the libvirt functional tests need at least the 'NUMATopologyFilter' scheduler filter enabled. Provide a mechanism to enable this, adding the filter to the real-time tests where it was previously missing. Change-Id: Id51ed2304140754a1eef402d558123b5e6bab9c8 Signed-off-by: Stephen Finucane --- nova/tests/functional/libvirt/base.py | 19 +++++++++++++++++-- .../functional/libvirt/test_numa_servers.py | 10 ++-------- .../libvirt/test_pci_sriov_servers.py | 14 ++------------ .../functional/libvirt/test_rt_servers.py | 2 ++ 4 files changed, 23 insertions(+), 22 deletions(-) diff --git a/nova/tests/functional/libvirt/base.py b/nova/tests/functional/libvirt/base.py index 21a8412a2cfd..0b2cb9fadf77 100644 --- a/nova/tests/functional/libvirt/base.py +++ b/nova/tests/functional/libvirt/base.py @@ -14,12 +14,13 @@ # under the License. import copy -import fixtures import io + +import fixtures import mock +from nova import conf from nova.objects import fields as obj_fields - from nova.tests import fixtures as nova_fixtures from nova.tests.functional import fixtures as func_fixtures from nova.tests.functional import test_servers as base @@ -27,8 +28,13 @@ from nova.tests.unit.virt.libvirt import fake_imagebackend from nova.tests.unit.virt.libvirt import fakelibvirt +CONF = conf.CONF + + class ServersTestBase(base.ServersTestBase): + ADDITIONAL_FILTERS = [] + def setUp(self): super(ServersTestBase, self).setUp() @@ -80,6 +86,15 @@ class ServersTestBase(base.ServersTestBase): # service in the test self.flags(compute_driver='libvirt.LibvirtDriver') + def _setup_scheduler_service(self): + enabled_filters = CONF.filter_scheduler.enabled_filters + enabled_filters += self.ADDITIONAL_FILTERS + + self.flags(driver='filter_scheduler', group='scheduler') + self.flags(enabled_filters=enabled_filters, group='filter_scheduler') + + return self.start_service('scheduler') + def _get_connection(self, host_info, pci_info=None, libvirt_version=fakelibvirt.FAKE_LIBVIRT_VERSION, mdev_info=None): diff --git a/nova/tests/functional/libvirt/test_numa_servers.py b/nova/tests/functional/libvirt/test_numa_servers.py index b8e0750f178b..e6cba0441732 100644 --- a/nova/tests/functional/libvirt/test_numa_servers.py +++ b/nova/tests/functional/libvirt/test_numa_servers.py @@ -33,6 +33,8 @@ LOG = logging.getLogger(__name__) class NUMAServersTestBase(base.ServersTestBase): + ADDITIONAL_FILTERS = ['NUMATopologyFilter'] + def setUp(self): super(NUMAServersTestBase, self).setUp() @@ -47,14 +49,6 @@ class NUMAServersTestBase(base.ServersTestBase): self.mock_filter = _p.start() self.addCleanup(_p.stop) - def _setup_scheduler_service(self): - # Enable the 'NUMATopologyFilter' - self.flags(driver='filter_scheduler', group='scheduler') - self.flags(enabled_filters=CONF.filter_scheduler.enabled_filters + - ['NUMATopologyFilter'], - group='filter_scheduler') - return self.start_service('scheduler') - class NUMAServersTest(NUMAServersTestBase): diff --git a/nova/tests/functional/libvirt/test_pci_sriov_servers.py b/nova/tests/functional/libvirt/test_pci_sriov_servers.py index 3d1ed4a86c1d..13cbec5b2b7b 100644 --- a/nova/tests/functional/libvirt/test_pci_sriov_servers.py +++ b/nova/tests/functional/libvirt/test_pci_sriov_servers.py @@ -15,7 +15,6 @@ import fixtures import mock -from oslo_config import cfg from oslo_log import log as logging from oslo_serialization import jsonutils @@ -24,12 +23,13 @@ from nova.tests.functional.libvirt import base from nova.tests.unit.virt.libvirt import fakelibvirt -CONF = cfg.CONF LOG = logging.getLogger(__name__) class _PCIServersTestBase(base.ServersTestBase): + ADDITIONAL_FILTERS = ['NUMATopologyFilter', 'PciPassthroughFilter'] + def setUp(self): self.flags(passthrough_whitelist=self.PCI_PASSTHROUGH_WHITELIST, alias=self.PCI_ALIAS, @@ -49,16 +49,6 @@ class _PCIServersTestBase(base.ServersTestBase): '.PciPassthroughFilter.host_passes', side_effect=host_pass_mock)).mock - def _setup_scheduler_service(self): - # Enable the 'NUMATopologyFilter', 'PciPassthroughFilter' - enabled_filters = CONF.filter_scheduler.enabled_filters + [ - 'NUMATopologyFilter', 'PciPassthroughFilter'] - - self.flags(driver='filter_scheduler', group='scheduler') - self.flags(enabled_filters=enabled_filters, group='filter_scheduler') - - return self.start_service('scheduler') - def _run_build_test(self, flavor_id, end_status='ACTIVE'): if not self.compute_started: diff --git a/nova/tests/functional/libvirt/test_rt_servers.py b/nova/tests/functional/libvirt/test_rt_servers.py index 14664bf88f27..c828fdb57ceb 100644 --- a/nova/tests/functional/libvirt/test_rt_servers.py +++ b/nova/tests/functional/libvirt/test_rt_servers.py @@ -20,6 +20,8 @@ from nova.tests.unit.virt.libvirt import fakelibvirt class RealTimeServersTest(base.ServersTestBase): + ADDITIONAL_FILTERS = ['NUMATopologyFilter'] + def setUp(self): super(RealTimeServersTest, self).setUp() self.flags(sysinfo_serial='none', group='libvirt')