Skip to content

Commit 301a5c6

Browse files
Zuulopenstack-gerrit
authored andcommitted
Merge "Increase code reuse in test_numa_servers"
2 parents 4c1b4f8 + 7f3a895 commit 301a5c6

File tree

1 file changed

+6
-35
lines changed

1 file changed

+6
-35
lines changed

nova/tests/functional/libvirt/test_numa_servers.py

Lines changed: 6 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -441,21 +441,8 @@ def test_resize_revert_server_with_numa(self):
441441
kB_mem=15740000)
442442

443443
# Start services
444-
self.computes = {}
445-
for host in ['test_compute0', 'test_compute1']:
446-
fake_connection = self._get_connection(
447-
host_info=host_info, hostname=host)
448-
449-
# This is fun. Firstly we need to do a global'ish mock so we can
450-
# actually start the service.
451-
with mock.patch('nova.virt.libvirt.host.Host.get_connection',
452-
return_value=fake_connection):
453-
compute = self.start_service('compute', host=host)
454-
455-
# Once that's done, we need to do some tweaks to each individual
456-
# compute "service" to make sure they return unique objects
457-
compute.driver._host.get_connection = lambda: fake_connection
458-
self.computes[host] = compute
444+
self.start_computes({'test_compute0': host_info,
445+
'test_compute1': host_info})
459446

460447
# STEP ONE
461448

@@ -653,10 +640,6 @@ def test_vcpu_to_pcpu_reshape(self):
653640
group='compute')
654641
self.flags(vcpu_pin_set='0-7')
655642

656-
host_info = fakelibvirt.HostInfo(cpu_nodes=2, cpu_sockets=1,
657-
cpu_cores=2, cpu_threads=2,
658-
kB_mem=15740000)
659-
660643
# Start services
661644
self.start_computes(save_rp_uuids=True)
662645

@@ -774,22 +757,10 @@ def test_vcpu_to_pcpu_reshape(self):
774757
self.flags(cpu_dedicated_set='0-7', group='compute')
775758
self.flags(vcpu_pin_set=None)
776759

777-
for host in ['test_compute0', 'test_compute1']:
778-
self.computes[host].stop()
779-
780-
fake_connection = self._get_connection(
781-
host_info=host_info, hostname=host)
782-
783-
# This is fun. Firstly we need to do a global'ish mock so we can
784-
# actually start the service.
785-
with mock.patch('nova.virt.libvirt.host.Host.get_connection',
786-
return_value=fake_connection):
787-
compute = self.start_service('compute', host=host)
788-
789-
# Once that's done, we need to do some tweaks to each individual
790-
# compute "service" to make sure they return unique objects
791-
compute.driver._host.get_connection = lambda: fake_connection
792-
self.computes[host] = compute
760+
computes = {}
761+
for host, compute in self.computes.items():
762+
computes[host] = self.restart_compute_service(compute)
763+
self.computes = computes
793764

794765
# verify that the inventory, usages and allocation are correct after
795766
# the reshape

0 commit comments

Comments
 (0)