@@ -694,28 +694,36 @@ def test_build_instances_no_instance_mapping(self, _mock_set_state,
694
694
mock .call (self .context , instances [1 ].uuid )])
695
695
self .assertFalse (mock_get_by_host .called )
696
696
697
- @mock .patch (" nova.scheduler .utils.claim_resources" , return_value = False )
697
+ @mock .patch (' nova.compute .utils.notify_about_compute_task_error' )
698
698
@mock .patch .object (objects .Instance , 'save' )
699
- def test_build_instances_exhaust_host_list (self , _mock_save , mock_claim ):
699
+ def test_build_instances_exhaust_host_list (self , _mock_save , mock_notify ):
700
700
# A list of three alternate hosts for one instance
701
701
host_lists = copy .deepcopy (fake_host_lists_alt )
702
702
instance = fake_instance .fake_instance_obj (self .context )
703
703
image = {'fake-data' : 'should_pass_silently' }
704
- expected_claim_count = len (host_lists [0 ])
705
704
706
705
# build_instances() is a cast, we need to wait for it to complete
707
706
self .useFixture (cast_as_call .CastAsCall (self ))
707
+
708
+ self .conductor .build_instances (
709
+ context = self .context ,
710
+ instances = [instance ], image = image ,
711
+ filter_properties = {},
712
+ admin_password = 'admin_password' ,
713
+ injected_files = 'injected_files' ,
714
+ requested_networks = None ,
715
+ security_groups = 'security_groups' ,
716
+ block_device_mapping = None ,
717
+ legacy_bdm = None ,
718
+ host_lists = host_lists
719
+ )
720
+
708
721
# Since claim_resources() is mocked to always return False, we will run
709
- # out of alternate hosts, and MaxRetriesExceeded should be raised.
710
- self .assertRaises (exc .MaxRetriesExceeded ,
711
- self .conductor .build_instances , context = self .context ,
712
- instances = [instance ], image = image , filter_properties = {},
713
- admin_password = 'admin_password' ,
714
- injected_files = 'injected_files' , requested_networks = None ,
715
- security_groups = 'security_groups' ,
716
- block_device_mapping = None , legacy_bdm = None ,
717
- host_lists = host_lists )
718
- self .assertEqual (expected_claim_count , mock_claim .call_count )
722
+ # out of alternate hosts, and complain about MaxRetriesExceeded.
723
+ mock_notify .assert_called_once_with (
724
+ self .context , 'build_instances' ,
725
+ instance .uuid , test .MatchType (dict ), 'error' ,
726
+ test .MatchType (exc .MaxRetriesExceeded ), test .MatchType (str ))
719
727
720
728
@mock .patch .object (conductor_manager .ComputeTaskManager ,
721
729
'_destroy_build_request' )
0 commit comments