diff options
| author | Jenkins <jenkins@review.openstack.org> | 2012-09-13 05:36:31 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2012-09-13 05:36:31 +0000 |
| commit | ef8d6a57a166d20782d8ad284b2b72aa4ec48572 (patch) | |
| tree | 773871b4f956040caae705a3d3621be7f9895362 /nova/tests | |
| parent | e72db9fe9345c48f4ea287643306d884c82f04f4 (diff) | |
| parent | a3bdc1624fd557e0699acb049b1ca0c1ef894c2f (diff) | |
Merge "Avoid live migrate overwriting the other task_state"
Diffstat (limited to 'nova/tests')
| -rw-r--r-- | nova/tests/api/openstack/compute/contrib/test_admin_actions.py | 7 | ||||
| -rw-r--r-- | nova/tests/compute/test_compute.py | 17 | ||||
| -rw-r--r-- | nova/tests/scheduler/test_scheduler.py | 12 |
3 files changed, 24 insertions, 12 deletions
diff --git a/nova/tests/api/openstack/compute/contrib/test_admin_actions.py b/nova/tests/api/openstack/compute/contrib/test_admin_actions.py index 6e075e974..fbd81d283 100644 --- a/nova/tests/api/openstack/compute/contrib/test_admin_actions.py +++ b/nova/tests/api/openstack/compute/contrib/test_admin_actions.py @@ -139,6 +139,13 @@ class AdminActionsTest(test.TestCase): } }) req.content_type = 'application/json' + + def fake_update(inst, context, instance, + task_state, expected_task_state): + return None + + self.stubs.Set(compute.API, 'update', fake_update) + res = req.get_response(app) self.assertEqual(res.status_int, 202) diff --git a/nova/tests/compute/test_compute.py b/nova/tests/compute/test_compute.py index fe54aad90..ca49a560a 100644 --- a/nova/tests/compute/test_compute.py +++ b/nova/tests/compute/test_compute.py @@ -80,6 +80,10 @@ class FakeSchedulerAPI(object): filter_properties): pass + def live_migration(self, ctxt, block_migration, disk_over_commit, + instance, dest): + pass + class BaseTestCase(test.TestCase): @@ -4483,6 +4487,19 @@ class ComputeAPITestCase(BaseTestCase): self.security_group_api.trigger_rules_refresh(self.context, [1, 2]) + def test_live_migrate(self): + instance, instance_uuid = self._run_instance() + + self.compute_api.live_migrate(self.context, instance, + block_migration=True, + disk_over_commit=True, + host='fake_dest_host') + + instance = db.instance_get_by_uuid(self.context, instance_uuid) + self.assertEqual(instance['task_state'], task_states.MIGRATING) + + db.instance_destroy(self.context, instance['uuid']) + def fake_rpc_method(context, topic, msg, do_cast=True): pass diff --git a/nova/tests/scheduler/test_scheduler.py b/nova/tests/scheduler/test_scheduler.py index c5276819e..2e732546c 100644 --- a/nova/tests/scheduler/test_scheduler.py +++ b/nova/tests/scheduler/test_scheduler.py @@ -311,10 +311,8 @@ class SchedulerTestCase(test.TestCase): self.mox.StubOutWithMock(self.driver, '_live_migration_common_check') self.mox.StubOutWithMock(self.driver.compute_rpcapi, 'check_can_live_migrate_destination') - self.mox.StubOutWithMock(db, 'instance_update_and_get_original') self.mox.StubOutWithMock(self.driver.compute_rpcapi, 'live_migration') - self.mox.StubOutWithMock(notifications, 'send_update') dest = 'fake_host2' block_migration = False @@ -330,11 +328,6 @@ class SchedulerTestCase(test.TestCase): self.driver.compute_rpcapi.check_can_live_migrate_destination( self.context, instance, dest, block_migration, disk_over_commit).AndReturn({}) - db.instance_update_and_get_original(self.context, instance_uuid, - {"task_state": task_states.MIGRATING}).AndReturn( - (instance, instance)) - notifications.send_update(self.context, instance, instance, - service="scheduler") self.driver.compute_rpcapi.live_migration(self.context, host=instance['host'], instance=instance, dest=dest, block_migration=block_migration, migrate_data={}) @@ -353,7 +346,6 @@ class SchedulerTestCase(test.TestCase): self.mox.StubOutWithMock(db, 'instance_get_all_by_host') self.mox.StubOutWithMock(rpc, 'call') self.mox.StubOutWithMock(rpc, 'cast') - self.mox.StubOutWithMock(db, 'instance_update_and_get_original') self.mox.StubOutWithMock(self.driver.compute_rpcapi, 'live_migration') @@ -398,10 +390,6 @@ class SchedulerTestCase(test.TestCase): "version": compute_rpcapi.ComputeAPI.BASE_RPC_API_VERSION}, None).AndReturn({}) - db.instance_update_and_get_original(self.context, instance_uuid, - {"task_state": task_states.MIGRATING}).AndReturn( - (instance, instance)) - self.driver.compute_rpcapi.live_migration(self.context, host=instance['host'], instance=instance, dest=dest, block_migration=block_migration, migrate_data={}) |
