From 74698ac6cb9cfd8ce69623562f8b4fe0a94a46b0 Mon Sep 17 00:00:00 2001 From: Russell Bryant Date: Tue, 20 Nov 2012 17:13:29 -0500 Subject: Add migration_update to conductor. This patch adds a migration_update method to the conductor API. This is used by the compute manager to push off db access to nova-conductor. The only field that compute was updating was the status, so that is the only field allowed by the API. Instead of just sending the miration_id to the conductor, we are sending all of the migration data. This is done in the spirit of 'no-db-messaging'. While no other data is needed right now, it's easier to send it all now than have to change the API later. Change-Id: Ic3150fbc6d5e7b0c9e41681950a7424129cbc968 --- nova/tests/compute/test_compute.py | 8 ++++---- nova/tests/conductor/test_conductor.py | 10 ++++++++++ 2 files changed, 14 insertions(+), 4 deletions(-) (limited to 'nova/tests') diff --git a/nova/tests/compute/test_compute.py b/nova/tests/compute/test_compute.py index 32cd3ca3e..96d1f4250 100644 --- a/nova/tests/compute/test_compute.py +++ b/nova/tests/compute/test_compute.py @@ -2754,10 +2754,10 @@ class ComputeTestCase(BaseTestCase): self.assertEqual(dest_compute, CONF.host) return migrations - def fake_migration_update(context, migration_id, values): + def fake_migration_update(context, m, status): for migration in migrations: - if migration['id'] == migration_id and 'status' in values: - migration['status'] = values['status'] + if migration['id'] == m['id']: + migration['status'] = status def fake_confirm_resize(context, instance): # raise exception for 'fake_uuid4' to check migration status @@ -2772,7 +2772,7 @@ class ComputeTestCase(BaseTestCase): fake_instance_get_by_uuid) self.stubs.Set(db, 'migration_get_unconfirmed_by_dest_compute', fake_migration_get_unconfirmed_by_dest_compute) - self.stubs.Set(db, 'migration_update', + self.stubs.Set(self.compute.conductor_api, 'migration_update', fake_migration_update) self.stubs.Set(self.compute.compute_api, 'confirm_resize', fake_confirm_resize) diff --git a/nova/tests/conductor/test_conductor.py b/nova/tests/conductor/test_conductor.py index e3138fd34..d3c555822 100644 --- a/nova/tests/conductor/test_conductor.py +++ b/nova/tests/conductor/test_conductor.py @@ -24,6 +24,7 @@ from nova import context from nova import db from nova.db.sqlalchemy import models from nova import notifications +from nova.openstack.common import jsonutils from nova import test @@ -88,6 +89,15 @@ class ConductorTestCase(BaseTestCase): self.assertRaises(KeyError, self._do_update, 'any-uuid', foobar=1) + def test_migration_update(self): + migration = db.migration_create(self.context.elevated(), + {'instance_uuid': 'fake-uuid', + 'status': 'migrating'}) + migration_p = jsonutils.to_primitive(migration) + migration = self.conductor.migration_update(self.context, migration_p, + 'finished') + self.assertEqual(migration['status'], 'finished') + class ConductorRPCAPITestCase(ConductorTestCase): """Conductor RPC API Tests""" -- cgit