diff options
| author | Jenkins <jenkins@review.openstack.org> | 2012-11-13 21:06:42 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2012-11-13 21:06:42 +0000 |
| commit | b45ca52108a0b64f18885abb3c42cd4a2ff89ee8 (patch) | |
| tree | c67f1cb5f3889cc2083ba44fba74e96265cf17f0 /nova/tests | |
| parent | 083bccd34bc35dc043f17ff6ade66c64dd4bead2 (diff) | |
| parent | 3e25d9bc235381081210ca160bb1188ed05274ea (diff) | |
Merge "Add DB query to get in-progress migrations."
Diffstat (limited to 'nova/tests')
| -rw-r--r-- | nova/tests/test_db_api.py | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/nova/tests/test_db_api.py b/nova/tests/test_db_api.py index 7a71a1247..001880483 100644 --- a/nova/tests/test_db_api.py +++ b/nova/tests/test_db_api.py @@ -1013,6 +1013,55 @@ class CapacityTestCase(test.TestCase): self.assertEqual(1, int(stat['value'])) +class MigrationTestCase(test.TestCase): + + def setUp(self): + super(MigrationTestCase, self).setUp() + self.ctxt = context.get_admin_context() + + self._create() + self._create() + self._create(status='reverted') + self._create(status='confirmed') + self._create(source_compute='host2', dest_compute='host1') + self._create(source_compute='host2', dest_compute='host3') + self._create(source_compute='host3', dest_compute='host4') + + def _create(self, status='migrating', source_compute='host1', + dest_compute='host2'): + + values = {'host': source_compute} + instance = db.instance_create(self.ctxt, values) + + values = {'status': status, 'source_compute': source_compute, + 'dest_compute': dest_compute, + 'instance_uuid': instance['uuid']} + db.migration_create(self.ctxt, values) + + def _assert_in_progress(self, migrations): + for migration in migrations: + self.assertNotEqual('confirmed', migration.status) + self.assertNotEqual('reverted', migration.status) + + def test_in_progress_host1(self): + migrations = db.migration_get_in_progress_by_host(self.ctxt, 'host1') + # 2 as source + 1 as dest + self.assertEqual(3, len(migrations)) + self._assert_in_progress(migrations) + + def test_in_progress_host2(self): + migrations = db.migration_get_in_progress_by_host(self.ctxt, 'host2') + # 2 as dest, 2 as source + self.assertEqual(4, len(migrations)) + self._assert_in_progress(migrations) + + def test_instance_join(self): + migrations = db.migration_get_in_progress_by_host(self.ctxt, 'host2') + for migration in migrations: + instance = migration['instance'] + self.assertEqual(migration['instance_uuid'], instance['uuid']) + + class TestIpAllocation(test.TestCase): def setUp(self): |
