Skip to content

Commit

Permalink
Merge "Increase code reuse in test_numa_servers"
Browse files Browse the repository at this point in the history
  • Loading branch information
Zuul authored and openstack-gerrit committed May 20, 2020
2 parents 4c1b4f8 + 7f3a895 commit 301a5c6
Showing 1 changed file with 6 additions and 35 deletions.
41 changes: 6 additions & 35 deletions nova/tests/functional/libvirt/test_numa_servers.py
Original file line number Diff line number Diff line change
Expand Up @@ -441,21 +441,8 @@ def test_resize_revert_server_with_numa(self):
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

Expand Down Expand Up @@ -653,10 +640,6 @@ def test_vcpu_to_pcpu_reshape(self):
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)

Expand Down Expand Up @@ -774,22 +757,10 @@ def test_vcpu_to_pcpu_reshape(self):
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
Expand Down

0 comments on commit 301a5c6

Please sign in to comment.