diff options
author | Artom Lifshitz <alifshit@redhat.com> | 2020-03-20 10:23:14 -0400 |
---|---|---|
committer | Artom Lifshitz <alifshit@redhat.com> | 2020-03-20 10:33:35 -0400 |
commit | 7f3a8957fcd132ec320602ad1c06a70383e4450b (patch) | |
tree | b0814ba795a5e167738ab4f526dcfc036bfb4ae1 /nova/tests/functional/libvirt/test_numa_servers.py | |
parent | 1ea255c15b7bf4b8495701aa7415b203027323c7 (diff) | |
download | nova-7f3a8957fcd132ec320602ad1c06a70383e4450b.tar.gz |
Increase code reuse in test_numa_servers
While working on I36dd64dc272ea1743995b3b696323a9431666489, it was
noticed that test_numa_server.py was needlessly duplicating code
around compute service starup and restarting. This patch fixes this.
Change-Id: I00cd09fac0a8cb88191cc4cb3cbaf306987a97d6
Diffstat (limited to 'nova/tests/functional/libvirt/test_numa_servers.py')
-rw-r--r-- | nova/tests/functional/libvirt/test_numa_servers.py | 41 |
1 files changed, 6 insertions, 35 deletions
diff --git a/nova/tests/functional/libvirt/test_numa_servers.py b/nova/tests/functional/libvirt/test_numa_servers.py index 961aee3d16..840cbab48d 100644 --- a/nova/tests/functional/libvirt/test_numa_servers.py +++ b/nova/tests/functional/libvirt/test_numa_servers.py @@ -441,21 +441,8 @@ class NUMAServersTest(NUMAServersTestBase): kB_mem=15740000) # Start services - self.computes = {} - for host in ['test_compute0', 'test_compute1']: - fake_connection = self._get_connection( - host_info=host_info, hostname=host) - - # This is fun. Firstly we need to do a global'ish mock so we can - # actually start the service. - with mock.patch('nova.virt.libvirt.host.Host.get_connection', - return_value=fake_connection): - compute = self.start_service('compute', host=host) - - # Once that's done, we need to do some tweaks to each individual - # compute "service" to make sure they return unique objects - compute.driver._host.get_connection = lambda: fake_connection - self.computes[host] = compute + self.start_computes({'test_compute0': host_info, + 'test_compute1': host_info}) # STEP ONE @@ -653,10 +640,6 @@ class ReshapeForPCPUsTest(NUMAServersTestBase): group='compute') 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) - # Start services self.start_computes(save_rp_uuids=True) @@ -774,22 +757,10 @@ class ReshapeForPCPUsTest(NUMAServersTestBase): self.flags(cpu_dedicated_set='0-7', group='compute') self.flags(vcpu_pin_set=None) - for host in ['test_compute0', 'test_compute1']: - self.computes[host].stop() - - fake_connection = self._get_connection( - host_info=host_info, hostname=host) - - # This is fun. Firstly we need to do a global'ish mock so we can - # actually start the service. - with mock.patch('nova.virt.libvirt.host.Host.get_connection', - return_value=fake_connection): - compute = self.start_service('compute', host=host) - - # Once that's done, we need to do some tweaks to each individual - # compute "service" to make sure they return unique objects - compute.driver._host.get_connection = lambda: fake_connection - self.computes[host] = compute + computes = {} + for host, compute in self.computes.items(): + computes[host] = self.restart_compute_service(compute) + self.computes = computes # verify that the inventory, usages and allocation are correct after # the reshape |