1616
1717import mock
1818
19- from nova .db .main import api as main_db_api
2019from nova import objects
2120from nova .scheduler .filters import shard_filter
2221from nova import test
@@ -84,6 +83,7 @@ def test_shard_baremetal_passes(self, agg_mock, get_by_uuid):
8483 spec_obj = objects .RequestSpec (
8584 context = mock .sentinel .ctx , project_id = 'foo' ,
8685 instance_uuid = self .fake_build_req .instance_uuid ,
86+ availability_zone = None ,
8787 flavor = fake_flavor .fake_flavor_obj (
8888 mock .sentinel .ctx , expected_attrs = ['extra_specs' ],
8989 extra_specs = extra_specs ))
@@ -102,6 +102,7 @@ def test_shard_project_not_found(self, agg_mock, mock_update_cache,
102102 spec_obj = objects .RequestSpec (
103103 context = mock .sentinel .ctx , project_id = 'bar' ,
104104 instance_uuid = self .fake_build_req .instance_uuid ,
105+ availability_zone = None ,
105106 flavor = fake_flavor .fake_flavor_obj (
106107 mock .sentinel .ctx , expected_attrs = ['extra_specs' ]))
107108 self ._assert_passes (host , spec_obj , False )
@@ -116,6 +117,7 @@ def test_shard_project_no_shards(self, agg_mock, get_by_uuid):
116117 spec_obj = objects .RequestSpec (
117118 context = mock .sentinel .ctx , project_id = 'foo' ,
118119 instance_uuid = self .fake_build_req .instance_uuid ,
120+ availability_zone = None ,
119121 flavor = fake_flavor .fake_flavor_obj (
120122 mock .sentinel .ctx , expected_attrs = ['extra_specs' ]))
121123
@@ -130,6 +132,7 @@ def test_shard_host_no_shard_aggregate(self, agg_mock, get_by_uuid):
130132 spec_obj = objects .RequestSpec (
131133 context = mock .sentinel .ctx , project_id = 'foo' ,
132134 instance_uuid = self .fake_build_req .instance_uuid ,
135+ availability_zone = None ,
133136 flavor = fake_flavor .fake_flavor_obj (
134137 mock .sentinel .ctx , expected_attrs = ['extra_specs' ]))
135138
@@ -144,6 +147,7 @@ def test_shard_host_no_shards_in_aggregate(self, get_by_uuid):
144147 spec_obj = objects .RequestSpec (
145148 context = mock .sentinel .ctx , project_id = 'foo' ,
146149 instance_uuid = self .fake_build_req .instance_uuid ,
150+ availability_zone = None ,
147151 flavor = fake_flavor .fake_flavor_obj (
148152 mock .sentinel .ctx , expected_attrs = ['extra_specs' ]))
149153
@@ -158,6 +162,7 @@ def test_shard_project_shard_match_host_shard(self, get_by_uuid):
158162 spec_obj = objects .RequestSpec (
159163 context = mock .sentinel .ctx , project_id = 'foo' ,
160164 instance_uuid = self .fake_build_req .instance_uuid ,
165+ availability_zone = None ,
161166 flavor = fake_flavor .fake_flavor_obj (
162167 mock .sentinel .ctx , expected_attrs = ['extra_specs' ]))
163168
@@ -172,6 +177,7 @@ def test_shard_project_shard_do_not_match_host_shard(self, get_by_uuid):
172177 spec_obj = objects .RequestSpec (
173178 context = mock .sentinel .ctx , project_id = 'foo' ,
174179 instance_uuid = self .fake_build_req .instance_uuid ,
180+ availability_zone = None ,
175181 flavor = fake_flavor .fake_flavor_obj (
176182 mock .sentinel .ctx , expected_attrs = ['extra_specs' ]))
177183
@@ -186,6 +192,7 @@ def test_shard_project_has_multiple_shards_per_az(self, get_by_uuid):
186192 spec_obj = objects .RequestSpec (
187193 context = mock .sentinel .ctx , project_id = 'foo' ,
188194 instance_uuid = self .fake_build_req .instance_uuid ,
195+ availability_zone = None ,
189196 flavor = fake_flavor .fake_flavor_obj (
190197 mock .sentinel .ctx , expected_attrs = ['extra_specs' ]))
191198
@@ -205,6 +212,7 @@ def test_shard_project_has_multiple_shards_per_az_resize_same_shard(
205212 spec_obj = objects .RequestSpec (
206213 context = mock .sentinel .ctx , project_id = 'foo' ,
207214 instance_uuid = self .fake_build_req .instance_uuid ,
215+ availability_zone = None ,
208216 flavor = fake_flavor .fake_flavor_obj (
209217 mock .sentinel .ctx , expected_attrs = ['extra_specs' ]),
210218 scheduler_hints = dict (_nova_check_type = ['resize' ],
@@ -227,6 +235,7 @@ def test_shard_project_has_multiple_shards_per_az_resize_other_shard(
227235 flavor = fake_flavor .fake_flavor_obj (
228236 mock .sentinel .ctx , expected_attrs = ['extra_specs' ]),
229237 instance_uuid = self .fake_build_req .instance_uuid ,
238+ availability_zone = None ,
230239 scheduler_hints = dict (_nova_check_type = ['resize' ],
231240 source_host = ['host2' ]))
232241
@@ -245,6 +254,7 @@ def test_shard_project_has_sharding_enabled_any_host_passes(
245254 spec_obj = objects .RequestSpec (
246255 context = mock .sentinel .ctx , project_id = 'baz' ,
247256 instance_uuid = self .fake_build_req .instance_uuid ,
257+ availability_zone = None ,
248258 flavor = fake_flavor .fake_flavor_obj (
249259 mock .sentinel .ctx , expected_attrs = ['extra_specs' ]))
250260 self ._assert_passes (host , spec_obj , True )
@@ -261,6 +271,7 @@ def test_shard_project_has_sharding_enabled_and_single_shards(
261271 spec_obj = objects .RequestSpec (
262272 context = mock .sentinel .ctx , project_id = 'baz' ,
263273 instance_uuid = self .fake_build_req .instance_uuid ,
274+ availability_zone = None ,
264275 flavor = fake_flavor .fake_flavor_obj (
265276 mock .sentinel .ctx , expected_attrs = ['extra_specs' ]))
266277 self ._assert_passes (host , spec_obj , True )
@@ -287,7 +298,7 @@ def test_same_shard_for_kubernikus_cluster(self, get_context,
287298
288299 gather_host .assert_called_once_with (
289300 get_context .return_value ,
290- main_db_api .get_k8s_hosts_by_instances_tag ,
301+ objects . ComputeNodeList .get_k8s_hosts_by_instances_tag ,
291302 'kubernikus:kluster-example' ,
292303 filters = {'hv_type' : 'VMware vCenter Server' ,
293304 'availability_zone' : 'az-2' })
@@ -321,7 +332,7 @@ def test_same_shard_for_gardener_cluster(self, get_context,
321332
322333 gather_host .assert_called_once_with (
323334 get_context .return_value ,
324- main_db_api .get_k8s_hosts_by_instances_metadata ,
335+ objects . ComputeNodeList .get_k8s_hosts_by_instances_metadata ,
325336 gardener_cluster , '1' ,
326337 filters = {'hv_type' : 'VMware vCenter Server' ,
327338 'availability_zone' : 'az-2' })
@@ -351,7 +362,7 @@ def test_same_shard_for_nonbuild_requests(self, get_context,
351362
352363 gather_host .assert_called_once_with (
353364 get_context .return_value ,
354- main_db_api .get_k8s_hosts_by_instances_metadata ,
365+ objects . ComputeNodeList .get_k8s_hosts_by_instances_metadata ,
355366 gardener_cluster , '1' ,
356367 filters = {'hv_type' : 'VMware vCenter Server' ,
357368 'availability_zone' : 'az-2' })
@@ -467,6 +478,7 @@ def test_log_level_for_missing_vc_aggregate(self, agg_mock, log_mock,
467478 spec_obj = objects .RequestSpec (
468479 context = mock .sentinel .ctx , project_id = 'foo' ,
469480 instance_uuid = self .fake_build_req .instance_uuid ,
481+ availability_zone = None ,
470482 flavor = fake_flavor .fake_flavor_obj (
471483 mock .sentinel .ctx , expected_attrs = ['extra_specs' ]))
472484
0 commit comments