diff options
author | Russell Bryant <rbryant@redhat.com> | 2012-08-01 16:48:03 -0400 |
---|---|---|
committer | Russell Bryant <rbryant@redhat.com> | 2012-08-03 22:13:28 -0400 |
commit | 6e134c9df2ec05ebce9f62c6d85988ece18620ad (patch) | |
tree | 4aa467c5fe04990c3c51d7cfa5efd26b6f862117 /nova/tests | |
parent | 5fb51ea04b2ccff55f45af9e99cecd5d22f27a42 (diff) | |
download | nova-6e134c9df2ec05ebce9f62c6d85988ece18620ad.tar.gz nova-6e134c9df2ec05ebce9f62c6d85988ece18620ad.tar.xz nova-6e134c9df2ec05ebce9f62c6d85988ece18620ad.zip |
Updates to the prep_resize scheduler rpc call.
I started looking at this because of the prep_resize rpc call in the compute
manager. An API server calls prep_resize on the scheduler which then calls it
on a compute node. I will need to make the same changes on the compute side,
but this is the first step.
The prep_resize call was taking two object IDs, an instance UUID and an
instance_type ID. Both of these have been converted. It now takes an instance
dict and an instance_type dict, instead. It can also handle receiving the old
IDs for backwards compatibility. prep_resize also took a topic argument that
was unused, so it has just been removed.
There are a number of changes in the scheduler code tied up in this to make it
more explicit about exactly what arguments are expected instead of just using
*args, **kwargs.
Part of blueprint no-db-messaging.
Change-Id: I4af18e5575e2bb60a410fc8edabf3d607c72aabc
Diffstat (limited to 'nova/tests')
-rw-r--r-- | nova/tests/scheduler/test_chance_scheduler.py | 6 | ||||
-rw-r--r-- | nova/tests/scheduler/test_filter_scheduler.py | 2 | ||||
-rw-r--r-- | nova/tests/scheduler/test_rpcapi.py | 9 | ||||
-rw-r--r-- | nova/tests/scheduler/test_scheduler.py | 39 |
4 files changed, 35 insertions, 21 deletions
diff --git a/nova/tests/scheduler/test_chance_scheduler.py b/nova/tests/scheduler/test_chance_scheduler.py index ec853594b..eabfa93dc 100644 --- a/nova/tests/scheduler/test_chance_scheduler.py +++ b/nova/tests/scheduler/test_chance_scheduler.py @@ -149,7 +149,8 @@ class ChanceSchedulerTestCase(test_scheduler.SchedulerTestCase): self.mox.StubOutWithMock(driver, 'cast_to_compute_host') self.mox.StubOutWithMock(driver, 'encode_instance') # instance 1 - self.driver._schedule(ctxt, 'compute', request_spec).AndReturn('host') + 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) @@ -157,7 +158,8 @@ class ChanceSchedulerTestCase(test_scheduler.SchedulerTestCase): instance_uuid=instance1['uuid']) driver.encode_instance(instance1).AndReturn(instance1) # instance 2 - self.driver._schedule(ctxt, 'compute', request_spec).AndReturn('host') + 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) diff --git a/nova/tests/scheduler/test_filter_scheduler.py b/nova/tests/scheduler/test_filter_scheduler.py index 158fc0d83..648373945 100644 --- a/nova/tests/scheduler/test_filter_scheduler.py +++ b/nova/tests/scheduler/test_filter_scheduler.py @@ -111,7 +111,7 @@ class FilterSchedulerTestCase(test_scheduler.SchedulerTestCase): self.mox.StubOutWithMock(self.driver, '_provision_resource') self.driver._schedule(context_fake, 'compute', - request_spec, {}, **fake_kwargs + request_spec, {} ).AndReturn(['host1', 'host2']) # instance 1 self.driver._provision_resource( diff --git a/nova/tests/scheduler/test_rpcapi.py b/nova/tests/scheduler/test_rpcapi.py index 000138bc9..c881bc306 100644 --- a/nova/tests/scheduler/test_rpcapi.py +++ b/nova/tests/scheduler/test_rpcapi.py @@ -40,8 +40,9 @@ class SchedulerRpcAPITestCase(test.TestCase): ctxt = context.RequestContext('fake_user', 'fake_project') rpcapi = scheduler_rpcapi.SchedulerAPI() expected_retval = 'foo' if method == 'call' else None + expected_version = kwargs.pop('version', rpcapi.BASE_RPC_API_VERSION) expected_msg = rpcapi.make_msg(method, **kwargs) - expected_msg['version'] = rpcapi.BASE_RPC_API_VERSION + expected_msg['version'] = expected_version if rpc_method == 'cast' and method == 'run_instance': kwargs['call'] = False @@ -81,10 +82,10 @@ class SchedulerRpcAPITestCase(test.TestCase): def test_prep_resize(self): self._test_scheduler_api('prep_resize', rpc_method='cast', - topic='fake_topic', instance_uuid='fake_uuid', - instance_type_id='fake_type_id', image='fake_image', + instance='fake_instance', + instance_type='fake_type', image='fake_image', update_db='fake_update_db', request_spec='fake_request_spec', - filter_properties='fake_props') + filter_properties='fake_props', version='1.1') def test_show_host_resources(self): self._test_scheduler_api('show_host_resources', rpc_method='call', diff --git a/nova/tests/scheduler/test_scheduler.py b/nova/tests/scheduler/test_scheduler.py index ec30321d0..b9cb4de59 100644 --- a/nova/tests/scheduler/test_scheduler.py +++ b/nova/tests/scheduler/test_scheduler.py @@ -245,18 +245,23 @@ class SchedulerManagerTestCase(test.TestCase): request_spec = {'instance_properties': {'uuid': fake_instance_uuid}} - self.fake_kwargs['request_spec'] = request_spec - - self.manager.driver.schedule_prep_resize(self.context, - *self.fake_args, **self.fake_kwargs).AndRaise( - exception.NoValidHost(reason="")) + kwargs = { + 'context': self.context, + 'image': 'fake_image', + 'update_db': True, + 'request_spec': request_spec, + 'filter_properties': 'fake_props', + 'instance': 'fake_instance', + 'instance_type': 'fake_type', + } + self.manager.driver.schedule_prep_resize(**kwargs).AndRaise( + exception.NoValidHost(reason="")) db.instance_update_and_get_original(self.context, fake_instance_uuid, {"vm_state": vm_states.ACTIVE, "task_state": None}).AndReturn( (inst, inst)) self.mox.ReplayAll() - self.manager.prep_resize(self.context, self.topic, - *self.fake_args, **self.fake_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 @@ -270,10 +275,17 @@ class SchedulerManagerTestCase(test.TestCase): request_spec = {'instance_properties': {'uuid': fake_instance_uuid}} - self.fake_kwargs['request_spec'] = request_spec + kwargs = { + 'context': self.context, + 'image': 'fake_image', + 'update_db': True, + 'request_spec': request_spec, + 'filter_properties': 'fake_props', + 'instance': 'fake_instance', + 'instance_type': 'fake_type', + } - self.manager.driver.schedule_prep_resize(self.context, - *self.fake_args, **self.fake_kwargs).AndRaise( + self.manager.driver.schedule_prep_resize(**kwargs).AndRaise( self.AnException('something happened')) inst = { @@ -286,8 +298,7 @@ class SchedulerManagerTestCase(test.TestCase): self.mox.ReplayAll() self.assertRaises(self.AnException, self.manager.prep_resize, - self.context, self.topic, - *self.fake_args, **self.fake_kwargs) + **kwargs) class SchedulerTestCase(test.TestCase): @@ -772,8 +783,8 @@ class SchedulerDriverBaseTestCase(SchedulerTestCase): self.assertRaises(NotImplementedError, self.driver.schedule_prep_resize, - self.context, fake_request_spec, - *fake_args, **fake_kwargs) + self.context, {}, False, + fake_request_spec, {}, {}, {}) class SchedulerDriverModuleTestCase(test.TestCase): |