diff options
| author | Jenkins <jenkins@review.openstack.org> | 2011-12-05 21:16:40 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2011-12-05 21:16:40 +0000 |
| commit | e3ecd38debf3258660e703b065db0799cbbafcfb (patch) | |
| tree | c2a8bad8ebf39420f51bc738bb6a1150e6cc67c5 /nova/tests | |
| parent | b3c9a019dca8fc54116999939915298b30c3fbb9 (diff) | |
| parent | c25f7e7e832472ea2b5801d041cbf126333b1aaa (diff) | |
Merge "Implement resize down for XenAPI"
Diffstat (limited to 'nova/tests')
| -rw-r--r-- | nova/tests/test_compute.py | 17 | ||||
| -rw-r--r-- | nova/tests/test_virt_drivers.py | 3 | ||||
| -rw-r--r-- | nova/tests/test_xenapi.py | 36 | ||||
| -rw-r--r-- | nova/tests/utils.py | 15 |
4 files changed, 34 insertions, 37 deletions
diff --git a/nova/tests/test_compute.py b/nova/tests/test_compute.py index 1affd6b87..bccc590c3 100644 --- a/nova/tests/test_compute.py +++ b/nova/tests/test_compute.py @@ -1568,23 +1568,6 @@ class ComputeAPITestCase(BaseTestCase): self.compute.terminate_instance(context, instance['uuid']) - def test_resize_down_fails(self): - """Ensure resizing down raises and fails""" - instance = self._create_fake_instance() - context = self.context.elevated() - instance = db.instance_get_by_uuid(context, instance['uuid']) - self.compute.run_instance(self.context, instance['uuid']) - - inst_type = instance_types.get_instance_type_by_name('m1.xlarge') - db.instance_update(self.context, instance['uuid'], - {'instance_type_id': inst_type['id']}) - - instance = db.instance_get_by_uuid(context, instance['uuid']) - self.assertRaises(exception.CannotResizeToSmallerSize, - self.compute_api.resize, context, instance, 1) - - self.compute.terminate_instance(context, instance['uuid']) - def test_resize_same_size_fails(self): """Ensure invalid flavors raise""" context = self.context.elevated() diff --git a/nova/tests/test_virt_drivers.py b/nova/tests/test_virt_drivers.py index 8b4fa177f..8c5cda6f0 100644 --- a/nova/tests/test_virt_drivers.py +++ b/nova/tests/test_virt_drivers.py @@ -173,8 +173,9 @@ class _VirtDriverTestCase(test.TestCase): @catch_notimplementederror def test_migrate_disk_and_power_off(self): instance_ref, network_info = self._get_running_instance() + instance_type_ref = test_utils.get_test_instance_type() self.connection.migrate_disk_and_power_off( - self.ctxt, instance_ref, 'dest_host') + self.ctxt, instance_ref, 'dest_host', instance_type_ref) @catch_notimplementederror def test_pause(self): diff --git a/nova/tests/test_xenapi.py b/nova/tests/test_xenapi.py index 906f176fd..c72ee37a7 100644 --- a/nova/tests/test_xenapi.py +++ b/nova/tests/test_xenapi.py @@ -803,17 +803,20 @@ class XenAPIMigrateInstance(test.TestCase): product_version=(6, 0, 0)) stubs.stubout_loopingcall_start(self.stubs) conn = xenapi_conn.get_connection(False) - conn._vmops.resize_instance(instance, '') + conn._vmops._resize_instance(instance, '') self.assertEqual(called['resize'], True) def test_migrate_disk_and_power_off(self): instance = db.instance_create(self.context, self.instance_values) + instance_type = db.instance_type_get_by_name(self.context, 'm1.large') stubs.stubout_session(self.stubs, stubs.FakeSessionForMigrationTests) conn = xenapi_conn.get_connection(False) - conn.migrate_disk_and_power_off(self.context, instance, '127.0.0.1') + conn.migrate_disk_and_power_off(self.context, instance, + '127.0.0.1', instance_type) def test_migrate_disk_and_power_off_passes_exceptions(self): instance = db.instance_create(self.context, self.instance_values) + instance_type = db.instance_type_get_by_name(self.context, 'm1.large') stubs.stubout_session(self.stubs, stubs.FakeSessionForMigrationTests) def fake_raise(*args, **kwargs): @@ -823,7 +826,7 @@ class XenAPIMigrateInstance(test.TestCase): conn = xenapi_conn.get_connection(False) self.assertRaises(exception.MigrationError, conn.migrate_disk_and_power_off, - self.context, instance, '127.0.0.1') + self.context, instance, '127.0.0.1', instance_type) def test_revert_migrate(self): instance = db.instance_create(self.context, self.instance_values) @@ -1163,12 +1166,10 @@ class XenAPIAutoDiskConfigTestCase(test.TestCase): def assertIsPartitionCalled(self, called): marker = {"partition_called": False} - @classmethod - def fake_resize_partition_fs(cls, dev_path, partition_path): + def fake_resize_part_and_fs(dev, start, old, new): marker["partition_called"] = True - - self.stubs.Set(vm_utils.VMHelper, "_resize_partition_and_fs", - fake_resize_partition_fs) + self.stubs.Set(vm_utils, "_resize_part_and_fs", + fake_resize_part_and_fs) instance = db.instance_create(self.context, self.instance_values) disk_image_type = vm_utils.ImageType.DISK_VHD @@ -1193,12 +1194,10 @@ class XenAPIAutoDiskConfigTestCase(test.TestCase): """Should not partition unless fail safes pass""" self.instance_values['auto_disk_config'] = True - @classmethod - def fake_resize_partition_allowed(cls, dev_path, partition_path): - return False - - self.stubs.Set(vm_utils.VMHelper, "_resize_partition_allowed", - fake_resize_partition_allowed) + def fake_get_partitions(dev): + return [(1, 0, 100, 'ext4'), (2, 100, 200, 'ext4')] + self.stubs.Set(vm_utils, "_get_partitions", + fake_get_partitions) self.assertIsPartitionCalled(False) @@ -1209,10 +1208,9 @@ class XenAPIAutoDiskConfigTestCase(test.TestCase): """ self.instance_values['auto_disk_config'] = True - @classmethod - def fake_resize_partition_allowed(cls, dev_path, partition_path): - return True - self.stubs.Set(vm_utils.VMHelper, "_resize_partition_allowed", - fake_resize_partition_allowed) + def fake_get_partitions(dev): + return [(1, 0, 100, 'ext4')] + self.stubs.Set(vm_utils, "_get_partitions", + fake_get_partitions) self.assertIsPartitionCalled(True) diff --git a/nova/tests/utils.py b/nova/tests/utils.py index e5de01275..cc387fbcd 100644 --- a/nova/tests/utils.py +++ b/nova/tests/utils.py @@ -34,6 +34,21 @@ def get_test_image_info(context, instance_ref): return image_service.show(context, image_id) +def get_test_instance_type(context=None): + if not context: + context = get_test_admin_context() + + test_instance_type = {'name': 'kinda.big', + 'memory_mb': 2048, + 'vcpus': 4, + 'local_gb': 40, + 'swap': 1024} + + instance_type_ref = nova.db.instance_type_create(context, + test_instance_type) + return instance_type_ref + + def get_test_instance(context=None): if not context: context = get_test_admin_context() |
