diff options
author | Chris Behrens <cbehrens@codestud.com> | 2012-08-08 21:09:14 +0000 |
---|---|---|
committer | Chris Behrens <cbehrens@codestud.com> | 2012-08-08 22:49:27 +0000 |
commit | 10a5f1ac025f89f84398be308455b72d77602cc3 (patch) | |
tree | 39daef4810ec46b84940ce0f78f6d03d133386de /nova/tests/scheduler | |
parent | 28a03d9aded97732038eadd5bbcb21282f1b246a (diff) | |
download | nova-10a5f1ac025f89f84398be308455b72d77602cc3.tar.gz nova-10a5f1ac025f89f84398be308455b72d77602cc3.tar.xz nova-10a5f1ac025f89f84398be308455b72d77602cc3.zip |
scheduler prep_resize should not update instance['host']
This is done by the manager once things are ready on the destination
compute node.
Fixes bug 1034593
Also removes now-unneeded update_db argument passed via rpcapi and bumps
scheduler rpcapi version for prep_resize to 1.4
Change-Id: I0ac3be39877f3afcf42f5996d0da90042fe7c6e3
Diffstat (limited to 'nova/tests/scheduler')
-rw-r--r-- | nova/tests/scheduler/test_chance_scheduler.py | 24 | ||||
-rw-r--r-- | nova/tests/scheduler/test_filter_scheduler.py | 27 | ||||
-rw-r--r-- | nova/tests/scheduler/test_rpcapi.py | 4 | ||||
-rw-r--r-- | nova/tests/scheduler/test_scheduler.py | 69 |
4 files changed, 70 insertions, 54 deletions
diff --git a/nova/tests/scheduler/test_chance_scheduler.py b/nova/tests/scheduler/test_chance_scheduler.py index 663044ee8..d8eb2ade6 100644 --- a/nova/tests/scheduler/test_chance_scheduler.py +++ b/nova/tests/scheduler/test_chance_scheduler.py @@ -253,3 +253,27 @@ class ChanceSchedulerTestCase(test_scheduler.SchedulerTestCase): self.assertRaises(exception.NoValidHost, self.driver.schedule, ctxt, topic, method, *fake_args, **fake_kwargs) + + def test_schedule_prep_resize_doesnt_update_host(self): + fake_context = context.RequestContext('user', 'project', + is_admin=True) + + def _return_host(*args, **kwargs): + return 'host2' + + self.stubs.Set(self.driver, '_schedule', _return_host) + + info = {'called': 0} + + def _fake_instance_update_db(*args, **kwargs): + # This should not be called + info['called'] = 1 + + self.stubs.Set(driver, 'instance_update_db', + _fake_instance_update_db) + + instance = {'uuid': 'fake-uuid', 'host': 'host1'} + + self.driver.schedule_prep_resize(fake_context, {}, {}, {}, + instance, {}) + self.assertEqual(info['called'], 0) diff --git a/nova/tests/scheduler/test_filter_scheduler.py b/nova/tests/scheduler/test_filter_scheduler.py index acfb82b18..1ea57b4cf 100644 --- a/nova/tests/scheduler/test_filter_scheduler.py +++ b/nova/tests/scheduler/test_filter_scheduler.py @@ -20,6 +20,7 @@ import mox from nova import context from nova import exception +from nova.scheduler import driver from nova.scheduler import filter_scheduler from nova.scheduler import host_manager from nova.scheduler import least_cost @@ -167,6 +168,32 @@ class FilterSchedulerTestCase(test_scheduler.SchedulerTestCase): for weighted_host in weighted_hosts: self.assertTrue(weighted_host.host_state is not None) + def test_schedule_prep_resize_doesnt_update_host(self): + fake_context = context.RequestContext('user', 'project', + is_admin=True) + + sched = fakes.FakeFilterScheduler() + + def _return_hosts(*args, **kwargs): + host_state = host_manager.HostState('host2', 'compute') + return [least_cost.WeightedHost(1.0, host_state=host_state)] + + self.stubs.Set(sched, '_schedule', _return_hosts) + + info = {'called': 0} + + def _fake_instance_update_db(*args, **kwargs): + # This should not be called + info['called'] = 1 + + self.stubs.Set(driver, 'instance_update_db', + _fake_instance_update_db) + + instance = {'uuid': 'fake-uuid', 'host': 'host1'} + + sched.schedule_prep_resize(fake_context, {}, {}, {}, instance, {}) + self.assertEqual(info['called'], 0) + def test_get_cost_functions(self): self.flags(reserved_host_memory_mb=128) fixture = fakes.FakeFilterScheduler() diff --git a/nova/tests/scheduler/test_rpcapi.py b/nova/tests/scheduler/test_rpcapi.py index ff17d9183..109ff36a3 100644 --- a/nova/tests/scheduler/test_rpcapi.py +++ b/nova/tests/scheduler/test_rpcapi.py @@ -84,8 +84,8 @@ class SchedulerRpcAPITestCase(test.TestCase): self._test_scheduler_api('prep_resize', rpc_method='cast', instance='fake_instance', instance_type='fake_type', image='fake_image', - update_db='fake_update_db', request_spec='fake_request_spec', - filter_properties='fake_props', version='1.1') + request_spec='fake_request_spec', + filter_properties='fake_props', version='1.4') 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 cfb6d862d..44918550a 100644 --- a/nova/tests/scheduler/test_scheduler.py +++ b/nova/tests/scheduler/test_scheduler.py @@ -247,7 +247,6 @@ class SchedulerManagerTestCase(test.TestCase): kwargs = { 'context': self.context, 'image': 'fake_image', - 'update_db': True, 'request_spec': request_spec, 'filter_properties': 'fake_props', 'instance': 'fake_instance', @@ -260,7 +259,8 @@ class SchedulerManagerTestCase(test.TestCase): (inst, inst)) self.mox.ReplayAll() - self.manager.prep_resize(**kwargs) + # FIXME(comstud): Remove 'update_db' on future RPC version bump. + self.manager.prep_resize(update_db=False, **kwargs) def test_prep_resize_exception_host_in_error_state_and_raise(self): """Test that a NoValidHost exception for prep_resize puts @@ -277,7 +277,6 @@ class SchedulerManagerTestCase(test.TestCase): kwargs = { 'context': self.context, 'image': 'fake_image', - 'update_db': True, 'request_spec': request_spec, 'filter_properties': 'fake_props', 'instance': 'fake_instance', @@ -296,7 +295,9 @@ 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) @@ -774,7 +775,7 @@ class SchedulerDriverBaseTestCase(SchedulerTestCase): self.assertRaises(NotImplementedError, self.driver.schedule_prep_resize, - self.context, {}, False, + self.context, {}, fake_request_spec, {}, {}, {}) @@ -807,7 +808,7 @@ class SchedulerDriverModuleTestCase(test.TestCase): self.mox.ReplayAll() driver.cast_to_volume_host(self.context, host, method, - update_db=True, **fake_kwargs) + **fake_kwargs) def test_cast_to_volume_host_update_db_without_volume_id(self): host = 'fake_host1' @@ -825,25 +826,7 @@ class SchedulerDriverModuleTestCase(test.TestCase): self.mox.ReplayAll() driver.cast_to_volume_host(self.context, host, method, - update_db=True, **fake_kwargs) - - def test_cast_to_volume_host_no_update_db(self): - host = 'fake_host1' - method = 'fake_method' - fake_kwargs = {'extra_arg': 'meow'} - queue = 'fake_queue' - - self.mox.StubOutWithMock(rpc, 'queue_get_for') - self.mox.StubOutWithMock(rpc, 'cast') - - rpc.queue_get_for(self.context, 'volume', host).AndReturn(queue) - rpc.cast(self.context, queue, - {'method': method, - 'args': fake_kwargs}) - - self.mox.ReplayAll() - driver.cast_to_volume_host(self.context, host, method, - update_db=False, **fake_kwargs) + **fake_kwargs) def test_cast_to_compute_host_update_db_with_instance_uuid(self): host = 'fake_host1' @@ -867,7 +850,7 @@ class SchedulerDriverModuleTestCase(test.TestCase): self.mox.ReplayAll() driver.cast_to_compute_host(self.context, host, method, - update_db=True, **fake_kwargs) + **fake_kwargs) def test_cast_to_compute_host_update_db_without_instance_uuid(self): host = 'fake_host1' @@ -885,25 +868,7 @@ class SchedulerDriverModuleTestCase(test.TestCase): self.mox.ReplayAll() driver.cast_to_compute_host(self.context, host, method, - update_db=True, **fake_kwargs) - - def test_cast_to_compute_host_no_update_db(self): - host = 'fake_host1' - method = 'fake_method' - fake_kwargs = {'extra_arg': 'meow'} - queue = 'fake_queue' - - self.mox.StubOutWithMock(rpc, 'queue_get_for') - self.mox.StubOutWithMock(rpc, 'cast') - - rpc.queue_get_for(self.context, 'compute', host).AndReturn(queue) - rpc.cast(self.context, queue, - {'method': method, - 'args': fake_kwargs}) - - self.mox.ReplayAll() - driver.cast_to_compute_host(self.context, host, method, - update_db=False, **fake_kwargs) + **fake_kwargs) def test_cast_to_network_host(self): host = 'fake_host1' @@ -921,7 +886,7 @@ class SchedulerDriverModuleTestCase(test.TestCase): self.mox.ReplayAll() driver.cast_to_network_host(self.context, host, method, - update_db=True, **fake_kwargs) + **fake_kwargs) def test_cast_to_host_compute_topic(self): host = 'fake_host1' @@ -930,11 +895,11 @@ class SchedulerDriverModuleTestCase(test.TestCase): self.mox.StubOutWithMock(driver, 'cast_to_compute_host') driver.cast_to_compute_host(self.context, host, method, - update_db=False, **fake_kwargs) + **fake_kwargs) self.mox.ReplayAll() driver.cast_to_host(self.context, 'compute', host, method, - update_db=False, **fake_kwargs) + **fake_kwargs) def test_cast_to_host_volume_topic(self): host = 'fake_host1' @@ -943,11 +908,11 @@ class SchedulerDriverModuleTestCase(test.TestCase): self.mox.StubOutWithMock(driver, 'cast_to_volume_host') driver.cast_to_volume_host(self.context, host, method, - update_db=False, **fake_kwargs) + **fake_kwargs) self.mox.ReplayAll() driver.cast_to_host(self.context, 'volume', host, method, - update_db=False, **fake_kwargs) + **fake_kwargs) def test_cast_to_host_network_topic(self): host = 'fake_host1' @@ -956,11 +921,11 @@ class SchedulerDriverModuleTestCase(test.TestCase): self.mox.StubOutWithMock(driver, 'cast_to_network_host') driver.cast_to_network_host(self.context, host, method, - update_db=False, **fake_kwargs) + **fake_kwargs) self.mox.ReplayAll() driver.cast_to_host(self.context, 'network', host, method, - update_db=False, **fake_kwargs) + **fake_kwargs) def test_cast_to_host_unknown_topic(self): host = 'fake_host1' @@ -979,7 +944,7 @@ class SchedulerDriverModuleTestCase(test.TestCase): self.mox.ReplayAll() driver.cast_to_host(self.context, topic, host, method, - update_db=False, **fake_kwargs) + **fake_kwargs) def test_encode_instance(self): instance = {'id': 31337, |