diff options
| author | Mark McLoughlin <markmc@redhat.com> | 2012-08-29 11:18:04 +0100 |
|---|---|---|
| committer | Mark McLoughlin <markmc@redhat.com> | 2012-08-29 20:54:49 +0100 |
| commit | d52e052729edeb7c0ae845dedd682f3f04526278 (patch) | |
| tree | 6de0b87d9e39aa35f430934d8ee7a832ce3e8732 /nova/tests | |
| parent | b84b1c7c9dfcf91fe767dabfb449fcfe59d588ea (diff) | |
Remove scheduler RPC API version 1.x
Like with the compute RPC API, we're unlikely to still work well with
RPC client using older 1.x version because of DB schema changes.
In that case, we may as well remove 1.x support in Folsom and rip out
the potentially buggy backwards compat code. This should also make
backporting fixes from Grizzly easier.
Deployers following trunk can upgrade all their nodes to use the version
2.0 API before deploying this commit.
Change-Id: Iee099751bda9637da5e134357d28e89d5fba9895
Diffstat (limited to 'nova/tests')
| -rw-r--r-- | nova/tests/scheduler/test_chance_scheduler.py | 147 | ||||
| -rw-r--r-- | nova/tests/scheduler/test_filter_scheduler.py | 25 | ||||
| -rw-r--r-- | nova/tests/scheduler/test_multi_scheduler.py | 37 | ||||
| -rw-r--r-- | nova/tests/scheduler/test_scheduler.py | 191 |
4 files changed, 56 insertions, 344 deletions
diff --git a/nova/tests/scheduler/test_chance_scheduler.py b/nova/tests/scheduler/test_chance_scheduler.py index d8eb2ade6..7560f72f4 100644 --- a/nova/tests/scheduler/test_chance_scheduler.py +++ b/nova/tests/scheduler/test_chance_scheduler.py @@ -63,27 +63,22 @@ class ChanceSchedulerTestCase(test_scheduler.SchedulerTestCase): ctxt = context.RequestContext('fake', 'fake', False) ctxt_elevated = 'fake-context-elevated' fake_args = (1, 2, 3) - instance_opts = {'fake_opt1': 'meow'} - request_spec = {'num_instances': 2, - 'instance_properties': instance_opts} + instance_opts = {'fake_opt1': 'meow', 'launch_index': -1} instance1 = {'uuid': 'fake-uuid1'} instance2 = {'uuid': 'fake-uuid2'} + request_spec = {'instance_uuids': ['fake-uuid1', 'fake-uuid2'], + 'instance_properties': instance_opts} instance1_encoded = {'uuid': 'fake-uuid1', '_is_precooked': False} instance2_encoded = {'uuid': 'fake-uuid2', '_is_precooked': False} reservations = ['resv1', 'resv2'] - # create_instance_db_entry() usually does this, but we're - # stubbing it. - def _add_uuid1(ctxt, request_spec, reservations): - request_spec['instance_properties']['uuid'] = 'fake-uuid1' - - def _add_uuid2(ctxt, request_spec, reservations): - request_spec['instance_properties']['uuid'] = 'fake-uuid2' + def inc_launch_index(*args): + request_spec['instance_properties']['launch_index'] = ( + request_spec['instance_properties']['launch_index'] + 1) self.mox.StubOutWithMock(ctxt, 'elevated') self.mox.StubOutWithMock(self.driver, 'hosts_up') self.mox.StubOutWithMock(random, 'random') - self.mox.StubOutWithMock(self.driver, 'create_instance_db_entry') self.mox.StubOutWithMock(driver, 'encode_instance') self.mox.StubOutWithMock(driver, 'instance_update_db') self.mox.StubOutWithMock(compute_rpcapi.ComputeAPI, 'run_instance') @@ -93,110 +88,39 @@ class ChanceSchedulerTestCase(test_scheduler.SchedulerTestCase): self.driver.hosts_up(ctxt_elevated, 'compute').AndReturn( ['host1', 'host2', 'host3', 'host4']) random.random().AndReturn(.5) - self.driver.create_instance_db_entry(ctxt, request_spec, - reservations).WithSideEffects(_add_uuid1).AndReturn( - instance1) driver.instance_update_db(ctxt, instance1['uuid'], - 'host3').AndReturn(instance1) + 'host3').WithSideEffects(inc_launch_index).AndReturn(instance1) compute_rpcapi.ComputeAPI.run_instance(ctxt, host='host3', instance=instance1, requested_networks=None, injected_files=None, admin_password=None, is_first_time=None, request_spec=request_spec, filter_properties={}) - driver.encode_instance(instance1).AndReturn(instance1_encoded) + # instance 2 ctxt.elevated().AndReturn(ctxt_elevated) self.driver.hosts_up(ctxt_elevated, 'compute').AndReturn( ['host1', 'host2', 'host3', 'host4']) random.random().AndReturn(.2) - self.driver.create_instance_db_entry(ctxt, request_spec, - reservations).WithSideEffects(_add_uuid2).AndReturn( - instance2) driver.instance_update_db(ctxt, instance2['uuid'], - 'host1').AndReturn(instance2) + 'host1').WithSideEffects(inc_launch_index).AndReturn(instance2) compute_rpcapi.ComputeAPI.run_instance(ctxt, host='host1', instance=instance2, requested_networks=None, injected_files=None, admin_password=None, is_first_time=None, request_spec=request_spec, filter_properties={}) - driver.encode_instance(instance2).AndReturn(instance2_encoded) self.mox.ReplayAll() result = self.driver.schedule_run_instance(ctxt, request_spec, - None, None, None, None, {}, reservations) + None, None, None, None, {}) expected = [instance1_encoded, instance2_encoded] self.assertEqual(result, expected) - def test_scheduler_includes_launch_index(self): - ctxt = context.RequestContext('fake', 'fake', False) - instance_opts = {'fake_opt1': 'meow'} - request_spec = {'num_instances': 2, - 'instance_properties': instance_opts} - instance1 = {'uuid': 'fake-uuid1'} - instance2 = {'uuid': 'fake-uuid2'} - - # create_instance_db_entry() usually does this, but we're - # stubbing it. - def _add_uuid(num): - """Return a function that adds the provided uuid number.""" - def _add_uuid_num(_, spec, reservations): - spec['instance_properties']['uuid'] = 'fake-uuid%d' % num - return _add_uuid_num - - def _has_launch_index(expected_index): - """Return a function that verifies the expected index.""" - def _check_launch_index(value): - if 'instance_properties' in value: - if 'launch_index' in value['instance_properties']: - index = value['instance_properties']['launch_index'] - if index == expected_index: - return True - return False - return _check_launch_index - - self.mox.StubOutWithMock(self.driver, '_schedule') - self.mox.StubOutWithMock(self.driver, 'create_instance_db_entry') - self.mox.StubOutWithMock(driver, 'encode_instance') - self.mox.StubOutWithMock(driver, 'instance_update_db') - self.mox.StubOutWithMock(compute_rpcapi.ComputeAPI, 'run_instance') - - # instance 1 - self.driver._schedule(ctxt, 'compute', request_spec, - {}).AndReturn('host') - self.driver.create_instance_db_entry( - ctxt, mox.Func(_has_launch_index(0)), None - ).WithSideEffects(_add_uuid(1)).AndReturn(instance1) - driver.instance_update_db(ctxt, instance1['uuid'], - 'host').AndReturn(instance1) - compute_rpcapi.ComputeAPI.run_instance(ctxt, host='host', - instance=instance1, requested_networks=None, - injected_files=None, admin_password=None, is_first_time=None, - request_spec=request_spec, filter_properties={}) - driver.encode_instance(instance1).AndReturn(instance1) - # instance 2 - self.driver._schedule(ctxt, 'compute', request_spec, - {}).AndReturn('host') - self.driver.create_instance_db_entry( - ctxt, mox.Func(_has_launch_index(1)), None - ).WithSideEffects(_add_uuid(2)).AndReturn(instance2) - driver.instance_update_db(ctxt, instance2['uuid'], - 'host').AndReturn(instance2) - compute_rpcapi.ComputeAPI.run_instance(ctxt, host='host', - instance=instance2, requested_networks=None, - injected_files=None, admin_password=None, is_first_time=None, - request_spec=request_spec, filter_properties={}) - driver.encode_instance(instance2).AndReturn(instance2) - self.mox.ReplayAll() - - self.driver.schedule_run_instance(ctxt, request_spec, None, None, - None, None, {}, None) - def test_basic_schedule_run_instance_no_hosts(self): ctxt = context.RequestContext('fake', 'fake', False) ctxt_elevated = 'fake-context-elevated' fake_args = (1, 2, 3) - instance_opts = 'fake_instance_opts' - request_spec = {'num_instances': 2, + instance_opts = {'fake_opt1': 'meow', 'launch_index': -1} + request_spec = {'instance_uuids': ['fake-uuid1'], 'instance_properties': instance_opts} self.mox.StubOutWithMock(ctxt, 'elevated') @@ -209,50 +133,7 @@ class ChanceSchedulerTestCase(test_scheduler.SchedulerTestCase): self.mox.ReplayAll() self.assertRaises(exception.NoValidHost, self.driver.schedule_run_instance, ctxt, request_spec, - None, None, None, None, {}, None) - - def test_basic_schedule_fallback(self): - ctxt = context.RequestContext('fake', 'fake', False) - ctxt_elevated = 'fake-context-elevated' - topic = 'fake_topic' - method = 'fake_method' - fake_args = (1, 2, 3) - fake_kwargs = {'fake_kwarg1': 'fake_value1', - 'fake_kwarg2': 'fake_value2'} - - self.mox.StubOutWithMock(ctxt, 'elevated') - self.mox.StubOutWithMock(self.driver, 'hosts_up') - self.mox.StubOutWithMock(random, 'random') - self.mox.StubOutWithMock(driver, 'cast_to_host') - - ctxt.elevated().AndReturn(ctxt_elevated) - self.driver.hosts_up(ctxt_elevated, topic).AndReturn( - ['host1', 'host2', 'host3', 'host4']) - random.random().AndReturn(.5) - driver.cast_to_host(ctxt, topic, 'host3', method, **fake_kwargs) - - self.mox.ReplayAll() - self.driver.schedule(ctxt, topic, method, *fake_args, **fake_kwargs) - - def test_basic_schedule_fallback_no_hosts(self): - ctxt = context.RequestContext('fake', 'fake', False) - ctxt_elevated = 'fake-context-elevated' - topic = 'fake_topic' - method = 'fake_method' - fake_args = (1, 2, 3) - fake_kwargs = {'fake_kwarg1': 'fake_value1', - 'fake_kwarg2': 'fake_value2'} - - self.mox.StubOutWithMock(ctxt, 'elevated') - self.mox.StubOutWithMock(self.driver, 'hosts_up') - - ctxt.elevated().AndReturn(ctxt_elevated) - self.driver.hosts_up(ctxt_elevated, topic).AndReturn([]) - - self.mox.ReplayAll() - self.assertRaises(exception.NoValidHost, - self.driver.schedule, ctxt, topic, method, - *fake_args, **fake_kwargs) + None, None, None, None, {}) def test_schedule_prep_resize_doesnt_update_host(self): fake_context = context.RequestContext('user', 'project', @@ -275,5 +156,5 @@ class ChanceSchedulerTestCase(test_scheduler.SchedulerTestCase): instance = {'uuid': 'fake-uuid', 'host': 'host1'} self.driver.schedule_prep_resize(fake_context, {}, {}, {}, - instance, {}) + instance, {}, None) self.assertEqual(info['called'], 0) diff --git a/nova/tests/scheduler/test_filter_scheduler.py b/nova/tests/scheduler/test_filter_scheduler.py index 1cab6ebbf..bd8a7c5d6 100644 --- a/nova/tests/scheduler/test_filter_scheduler.py +++ b/nova/tests/scheduler/test_filter_scheduler.py @@ -49,10 +49,11 @@ class FilterSchedulerTestCase(test_scheduler.SchedulerTestCase): fake_context = context.RequestContext('user', 'project') request_spec = {'instance_type': {'memory_mb': 1, 'root_gb': 1, 'ephemeral_gb': 0}, - 'instance_properties': {'project_id': 1}} + 'instance_properties': {'project_id': 1}, + 'instance_uuids': ['fake-uuid1']} self.assertRaises(exception.NoValidHost, sched.schedule_run_instance, fake_context, request_spec, None, None, None, - None, {}, None) + None, {}) def test_run_instance_non_admin(self): """Test creating an instance locally using run_instance, passing @@ -71,10 +72,11 @@ class FilterSchedulerTestCase(test_scheduler.SchedulerTestCase): fake_context = context.RequestContext('user', 'project') request_spec = {'instance_type': {'memory_mb': 1, 'local_gb': 1}, - 'instance_properties': {'project_id': 1}} + 'instance_properties': {'project_id': 1}, + 'instance_uuids': ['fake-uuid1']} self.assertRaises(exception.NoValidHost, sched.schedule_run_instance, fake_context, request_spec, None, None, None, - None, {}, None) + None, {}) self.assertTrue(self.was_admin) def test_schedule_bad_topic(self): @@ -89,7 +91,7 @@ class FilterSchedulerTestCase(test_scheduler.SchedulerTestCase): fake_kwargs = {'fake_kwarg1': 'fake_value1', 'fake_kwarg2': 'fake_value2'} instance_opts = {'fake_opt1': 'meow'} - request_spec = {'num_instances': 2, + request_spec = {'instance_uuids': ['fake-uuid1', 'fake-uuid2'], 'instance_properties': instance_opts} instance1 = {'uuid': 'fake-uuid1'} instance2 = {'uuid': 'fake-uuid2'} @@ -114,22 +116,24 @@ class FilterSchedulerTestCase(test_scheduler.SchedulerTestCase): self.mox.StubOutWithMock(self.driver, '_provision_resource') self.driver._schedule(context_fake, 'compute', - request_spec, {} + request_spec, {}, ['fake-uuid1', 'fake-uuid2'] ).AndReturn(['host1', 'host2']) # instance 1 self.driver._provision_resource( ctxt, 'host1', mox.Func(_has_launch_index(0)), {}, - None, None, None, None, reservations=None).AndReturn(instance1) + None, None, None, None, + instance_uuid='fake-uuid1').AndReturn(instance1) # instance 2 self.driver._provision_resource( ctxt, 'host2', mox.Func(_has_launch_index(1)), {}, - None, None, None, None, reservations=None).AndReturn(instance2) + None, None, None, None, + instance_uuid='fake-uuid2').AndReturn(instance2) self.mox.ReplayAll() self.driver.schedule_run_instance(context_fake, request_spec, - None, None, None, None, {}, None) + None, None, None, None, {}) def test_schedule_happy_day(self): """Make sure there's nothing glaringly wrong with _schedule() @@ -191,7 +195,8 @@ class FilterSchedulerTestCase(test_scheduler.SchedulerTestCase): instance = {'uuid': 'fake-uuid', 'host': 'host1'} - sched.schedule_prep_resize(fake_context, {}, {}, {}, instance, {}) + sched.schedule_prep_resize(fake_context, {}, {}, {}, + instance, {}, None) self.assertEqual(info['called'], 0) def test_get_cost_functions(self): diff --git a/nova/tests/scheduler/test_multi_scheduler.py b/nova/tests/scheduler/test_multi_scheduler.py index 8220fa60d..04ab67675 100644 --- a/nova/tests/scheduler/test_multi_scheduler.py +++ b/nova/tests/scheduler/test_multi_scheduler.py @@ -35,9 +35,6 @@ class FakeComputeScheduler(driver.Scheduler): def schedule_theoretical(self, *args, **kwargs): pass - def schedule(self, *args, **kwargs): - pass - class FakeVolumeScheduler(driver.Scheduler): is_fake_volume = True @@ -46,9 +43,6 @@ class FakeVolumeScheduler(driver.Scheduler): super(FakeVolumeScheduler, self).__init__() self.is_update_caps_called = False - def schedule(self, *args, **kwargs): - pass - class FakeDefaultScheduler(driver.Scheduler): is_fake_default = True @@ -57,9 +51,6 @@ class FakeDefaultScheduler(driver.Scheduler): super(FakeDefaultScheduler, self).__init__() self.is_update_caps_called = False - def schedule(self, *args, **kwargs): - pass - class MultiDriverTestCase(test_scheduler.SchedulerTestCase): """Test case for multi driver""" @@ -84,31 +75,6 @@ class MultiDriverTestCase(test_scheduler.SchedulerTestCase): self.assertTrue(mgr.drivers['volume'].is_fake_volume) self.assertTrue(mgr.drivers['default'].is_fake_default) - def test_schedule_fallback_proxy(self): - mgr = self._manager - - self.mox.StubOutWithMock(mgr.drivers['compute'], 'schedule') - self.mox.StubOutWithMock(mgr.drivers['volume'], 'schedule') - self.mox.StubOutWithMock(mgr.drivers['default'], 'schedule') - - ctxt = 'fake_context' - method = 'fake_method' - fake_args = (1, 2, 3) - fake_kwargs = {'fake_kwarg1': 'fake_value1', - 'fake_kwarg2': 'fake_value2'} - - mgr.drivers['compute'].schedule(ctxt, 'compute', method, - *fake_args, **fake_kwargs) - mgr.drivers['volume'].schedule(ctxt, 'volume', method, - *fake_args, **fake_kwargs) - mgr.drivers['default'].schedule(ctxt, 'random_topic', method, - *fake_args, **fake_kwargs) - - self.mox.ReplayAll() - mgr.schedule(ctxt, 'compute', method, *fake_args, **fake_kwargs) - mgr.schedule(ctxt, 'volume', method, *fake_args, **fake_kwargs) - mgr.schedule(ctxt, 'random_topic', method, *fake_args, **fake_kwargs) - def test_update_service_capabilities(self): def fake_update_service_capabilities(self, service, host, caps): self.is_update_caps_called = True @@ -159,6 +125,3 @@ class SimpleSchedulerTestCase(MultiDriverTestCase): self.assertTrue(mgr.drivers['compute'].is_fake_compute) self.assertTrue(mgr.drivers['volume'] is not None) self.assertTrue(mgr.drivers['default'].is_fake_default) - - def test_proxy_calls(self): - pass diff --git a/nova/tests/scheduler/test_scheduler.py b/nova/tests/scheduler/test_scheduler.py index 2c00c7983..c5276819e 100644 --- a/nova/tests/scheduler/test_scheduler.py +++ b/nova/tests/scheduler/test_scheduler.py @@ -78,7 +78,7 @@ class SchedulerManagerTestCase(test.TestCase): host, {}) self.mox.ReplayAll() result = self.manager.update_service_capabilities(self.context, - service_name=service_name, host=host) + service_name=service_name, host=host, capabilities={}) self.mox.VerifyAll() self.mox.ResetAll() @@ -91,29 +91,6 @@ class SchedulerManagerTestCase(test.TestCase): service_name=service_name, host=host, capabilities=capabilities) - def test_existing_method(self): - def stub_method(self, *args, **kwargs): - pass - setattr(self.manager.driver, 'schedule_stub_method', stub_method) - - self.mox.StubOutWithMock(self.manager.driver, - 'schedule_stub_method') - self.manager.driver.schedule_stub_method(self.context, - *self.fake_args, **self.fake_kwargs) - - self.mox.ReplayAll() - self.manager.stub_method(self.context, self.topic, - *self.fake_args, **self.fake_kwargs) - - def test_missing_method_fallback(self): - self.mox.StubOutWithMock(self.manager.driver, 'schedule') - self.manager.driver.schedule(self.context, self.topic, - 'noexist', *self.fake_args, **self.fake_kwargs) - - self.mox.ReplayAll() - self.manager.noexist(self.context, self.topic, - *self.fake_args, **self.fake_kwargs) - def test_show_host_resources(self): host = 'fake_host' @@ -175,37 +152,6 @@ class SchedulerManagerTestCase(test.TestCase): self.mox.StubOutWithMock(self.manager.driver, method_name) - def test_schedule_exeception_changes_state_notifies_and_raises(self): - """Test that an exception scheduling calls - _set_vm_state_and_notify and reraises - """ - fake_instance_uuid = 'fake-instance-id' - - self._mox_schedule_method_helper('schedule_something') - - self.mox.StubOutWithMock(self.manager, '_set_vm_state_and_notify') - - request_spec = {'instance_properties': - {'uuid': fake_instance_uuid}} - self.fake_kwargs['request_spec'] = request_spec - - ex = self.AnException('something happened') - self.manager.driver.schedule_something(self.context, - *self.fake_args, **self.fake_kwargs).AndRaise(ex) - - # Adding the context to the args is kind of gnarly, but thats what - # happens. Could be refactored to keep all the context, spec, topic - # stuff a bit cleaner. - self.manager._set_vm_state_and_notify('something', - {'vm_state': vm_states.ERROR}, self.context, - ex, request_spec) - - self.mox.ReplayAll() - - self.assertRaises(self.AnException, self.manager.something, - self.context, self.topic, - *self.fake_args, **self.fake_kwargs) - def test_run_instance_exception_puts_instance_in_error_state(self): """Test that a NoValidHost exception for run_instance puts the instance in ERROR state and eats the exception. @@ -221,14 +167,14 @@ class SchedulerManagerTestCase(test.TestCase): {'uuid': fake_instance_uuid}} self.manager.driver.schedule_run_instance(self.context, - request_spec, None, None, None, None, {}, None).AndRaise( + request_spec, None, None, None, None, {}).AndRaise( exception.NoValidHost(reason="")) db.instance_update_and_get_original(self.context, fake_instance_uuid, {"vm_state": vm_states.ERROR}).AndReturn((inst, inst)) self.mox.ReplayAll() self.manager.run_instance(self.context, request_spec, - None, None, None, None, {}, None) + None, None, None, None, {}) def test_prep_resize_no_valid_host_back_in_active_state(self): """Test that a NoValidHost exception for prep_resize puts @@ -260,8 +206,7 @@ class SchedulerManagerTestCase(test.TestCase): (inst, inst)) self.mox.ReplayAll() - # FIXME(comstud): Remove 'update_db' on future RPC version bump. - self.manager.prep_resize(update_db=False, **kwargs) + self.manager.prep_resize(**kwargs) def test_prep_resize_exception_host_in_error_state_and_raise(self): """Test that a NoValidHost exception for prep_resize puts @@ -297,10 +242,7 @@ class SchedulerManagerTestCase(test.TestCase): self.mox.ReplayAll() - # FIXME(comstud): Remove 'update_db' on future RPC version bump. - self.assertRaises(self.AnException, self.manager.prep_resize, - update_db=False, - **kwargs) + self.assertRaises(self.AnException, self.manager.prep_resize, **kwargs) class SchedulerTestCase(test.TestCase): @@ -347,48 +289,6 @@ class SchedulerTestCase(test.TestCase): result = self.driver.hosts_up(self.context, self.topic) self.assertEqual(result, ['host2']) - def test_create_instance_db_entry(self): - base_options = {'fake_option': 'meow'} - image = 'fake_image' - instance_type = 'fake_instance_type' - security_group = 'fake_security_group' - block_device_mapping = 'fake_block_device_mapping' - request_spec = {'instance_properties': base_options, - 'image': image, - 'instance_type': instance_type, - 'security_group': security_group, - 'block_device_mapping': block_device_mapping} - - self.mox.StubOutWithMock(self.driver.compute_api, - 'create_db_entry_for_new_instance') - self.mox.StubOutWithMock(db, 'instance_get_by_uuid') - - # New entry - fake_instance = {'uuid': 'fake-uuid'} - self.driver.compute_api.create_db_entry_for_new_instance( - self.context, instance_type, image, base_options, - security_group, - block_device_mapping).AndReturn(fake_instance) - self.mox.ReplayAll() - instance = self.driver.create_instance_db_entry(self.context, - request_spec, None) - self.mox.VerifyAll() - self.assertEqual(instance, fake_instance) - - # Entry created by compute already - self.mox.ResetAll() - - fake_uuid = 'fake-uuid' - base_options['uuid'] = fake_uuid - fake_instance = {'uuid': fake_uuid} - db.instance_get_by_uuid(self.context, fake_uuid).AndReturn( - fake_instance) - - self.mox.ReplayAll() - instance = self.driver.create_instance_db_entry(self.context, - request_spec, None) - self.assertEqual(instance, fake_instance) - def _live_migration_instance(self): volume1 = {'id': 31338} volume2 = {'id': 31339} @@ -516,37 +416,28 @@ class SchedulerTestCase(test.TestCase): def test_live_migration_instance_not_running(self): """The instance given by instance_id is not running.""" - self.mox.StubOutWithMock(db, 'instance_get') - dest = 'fake_host2' block_migration = False + disk_over_commit = False instance = self._live_migration_instance() - instance_id = instance['id'] instance['power_state'] = power_state.NOSTATE - db.instance_get(self.context, - instance_id).AndReturn(instance) - - self.mox.ReplayAll() - self.assertRaises(exception.InstanceNotRunning, self.driver.schedule_live_migration, self.context, - instance_id=instance_id, dest=dest, - block_migration=block_migration) + instance=instance, dest=dest, + block_migration=block_migration, + disk_over_commit=disk_over_commit) def test_live_migration_compute_src_not_exist(self): """Raise exception when src compute node is does not exist.""" - self.mox.StubOutWithMock(db, 'instance_get') self.mox.StubOutWithMock(utils, 'service_is_up') self.mox.StubOutWithMock(db, 'service_get_all_compute_by_host') dest = 'fake_host2' block_migration = False + disk_over_commit = False instance = self._live_migration_instance() - instance_id = instance['id'] - db.instance_get(self.context, - instance_id).AndReturn(instance) # Compute down db.service_get_all_compute_by_host(self.context, @@ -556,22 +447,20 @@ class SchedulerTestCase(test.TestCase): self.mox.ReplayAll() self.assertRaises(exception.ComputeServiceUnavailable, self.driver.schedule_live_migration, self.context, - instance_id=instance_id, dest=dest, - block_migration=block_migration) + instance=instance, dest=dest, + block_migration=block_migration, + disk_over_commit=disk_over_commit) def test_live_migration_compute_src_not_alive(self): """Raise exception when src compute node is not alive.""" - self.mox.StubOutWithMock(db, 'instance_get') self.mox.StubOutWithMock(utils, 'service_is_up') self.mox.StubOutWithMock(db, 'service_get_all_compute_by_host') dest = 'fake_host2' block_migration = False + disk_over_commit = False instance = self._live_migration_instance() - instance_id = instance['id'] - db.instance_get(self.context, - instance_id).AndReturn(instance) # Compute down db.service_get_all_compute_by_host(self.context, @@ -581,23 +470,21 @@ class SchedulerTestCase(test.TestCase): self.mox.ReplayAll() self.assertRaises(exception.ComputeServiceUnavailable, self.driver.schedule_live_migration, self.context, - instance_id=instance_id, dest=dest, - block_migration=block_migration) + instance=instance, dest=dest, + block_migration=block_migration, + disk_over_commit=disk_over_commit) def test_live_migration_compute_dest_not_alive(self): """Raise exception when dest compute node is not alive.""" - self.mox.StubOutWithMock(db, 'instance_get') self.mox.StubOutWithMock(self.driver, '_live_migration_src_check') self.mox.StubOutWithMock(db, 'service_get_all_compute_by_host') self.mox.StubOutWithMock(utils, 'service_is_up') dest = 'fake_host2' block_migration = False + disk_over_commit = False instance = self._live_migration_instance() - instance_id = instance['id'] - db.instance_get(self.context, - instance_id).AndReturn(instance) self.driver._live_migration_src_check(self.context, instance) db.service_get_all_compute_by_host(self.context, @@ -608,13 +495,13 @@ class SchedulerTestCase(test.TestCase): self.mox.ReplayAll() self.assertRaises(exception.ComputeServiceUnavailable, self.driver.schedule_live_migration, self.context, - instance_id=instance_id, dest=dest, - block_migration=block_migration) + instance=instance, dest=dest, + block_migration=block_migration, + disk_over_commit=disk_over_commit) def test_live_migration_dest_check_service_same_host(self): """Confirms exception raises in case dest and src is same host.""" - self.mox.StubOutWithMock(db, 'instance_get') self.mox.StubOutWithMock(self.driver, '_live_migration_src_check') self.mox.StubOutWithMock(db, 'service_get_all_compute_by_host') self.mox.StubOutWithMock(utils, 'service_is_up') @@ -622,13 +509,9 @@ class SchedulerTestCase(test.TestCase): block_migration = False disk_over_commit = False instance = self._live_migration_instance() - instance_id = instance['id'] # make dest same as src dest = instance['host'] - db.instance_get(self.context, - instance_id).AndReturn(instance) - self.driver._live_migration_src_check(self.context, instance) db.service_get_all_compute_by_host(self.context, dest).AndReturn(['fake_service3']) @@ -637,14 +520,13 @@ class SchedulerTestCase(test.TestCase): self.mox.ReplayAll() self.assertRaises(exception.UnableToMigrateToSelf, self.driver.schedule_live_migration, self.context, - instance_id=instance_id, dest=dest, + instance=instance, dest=dest, block_migration=block_migration, disk_over_commit=False) def test_live_migration_dest_check_service_lack_memory(self): """Confirms exception raises when dest doesn't have enough memory.""" - self.mox.StubOutWithMock(db, 'instance_get') self.mox.StubOutWithMock(self.driver, '_live_migration_src_check') self.mox.StubOutWithMock(db, 'service_get_all_compute_by_host') self.mox.StubOutWithMock(utils, 'service_is_up') @@ -655,9 +537,6 @@ class SchedulerTestCase(test.TestCase): block_migration = False disk_over_commit = False instance = self._live_migration_instance() - instance_id = instance['id'] - db.instance_get(self.context, - instance_id).AndReturn(instance) self.driver._live_migration_src_check(self.context, instance) db.service_get_all_compute_by_host(self.context, @@ -672,13 +551,12 @@ class SchedulerTestCase(test.TestCase): self.mox.ReplayAll() self.assertRaises(exception.MigrationError, self.driver.schedule_live_migration, self.context, - instance_id=instance_id, dest=dest, + instance=instance, dest=dest, block_migration=block_migration, disk_over_commit=disk_over_commit) def test_live_migration_different_hypervisor_type_raises(self): """Confirm live_migration to hypervisor of different type raises""" - self.mox.StubOutWithMock(db, 'instance_get') self.mox.StubOutWithMock(self.driver, '_live_migration_src_check') self.mox.StubOutWithMock(self.driver, '_live_migration_dest_check') self.mox.StubOutWithMock(rpc, 'queue_get_for') @@ -690,9 +568,6 @@ class SchedulerTestCase(test.TestCase): block_migration = False disk_over_commit = False instance = self._live_migration_instance() - instance_id = instance['id'] - db.instance_get(self.context, - instance_id).AndReturn(instance) self.driver._live_migration_src_check(self.context, instance) self.driver._live_migration_dest_check(self.context, instance, dest) @@ -708,13 +583,12 @@ class SchedulerTestCase(test.TestCase): self.mox.ReplayAll() self.assertRaises(exception.InvalidHypervisorType, self.driver.schedule_live_migration, self.context, - instance_id=instance_id, dest=dest, + instance=instance, dest=dest, block_migration=block_migration, disk_over_commit=disk_over_commit) def test_live_migration_dest_hypervisor_version_older_raises(self): """Confirm live migration to older hypervisor raises""" - self.mox.StubOutWithMock(db, 'instance_get') self.mox.StubOutWithMock(self.driver, '_live_migration_src_check') self.mox.StubOutWithMock(self.driver, '_live_migration_dest_check') self.mox.StubOutWithMock(rpc, 'queue_get_for') @@ -726,9 +600,6 @@ class SchedulerTestCase(test.TestCase): block_migration = False disk_over_commit = False instance = self._live_migration_instance() - instance_id = instance['id'] - db.instance_get(self.context, - instance_id).AndReturn(instance) self.driver._live_migration_src_check(self.context, instance) self.driver._live_migration_dest_check(self.context, instance, dest) @@ -743,7 +614,7 @@ class SchedulerTestCase(test.TestCase): self.mox.ReplayAll() self.assertRaises(exception.DestinationHypervisorTooOld, self.driver.schedule_live_migration, self.context, - instance_id=instance_id, dest=dest, + instance=instance, dest=dest, block_migration=block_migration, disk_over_commit=disk_over_commit) @@ -752,14 +623,6 @@ class SchedulerDriverBaseTestCase(SchedulerTestCase): """Test cases for base scheduler driver class methods that can't will fail if the driver is changed""" - def test_unimplemented_schedule(self): - fake_args = (1, 2, 3) - fake_kwargs = {'cat': 'meow'} - - self.assertRaises(NotImplementedError, self.driver.schedule, - self.context, self.topic, 'schedule_something', - *fake_args, **fake_kwargs) - def test_unimplemented_schedule_run_instance(self): fake_args = (1, 2, 3) fake_kwargs = {'cat': 'meow'} @@ -769,7 +632,7 @@ class SchedulerDriverBaseTestCase(SchedulerTestCase): self.assertRaises(NotImplementedError, self.driver.schedule_run_instance, self.context, fake_request_spec, None, None, None, - None, None, None) + None, None) def test_unimplemented_schedule_prep_resize(self): fake_args = (1, 2, 3) @@ -780,7 +643,7 @@ class SchedulerDriverBaseTestCase(SchedulerTestCase): self.assertRaises(NotImplementedError, self.driver.schedule_prep_resize, self.context, {}, - fake_request_spec, {}, {}, {}) + fake_request_spec, {}, {}, {}, None) class SchedulerDriverModuleTestCase(test.TestCase): |
