summaryrefslogtreecommitdiffstats
path: root/nova/tests/scheduler
diff options
context:
space:
mode:
authorRussell Bryant <rbryant@redhat.com>2012-08-03 22:50:21 -0400
committerRussell Bryant <rbryant@redhat.com>2012-08-06 15:09:33 -0400
commit98f753d4c5e8bdf31716a7452f89930a51b3edf5 (patch)
tree1bf25777e0c38629dd9dc8017dd124c290acf86b /nova/tests/scheduler
parent7677354e3ba0954158d33feef3667b0fe7dcc2a3 (diff)
downloadnova-98f753d4c5e8bdf31716a7452f89930a51b3edf5.tar.gz
nova-98f753d4c5e8bdf31716a7452f89930a51b3edf5.tar.xz
nova-98f753d4c5e8bdf31716a7452f89930a51b3edf5.zip
Send full instance to scheduler live_migration.
Remove the instance_id parameter and send a full instance dict to the live_migration method of the scheduler manager. This cuts down on some unnecessary database access in the scheduler. Part of blueprint no-db-messaging. Change-Id: Ic45105300c967c760559df2225e59e515cea8b7b
Diffstat (limited to 'nova/tests/scheduler')
-rw-r--r--nova/tests/scheduler/test_rpcapi.py3
-rw-r--r--nova/tests/scheduler/test_scheduler.py12
2 files changed, 5 insertions, 10 deletions
diff --git a/nova/tests/scheduler/test_rpcapi.py b/nova/tests/scheduler/test_rpcapi.py
index 20874c365..ff17d9183 100644
--- a/nova/tests/scheduler/test_rpcapi.py
+++ b/nova/tests/scheduler/test_rpcapi.py
@@ -95,7 +95,8 @@ class SchedulerRpcAPITestCase(test.TestCase):
self._test_scheduler_api('live_migration', rpc_method='call',
block_migration='fake_block_migration',
disk_over_commit='fake_disk_over_commit',
- instance_id='fake_id', dest='fake_dest', topic='fake_topic')
+ instance='fake_instance', dest='fake_dest', topic='fake_topic',
+ version='1.3')
def test_update_service_capabilities(self):
self._test_scheduler_api('update_service_capabilities',
diff --git a/nova/tests/scheduler/test_scheduler.py b/nova/tests/scheduler/test_scheduler.py
index 0c416dc72..3950d1ef6 100644
--- a/nova/tests/scheduler/test_scheduler.py
+++ b/nova/tests/scheduler/test_scheduler.py
@@ -403,7 +403,6 @@ class SchedulerTestCase(test.TestCase):
def test_live_migration_basic(self):
"""Test basic schedule_live_migration functionality"""
- 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(self.driver, '_live_migration_common_check')
@@ -416,11 +415,9 @@ class SchedulerTestCase(test.TestCase):
dest = 'fake_host2'
block_migration = False
disk_over_commit = False
- instance = self._live_migration_instance()
+ instance = jsonutils.to_primitive(self._live_migration_instance())
instance_id = instance['id']
instance_uuid = instance['uuid']
- 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)
@@ -441,14 +438,13 @@ class SchedulerTestCase(test.TestCase):
self.mox.ReplayAll()
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_all_checks_pass(self):
"""Test live migration when all checks pass."""
- self.mox.StubOutWithMock(db, 'instance_get')
self.mox.StubOutWithMock(utils, 'service_is_up')
self.mox.StubOutWithMock(db, 'service_get_all_compute_by_host')
self.mox.StubOutWithMock(db, 'instance_get_all_by_host')
@@ -463,8 +459,6 @@ class SchedulerTestCase(test.TestCase):
instance = jsonutils.to_primitive(self._live_migration_instance())
instance_id = instance['id']
instance_uuid = instance['uuid']
- db.instance_get(self.context,
- instance_id).AndReturn(instance)
# Source checks
db.service_get_all_compute_by_host(self.context,
@@ -511,7 +505,7 @@ class SchedulerTestCase(test.TestCase):
self.mox.ReplayAll()
result = 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)
self.assertEqual(result, None)