@@ -81,10 +81,11 @@ def test_1_correct_init(self):
81
81
manager = self .manager
82
82
self .assertIsInstance (manager .driver , self .driver_cls )
83
83
84
+ @mock .patch ('nova.scheduler.request_filter.process_reqspec' )
84
85
@mock .patch ('nova.scheduler.utils.resources_from_request_spec' )
85
86
@mock .patch ('nova.scheduler.client.report.SchedulerReportClient.'
86
87
'get_allocation_candidates' )
87
- def test_select_destination (self , mock_get_ac , mock_rfrs ):
88
+ def test_select_destination (self , mock_get_ac , mock_rfrs , mock_process ):
88
89
fake_spec = objects .RequestSpec ()
89
90
fake_spec .instance_uuid = uuids .instance
90
91
fake_version = "9.42"
@@ -98,6 +99,7 @@ def test_select_destination(self, mock_get_ac, mock_rfrs):
98
99
) as select_destinations :
99
100
self .manager .select_destinations (self .context , spec_obj = fake_spec ,
100
101
instance_uuids = [fake_spec .instance_uuid ])
102
+ mock_process .assert_called_once_with (self .context , fake_spec )
101
103
select_destinations .assert_called_once_with (
102
104
self .context , fake_spec ,
103
105
[fake_spec .instance_uuid ], expected_alloc_reqs_by_rp_uuid ,
@@ -115,11 +117,12 @@ def test_select_destination(self, mock_get_ac, mock_rfrs):
115
117
[fake_spec .instance_uuid ], expected_alloc_reqs_by_rp_uuid ,
116
118
mock .sentinel .p_sums , fake_version , True )
117
119
120
+ @mock .patch ('nova.scheduler.request_filter.process_reqspec' )
118
121
@mock .patch ('nova.scheduler.utils.resources_from_request_spec' )
119
122
@mock .patch ('nova.scheduler.client.report.SchedulerReportClient.'
120
123
'get_allocation_candidates' )
121
124
def test_select_destination_return_objects (self , mock_get_ac ,
122
- mock_rfrs ):
125
+ mock_rfrs , mock_process ):
123
126
fake_spec = objects .RequestSpec ()
124
127
fake_spec .instance_uuid = uuids .instance
125
128
fake_version = "9.42"
@@ -141,6 +144,7 @@ def test_select_destination_return_objects(self, mock_get_ac,
141
144
return_objects = True , return_alternates = True )
142
145
sel_host = dests [0 ][0 ]
143
146
self .assertIsInstance (sel_host , objects .Selection )
147
+ mock_process .assert_called_once_with (None , fake_spec )
144
148
# Since both return_objects and return_alternates are True, the
145
149
# driver should have been called with True for return_alternates.
146
150
select_destinations .assert_called_once_with (None , fake_spec ,
@@ -163,11 +167,12 @@ def test_select_destination_return_objects(self, mock_get_ac,
163
167
[fake_spec .instance_uuid ], expected_alloc_reqs_by_rp_uuid ,
164
168
mock .sentinel .p_sums , fake_version , False )
165
169
170
+ @mock .patch ('nova.scheduler.request_filter.process_reqspec' )
166
171
@mock .patch ('nova.scheduler.utils.resources_from_request_spec' )
167
172
@mock .patch ('nova.scheduler.client.report.SchedulerReportClient.'
168
173
'get_allocation_candidates' )
169
174
def _test_select_destination (self , get_allocation_candidates_response ,
170
- mock_get_ac , mock_rfrs ):
175
+ mock_get_ac , mock_rfrs , mock_process ):
171
176
fake_spec = objects .RequestSpec ()
172
177
fake_spec .instance_uuid = uuids .instance
173
178
place_res = get_allocation_candidates_response
@@ -179,6 +184,7 @@ def _test_select_destination(self, get_allocation_candidates_response,
179
184
spec_obj = fake_spec ,
180
185
instance_uuids = [fake_spec .instance_uuid ])
181
186
select_destinations .assert_not_called ()
187
+ mock_process .assert_called_once_with (self .context , fake_spec )
182
188
mock_get_ac .assert_called_once_with (
183
189
self .context , mock_rfrs .return_value )
184
190
@@ -227,10 +233,12 @@ def test_select_destination_is_rebuild(self, mock_get_ac, mock_rfrs,
227
233
mock_get_ac .assert_not_called ()
228
234
mock_process .assert_not_called ()
229
235
236
+ @mock .patch ('nova.scheduler.request_filter.process_reqspec' )
230
237
@mock .patch ('nova.scheduler.utils.resources_from_request_spec' )
231
238
@mock .patch ('nova.scheduler.client.report.SchedulerReportClient.'
232
239
'get_allocation_candidates' )
233
- def test_select_destination_with_4_3_client (self , mock_get_ac , mock_rfrs ):
240
+ def test_select_destination_with_4_3_client (self , mock_get_ac , mock_rfrs ,
241
+ mock_process ):
234
242
fake_spec = objects .RequestSpec ()
235
243
place_res = (fakes .ALLOC_REQS , mock .sentinel .p_sums , "42.0" )
236
244
mock_get_ac .return_value = place_res
@@ -241,19 +249,21 @@ def test_select_destination_with_4_3_client(self, mock_get_ac, mock_rfrs):
241
249
with mock .patch .object (self .manager .driver , 'select_destinations'
242
250
) as select_destinations :
243
251
self .manager .select_destinations (self .context , spec_obj = fake_spec )
252
+ mock_process .assert_called_once_with (self .context , fake_spec )
244
253
select_destinations .assert_called_once_with (self .context ,
245
254
fake_spec , None , expected_alloc_reqs_by_rp_uuid ,
246
255
mock .sentinel .p_sums , "42.0" , False )
247
256
mock_get_ac .assert_called_once_with (
248
257
self .context , mock_rfrs .return_value )
249
258
250
259
# TODO(sbauza): Remove that test once the API v4 is removed
260
+ @mock .patch ('nova.scheduler.request_filter.process_reqspec' )
251
261
@mock .patch ('nova.scheduler.utils.resources_from_request_spec' )
252
262
@mock .patch ('nova.scheduler.client.report.SchedulerReportClient.'
253
263
'get_allocation_candidates' )
254
264
@mock .patch .object (objects .RequestSpec , 'from_primitives' )
255
265
def test_select_destination_with_old_client (self , from_primitives ,
256
- mock_get_ac , mock_rfrs ):
266
+ mock_get_ac , mock_rfrs , mock_process ):
257
267
fake_spec = objects .RequestSpec ()
258
268
fake_spec .instance_uuid = uuids .instance
259
269
from_primitives .return_value = fake_spec
@@ -269,6 +279,7 @@ def test_select_destination_with_old_client(self, from_primitives,
269
279
self .context , request_spec = 'fake_spec' ,
270
280
filter_properties = 'fake_props' ,
271
281
instance_uuids = [fake_spec .instance_uuid ])
282
+ mock_process .assert_called_once_with (self .context , fake_spec )
272
283
select_destinations .assert_called_once_with (
273
284
self .context , fake_spec ,
274
285
[fake_spec .instance_uuid ], expected_alloc_reqs_by_rp_uuid ,
0 commit comments