From d79f366cf56a73ccc0cf934e0423ae405c17365d Mon Sep 17 00:00:00 2001 From: Artom Lifshitz Date: Tue, 9 Mar 2021 13:49:09 -0500 Subject: [PATCH] fakelibvirt: make kB_mem default not laughable Previously, the default for kB_mem was 2048. That's 2MB of RAM. Change this to 16GB, and cleanup tests that were forced to explicitly set sane value by removing the kB_mem argument. In cases where tests were using the default CPU configuration, arguments to HostInfo are removed entirely. Change-Id: I1c97776583f9e43c4a284fb9ef59bd6293730a28 --- nova/tests/functional/libvirt/base.py | 5 +- .../libvirt/test_numa_live_migration.py | 22 ++----- .../functional/libvirt/test_numa_servers.py | 57 +++++++------------ .../libvirt/test_pci_sriov_servers.py | 3 +- nova/tests/functional/libvirt/test_vpmem.py | 3 +- .../regressions/test_bug_1888395.py | 6 +- .../regressions/test_bug_1899649.py | 3 +- nova/tests/unit/virt/libvirt/fakelibvirt.py | 2 +- .../unit/virt/libvirt/test_fakelibvirt.py | 2 +- 9 files changed, 33 insertions(+), 70 deletions(-) diff --git a/nova/tests/functional/libvirt/base.py b/nova/tests/functional/libvirt/base.py index 54fc59252cbd..d40995cea894 100644 --- a/nova/tests/functional/libvirt/base.py +++ b/nova/tests/functional/libvirt/base.py @@ -18,7 +18,6 @@ import io import fixtures import mock -from oslo_utils import units from nova import conf from nova.tests import fixtures as nova_fixtures @@ -91,9 +90,7 @@ class ServersTestBase(integrated_helpers._IntegratedTestBase): ): if not host_info: host_info = fakelibvirt.HostInfo( - cpu_nodes=2, cpu_sockets=1, cpu_cores=2, cpu_threads=2, - kB_mem=(16 * units.Gi) // units.Ki, - ) + cpu_nodes=2, cpu_sockets=1, cpu_cores=2, cpu_threads=2) # sanity check self.assertGreater(16, host_info.cpus, diff --git a/nova/tests/functional/libvirt/test_numa_live_migration.py b/nova/tests/functional/libvirt/test_numa_live_migration.py index f1cbbe56cc87..0d88c9b7ea7e 100644 --- a/nova/tests/functional/libvirt/test_numa_live_migration.py +++ b/nova/tests/functional/libvirt/test_numa_live_migration.py @@ -118,13 +118,11 @@ class NUMALiveMigrationPositiveBase(NUMALiveMigrationBase): self.start_compute( hostname='host_a', host_info=fakelibvirt.HostInfo( - cpu_nodes=1, cpu_sockets=1, cpu_cores=4, cpu_threads=1, - kB_mem=10740000)) + cpu_nodes=1, cpu_sockets=1, cpu_cores=4, cpu_threads=1)) self.start_compute( hostname='host_b', host_info=fakelibvirt.HostInfo( - cpu_nodes=1, cpu_sockets=1, cpu_cores=4, cpu_threads=1, - kB_mem=10740000)) + cpu_nodes=1, cpu_sockets=1, cpu_cores=4, cpu_threads=1)) # Create a 2-CPU flavor extra_spec = {'hw:cpu_policy': 'dedicated'} @@ -470,14 +468,10 @@ class NUMALiveMigrationLegacyBase(NUMALiveMigrationPositiveBase): def _test(self, pin_source, pin_cond, expect_success=True): self.start_compute( hostname='source', - host_info=fakelibvirt.HostInfo( - cpu_nodes=1, cpu_sockets=1, cpu_cores=2, cpu_threads=1, - kB_mem=10740000)) + host_info=fakelibvirt.HostInfo()) self.start_compute( hostname='dest', - host_info=fakelibvirt.HostInfo( - cpu_nodes=1, cpu_sockets=1, cpu_cores=2, cpu_threads=1, - kB_mem=10740000)) + host_info=fakelibvirt.HostInfo()) ctxt = context.get_admin_context() src_mgr = self.computes['source'].manager @@ -597,13 +591,11 @@ class NUMALiveMigrationNegativeTests(NUMALiveMigrationBase): self.start_compute( hostname='host_a', host_info=fakelibvirt.HostInfo( - cpu_nodes=1, cpu_sockets=1, cpu_cores=3, cpu_threads=1, - kB_mem=10740000)) + cpu_nodes=1, cpu_sockets=1, cpu_cores=3, cpu_threads=1)) self.start_compute( hostname='host_b', host_info=fakelibvirt.HostInfo( - cpu_nodes=2, cpu_sockets=1, cpu_cores=2, cpu_threads=1, - kB_mem=10740000)) + cpu_nodes=2, cpu_sockets=1, cpu_cores=2, cpu_threads=1)) extra_spec = {'hw:numa_nodes': 1, 'hw:cpu_policy': 'dedicated'} @@ -638,14 +630,12 @@ class NUMALiveMigrationNegativeTests(NUMALiveMigrationBase): self.start_compute( hostname='host_a', host_info=fakelibvirt.HostInfo( - cpu_nodes=1, cpu_sockets=1, cpu_cores=2, cpu_threads=1, kB_mem=1024000, mempages={ 0: fakelibvirt.create_mempages([(4, 256000), (1024, 1000)]) })) self.start_compute( hostname='host_b', host_info=fakelibvirt.HostInfo( - cpu_nodes=1, cpu_sockets=1, cpu_cores=2, cpu_threads=1, kB_mem=1024000, mempages={ 0: fakelibvirt.create_mempages([(4, 256000), (2048, 500)]), })) diff --git a/nova/tests/functional/libvirt/test_numa_servers.py b/nova/tests/functional/libvirt/test_numa_servers.py index 1e29c1ae9efd..65f07e9c8a8a 100644 --- a/nova/tests/functional/libvirt/test_numa_servers.py +++ b/nova/tests/functional/libvirt/test_numa_servers.py @@ -105,8 +105,7 @@ class NUMAServersTest(NUMAServersTestBase): """ host_info = fakelibvirt.HostInfo(cpu_nodes=2, cpu_sockets=1, - cpu_cores=2, cpu_threads=2, - kB_mem=15740000) + cpu_cores=2, cpu_threads=2) self.start_compute(host_info=host_info, hostname='compute1') extra_spec = {'hw:numa_nodes': '2'} @@ -128,8 +127,7 @@ class NUMAServersTest(NUMAServersTestBase): separate host NUMA node. """ - host_info = fakelibvirt.HostInfo(cpu_nodes=1, cpu_sockets=1, - cpu_cores=2, kB_mem=15740000) + host_info = fakelibvirt.HostInfo() self.start_compute(host_info=host_info, hostname='compute1') extra_spec = {'hw:numa_nodes': '2'} @@ -145,8 +143,7 @@ class NUMAServersTest(NUMAServersTestBase): """ host_info = fakelibvirt.HostInfo(cpu_nodes=1, cpu_sockets=2, - cpu_cores=2, cpu_threads=2, - kB_mem=(1024 * 1024 * 16)) # GB + cpu_cores=2, cpu_threads=2) # create 1024 * 2 MB huge pages, and allocate the rest of the 16 GB as # small pages for cell in host_info.numa_topology.cells: @@ -177,8 +174,7 @@ class NUMAServersTest(NUMAServersTestBase): """ host_info = fakelibvirt.HostInfo(cpu_nodes=1, cpu_sockets=2, - cpu_cores=2, cpu_threads=2, - kB_mem=(1024 * 1024 * 16)) # GB + cpu_cores=2, cpu_threads=2) self.start_compute(host_info=host_info, hostname='compute1') # create 512 * 2 MB huge pages, and allocate the rest of the 16 GB as @@ -207,8 +203,7 @@ class NUMAServersTest(NUMAServersTestBase): self.flags(vcpu_pin_set=None) host_info = fakelibvirt.HostInfo(cpu_nodes=1, cpu_sockets=1, - cpu_cores=5, cpu_threads=2, - kB_mem=15740000) + cpu_cores=5, cpu_threads=2) self.start_compute(host_info=host_info, hostname='compute1') extra_spec = { @@ -240,8 +235,7 @@ class NUMAServersTest(NUMAServersTestBase): self.flags(vcpu_pin_set=None) host_info = fakelibvirt.HostInfo( - cpu_nodes=2, cpu_sockets=1, cpu_cores=4, cpu_threads=1, - kB_mem=15740000) + cpu_nodes=2, cpu_sockets=1, cpu_cores=4, cpu_threads=1) self.start_compute(host_info=host_info, hostname='compute1') # sanity check the created host topology object; this is really just a @@ -297,8 +291,7 @@ class NUMAServersTest(NUMAServersTestBase): self.flags(vcpu_pin_set=None) host_info = fakelibvirt.HostInfo( - cpu_nodes=2, cpu_sockets=1, cpu_cores=4, cpu_threads=1, - kB_mem=15740000) + cpu_nodes=2, cpu_sockets=1, cpu_cores=4, cpu_threads=1) self.start_compute(host_info=host_info, hostname='compute1') # sanity check the created host topology object; this is really just a @@ -338,8 +331,7 @@ class NUMAServersTest(NUMAServersTestBase): self.flags(vcpu_pin_set='0-7') host_info = fakelibvirt.HostInfo(cpu_nodes=2, cpu_sockets=1, - cpu_cores=2, cpu_threads=2, - kB_mem=15740000) + cpu_cores=2, cpu_threads=2) self.start_compute(host_info=host_info, hostname='compute1') extra_spec = { @@ -367,9 +359,7 @@ class NUMAServersTest(NUMAServersTestBase): # host has hyperthreads, which means we're going to end up consuming # $flavor.vcpu hosts cores plus the thread sibling(s) for each core host_info = fakelibvirt.HostInfo( - cpu_nodes=1, cpu_sockets=1, cpu_cores=2, cpu_threads=2, - kB_mem=(1024 * 1024 * 16), # GB - ) + cpu_nodes=1, cpu_sockets=1, cpu_cores=2, cpu_threads=2) self.start_compute(host_info=host_info, hostname='compute1') extra_spec = { @@ -402,8 +392,7 @@ class NUMAServersTest(NUMAServersTestBase): self.flags(vcpu_pin_set=None) host_info = fakelibvirt.HostInfo(cpu_nodes=1, cpu_sockets=1, - cpu_cores=5, cpu_threads=2, - kB_mem=15740000) + cpu_cores=5, cpu_threads=2) self.start_compute(host_info=host_info, hostname='compute1') extra_spec = { @@ -423,8 +412,7 @@ class NUMAServersTest(NUMAServersTestBase): self.flags(vcpu_pin_set=None) host_info = fakelibvirt.HostInfo(cpu_nodes=2, cpu_sockets=1, - cpu_cores=2, cpu_threads=2, - kB_mem=15740000) + cpu_cores=2, cpu_threads=2) self.start_compute(host_info=host_info, hostname='compute1') extra_spec = { @@ -454,9 +442,7 @@ class NUMAServersTest(NUMAServersTestBase): # host has hyperthreads, which means it should be rejected host_info = fakelibvirt.HostInfo( - cpu_nodes=2, cpu_sockets=1, cpu_cores=2, cpu_threads=2, - kB_mem=(1024 * 1024 * 16), # GB - ) + cpu_nodes=2, cpu_sockets=1, cpu_cores=2, cpu_threads=2) self.start_compute(host_info=host_info, hostname='compute1') extra_spec = { @@ -478,8 +464,7 @@ class NUMAServersTest(NUMAServersTestBase): self.flags(vcpu_pin_set=None) host_info = fakelibvirt.HostInfo(cpu_nodes=2, cpu_sockets=1, - cpu_cores=2, cpu_threads=2, - kB_mem=15740000) + cpu_cores=2, cpu_threads=2) self.start_compute(host_info=host_info, hostname='compute1') extra_spec = {'resources:PCPU': '2'} @@ -506,8 +491,7 @@ class NUMAServersTest(NUMAServersTestBase): self.flags(vcpu_pin_set=None) host_info = fakelibvirt.HostInfo(cpu_nodes=1, cpu_sockets=1, - cpu_cores=5, cpu_threads=2, - kB_mem=15740000) + cpu_cores=5, cpu_threads=2) self.start_compute(host_info=host_info, hostname='compute1') extra_spec = {'resources:PCPU': 2} @@ -526,8 +510,7 @@ class NUMAServersTest(NUMAServersTestBase): self.flags(vcpu_pin_set=None) host_info = fakelibvirt.HostInfo(cpu_nodes=2, cpu_sockets=1, - cpu_cores=2, cpu_threads=2, - kB_mem=15740000) + cpu_cores=2, cpu_threads=2) self.start_compute(host_info=host_info, hostname='compute1') extra_spec = {'resources:PCPU': '2'} @@ -575,8 +558,7 @@ class NUMAServersTest(NUMAServersTestBase): self.flags(vif_plugging_timeout=0) host_info = fakelibvirt.HostInfo(cpu_nodes=2, cpu_sockets=1, - cpu_cores=2, cpu_threads=2, - kB_mem=15740000) + cpu_cores=2, cpu_threads=2) # Start services self.start_compute(host_info=host_info, hostname='test_compute0') @@ -1300,7 +1282,7 @@ class NUMAServersRebuildTests(NUMAServersTestBase): # the free space to ensure the numa topology filter does not # eliminate the host. host_info = fakelibvirt.HostInfo(cpu_nodes=1, cpu_sockets=1, - cpu_cores=4, kB_mem=15740000) + cpu_cores=4) self.start_compute(host_info=host_info) server = self._create_active_server( @@ -1324,8 +1306,7 @@ class NUMAServersRebuildTests(NUMAServersTestBase): # cpu_cores is set to 2 to ensure that we have enough space # to boot the vm but not enough space to rebuild # by doubling the resource use during scheduling. - host_info = fakelibvirt.HostInfo( - cpu_nodes=1, cpu_sockets=1, cpu_cores=2, kB_mem=15740000) + host_info = fakelibvirt.HostInfo() self.start_compute(host_info=host_info) server = self._create_active_server( @@ -1344,7 +1325,7 @@ class NUMAServersRebuildTests(NUMAServersTestBase): flavor_id = self._create_flavor(extra_spec=extra_spec) host_info = fakelibvirt.HostInfo( - cpu_nodes=2, cpu_sockets=1, cpu_cores=4, kB_mem=15740000) + cpu_nodes=2, cpu_sockets=1, cpu_cores=4) self.start_compute(host_info=host_info) server = self._create_active_server( diff --git a/nova/tests/functional/libvirt/test_pci_sriov_servers.py b/nova/tests/functional/libvirt/test_pci_sriov_servers.py index 7301868ef759..95b23f2f1c3c 100644 --- a/nova/tests/functional/libvirt/test_pci_sriov_servers.py +++ b/nova/tests/functional/libvirt/test_pci_sriov_servers.py @@ -615,8 +615,7 @@ class SRIOVAttachDetachTest(_PCIServersTestBase): # second port and asserts that it fails as no free PCI device left on # the host. host_info = fakelibvirt.HostInfo(cpu_nodes=2, cpu_sockets=1, - cpu_cores=2, cpu_threads=2, - kB_mem=15740000) + cpu_cores=2, cpu_threads=2) pci_info = fakelibvirt.HostPCIDevicesInfo(num_pfs=1, num_vfs=1) fake_connection = self._get_connection(host_info, pci_info) self.mock_conn.return_value = fake_connection diff --git a/nova/tests/functional/libvirt/test_vpmem.py b/nova/tests/functional/libvirt/test_vpmem.py index 32f23cefd316..7f2a0d39dea6 100644 --- a/nova/tests/functional/libvirt/test_vpmem.py +++ b/nova/tests/functional/libvirt/test_vpmem.py @@ -96,8 +96,7 @@ class VPMEMTestBase(integrated_helpers.LibvirtProviderUsageBaseTestCase): fake_connection = self._get_connection( # Need a host to support creating more servers with vpmems host_info=fakelibvirt.HostInfo(cpu_nodes=2, cpu_sockets=1, - cpu_cores=2, cpu_threads=2, - kB_mem=15740000), + cpu_cores=2, cpu_threads=2), hostname=hostname) self.mock_conn.return_value = fake_connection compute = self._start_compute(host=hostname) diff --git a/nova/tests/functional/regressions/test_bug_1888395.py b/nova/tests/functional/regressions/test_bug_1888395.py index f12ebdcbf2d2..b8f1b94fbac2 100644 --- a/nova/tests/functional/regressions/test_bug_1888395.py +++ b/nova/tests/functional/regressions/test_bug_1888395.py @@ -64,13 +64,11 @@ class TestLiveMigrationWithoutMultiplePortBindings( self.start_compute( hostname='start_host', host_info=fakelibvirt.HostInfo( - cpu_nodes=1, cpu_sockets=1, cpu_cores=4, cpu_threads=2, - kB_mem=10740000)) + cpu_nodes=1, cpu_sockets=1, cpu_cores=4, cpu_threads=2)) self.start_compute( hostname='end_host', host_info=fakelibvirt.HostInfo( - cpu_nodes=1, cpu_sockets=1, cpu_cores=4, cpu_threads=2, - kB_mem=10740000)) + cpu_nodes=1, cpu_sockets=1, cpu_cores=4, cpu_threads=2)) self.ctxt = context.get_admin_context() # TODO(sean-k-mooney): remove this when it is part of ServersTestBase diff --git a/nova/tests/functional/regressions/test_bug_1899649.py b/nova/tests/functional/regressions/test_bug_1899649.py index be75ea947f2d..8cc583e980de 100644 --- a/nova/tests/functional/regressions/test_bug_1899649.py +++ b/nova/tests/functional/regressions/test_bug_1899649.py @@ -39,8 +39,7 @@ class TestVolAttachmentsAfterFailureToScheduleOrBuild(base.ServersTestBase): super().setUp() # Launch a single libvirt based compute service with a single NUMA node - host_info = fakelibvirt.HostInfo( - cpu_nodes=1, cpu_sockets=1, cpu_cores=2, kB_mem=15740000) + host_info = fakelibvirt.HostInfo() self.start_compute(host_info=host_info, hostname='compute1') # Use a flavor requesting 2 NUMA nodes that we know will always fail diff --git a/nova/tests/unit/virt/libvirt/fakelibvirt.py b/nova/tests/unit/virt/libvirt/fakelibvirt.py index 878f7ebd9e36..9f55bf7f1d76 100644 --- a/nova/tests/unit/virt/libvirt/fakelibvirt.py +++ b/nova/tests/unit/virt/libvirt/fakelibvirt.py @@ -578,7 +578,7 @@ class HostMdevDevicesInfo(object): class HostInfo(object): def __init__(self, cpu_nodes=1, cpu_sockets=1, cpu_cores=2, cpu_threads=1, - kB_mem=4096, mempages=None): + kB_mem=16780000, mempages=None): """Create a new Host Info object :param cpu_nodes: (int) the number of NUMA cell, 1 for unusual diff --git a/nova/tests/unit/virt/libvirt/test_fakelibvirt.py b/nova/tests/unit/virt/libvirt/test_fakelibvirt.py index 126b42c4efcf..1d1303c1ee1b 100644 --- a/nova/tests/unit/virt/libvirt/test_fakelibvirt.py +++ b/nova/tests/unit/virt/libvirt/test_fakelibvirt.py @@ -101,7 +101,7 @@ class FakeLibvirtTests(test.NoDBTestCase): obj_fields.Architecture.X86_64)) self.assertLessEqual(1024, res[1], "Memory unusually high.") - self.assertGreaterEqual(16384, res[1], "Memory unusually low.") + self.assertGreaterEqual(17000000, res[1], "Memory unusually low.") self.assertLessEqual(1, res[2], "Active CPU count unusually high.") self.assertGreaterEqual(32, res[2], "Active CPU count unusually low.") self.assertLessEqual(800, res[3], "CPU speed unusually high.")