@@ -441,21 +441,8 @@ def test_resize_revert_server_with_numa(self):
441
441
kB_mem = 15740000 )
442
442
443
443
# 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 })
459
446
460
447
# STEP ONE
461
448
@@ -653,10 +640,6 @@ def test_vcpu_to_pcpu_reshape(self):
653
640
group = 'compute' )
654
641
self .flags (vcpu_pin_set = '0-7' )
655
642
656
- host_info = fakelibvirt .HostInfo (cpu_nodes = 2 , cpu_sockets = 1 ,
657
- cpu_cores = 2 , cpu_threads = 2 ,
658
- kB_mem = 15740000 )
659
-
660
643
# Start services
661
644
self .start_computes (save_rp_uuids = True )
662
645
@@ -774,22 +757,10 @@ def test_vcpu_to_pcpu_reshape(self):
774
757
self .flags (cpu_dedicated_set = '0-7' , group = 'compute' )
775
758
self .flags (vcpu_pin_set = None )
776
759
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
793
764
794
765
# verify that the inventory, usages and allocation are correct after
795
766
# the reshape
0 commit comments