~ubuntu-branches/ubuntu/quantal/nova/quantal-proposed

« back to all changes in this revision

Viewing changes to nova/tests/test_xenapi.py

  • Committer: Package Import Robot
  • Author(s): Chuck Short
  • Date: 2011-12-09 14:24:07 UTC
  • mto: This revision was merged to the branch mainline in revision 55.
  • Revision ID: package-import@ubuntu.com-20111209142407-fviz6p5dnictpxsr
Tags: upstream-2012.1~e2~20111208.11721
ImportĀ upstreamĀ versionĀ 2012.1~e2~20111208.11721

Show diffs side-by-side

added added

removed removed

Lines of Context:
803
803
                              product_version=(6, 0, 0))
804
804
        stubs.stubout_loopingcall_start(self.stubs)
805
805
        conn = xenapi_conn.get_connection(False)
806
 
        conn._vmops.resize_instance(instance, '')
 
806
        conn._vmops._resize_instance(instance, '')
807
807
        self.assertEqual(called['resize'], True)
808
808
 
809
809
    def test_migrate_disk_and_power_off(self):
810
810
        instance = db.instance_create(self.context, self.instance_values)
 
811
        instance_type = db.instance_type_get_by_name(self.context, 'm1.large')
811
812
        stubs.stubout_session(self.stubs, stubs.FakeSessionForMigrationTests)
812
813
        conn = xenapi_conn.get_connection(False)
813
 
        conn.migrate_disk_and_power_off(self.context, instance, '127.0.0.1')
 
814
        conn.migrate_disk_and_power_off(self.context, instance,
 
815
                                        '127.0.0.1', instance_type)
814
816
 
815
817
    def test_migrate_disk_and_power_off_passes_exceptions(self):
816
818
        instance = db.instance_create(self.context, self.instance_values)
 
819
        instance_type = db.instance_type_get_by_name(self.context, 'm1.large')
817
820
        stubs.stubout_session(self.stubs, stubs.FakeSessionForMigrationTests)
818
821
 
819
822
        def fake_raise(*args, **kwargs):
823
826
        conn = xenapi_conn.get_connection(False)
824
827
        self.assertRaises(exception.MigrationError,
825
828
                          conn.migrate_disk_and_power_off,
826
 
                          self.context, instance, '127.0.0.1')
 
829
                          self.context, instance, '127.0.0.1', instance_type)
827
830
 
828
831
    def test_revert_migrate(self):
829
832
        instance = db.instance_create(self.context, self.instance_values)
1107
1110
    """Tests HostState, which holds metrics from XenServer that get
1108
1111
    reported back to the Schedulers."""
1109
1112
 
1110
 
    def _fake_safe_find_sr(self, session):
 
1113
    @classmethod
 
1114
    def _fake_safe_find_sr(cls, session):
1111
1115
        """None SR ref since we're ignoring it in FakeSR."""
1112
1116
        return None
1113
1117
 
1114
1118
    def test_host_state(self):
1115
1119
        self.stubs = stubout.StubOutForTesting()
1116
 
        self.stubs.Set(vm_utils, 'safe_find_sr', self._fake_safe_find_sr)
 
1120
        self.stubs.Set(vm_utils.VMHelper, 'safe_find_sr',
 
1121
                       self._fake_safe_find_sr)
1117
1122
        host_state = xenapi_conn.HostState(FakeSession())
1118
1123
        stats = host_state._stats
1119
1124
        self.assertEquals(stats['disk_total'], 10000)
1163
1168
    def assertIsPartitionCalled(self, called):
1164
1169
        marker = {"partition_called": False}
1165
1170
 
1166
 
        @classmethod
1167
 
        def fake_resize_partition_fs(cls, dev_path, partition_path):
 
1171
        def fake_resize_part_and_fs(dev, start, old, new):
1168
1172
            marker["partition_called"] = True
1169
 
 
1170
 
        self.stubs.Set(vm_utils.VMHelper, "_resize_partition_and_fs",
1171
 
                       fake_resize_partition_fs)
 
1173
        self.stubs.Set(vm_utils, "_resize_part_and_fs",
 
1174
                       fake_resize_part_and_fs)
1172
1175
 
1173
1176
        instance = db.instance_create(self.context, self.instance_values)
1174
1177
        disk_image_type = vm_utils.ImageType.DISK_VHD
1193
1196
        """Should not partition unless fail safes pass"""
1194
1197
        self.instance_values['auto_disk_config'] = True
1195
1198
 
1196
 
        @classmethod
1197
 
        def fake_resize_partition_allowed(cls, dev_path, partition_path):
1198
 
            return False
1199
 
 
1200
 
        self.stubs.Set(vm_utils.VMHelper, "_resize_partition_allowed",
1201
 
                       fake_resize_partition_allowed)
 
1199
        def fake_get_partitions(dev):
 
1200
            return [(1, 0, 100, 'ext4'), (2, 100, 200, 'ext4')]
 
1201
        self.stubs.Set(vm_utils, "_get_partitions",
 
1202
                       fake_get_partitions)
1202
1203
 
1203
1204
        self.assertIsPartitionCalled(False)
1204
1205
 
1209
1210
        """
1210
1211
        self.instance_values['auto_disk_config'] = True
1211
1212
 
1212
 
        @classmethod
1213
 
        def fake_resize_partition_allowed(cls, dev_path, partition_path):
1214
 
            return True
1215
 
        self.stubs.Set(vm_utils.VMHelper, "_resize_partition_allowed",
1216
 
                       fake_resize_partition_allowed)
 
1213
        def fake_get_partitions(dev):
 
1214
            return [(1, 0, 100, 'ext4')]
 
1215
        self.stubs.Set(vm_utils, "_get_partitions",
 
1216
                       fake_get_partitions)
1217
1217
 
1218
1218
        self.assertIsPartitionCalled(True)