diff --git a/nova/tests/test_xenapi.py b/nova/tests/test_xenapi.py index ee8d5ae20..b09bacc42 100644 --- a/nova/tests/test_xenapi.py +++ b/nova/tests/test_xenapi.py @@ -789,6 +789,23 @@ class XenAPIMigrateInstance(test.TestCase): stubs.stubout_get_this_vm_uuid(self.stubs) glance_stubs.stubout_glance_client(self.stubs) + def test_resize_xenserver_6(self): + instance = db.instance_create(self.context, self.instance_values) + called = {'resize': False} + + def fake_vdi_resize(*args, **kwargs): + called['resize'] = True + + self.stubs.Set(stubs.FakeSessionForMigrationTests, + "VDI_resize", fake_vdi_resize) + stubs.stubout_session(self.stubs, + stubs.FakeSessionForMigrationTests, + product_version=(6, 0, 0)) + stubs.stubout_loopingcall_start(self.stubs) + conn = xenapi_conn.get_connection(False) + 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) stubs.stubout_session(self.stubs, stubs.FakeSessionForMigrationTests) diff --git a/nova/tests/xenapi/stubs.py b/nova/tests/xenapi/stubs.py index c79bda682..51ca78708 100644 --- a/nova/tests/xenapi/stubs.py +++ b/nova/tests/xenapi/stubs.py @@ -57,8 +57,8 @@ def stubout_instance_snapshot(stubs): stubs.Set(vm_utils, 'wait_for_vhd_coalesce', fake_wait_for_vhd_coalesce) -def stubout_session(stubs, cls): - """Stubs out two methods from XenAPISession""" +def stubout_session(stubs, cls, product_version=None): + """Stubs out three methods from XenAPISession""" def fake_import(self): """Stubs out get_imported_xenapi of XenAPISession""" fake_module = 'nova.virt.xenapi.fake' @@ -69,6 +69,10 @@ def stubout_session(stubs, cls): lambda s, url: cls(url)) stubs.Set(xenapi_conn.XenAPISession, 'get_imported_xenapi', fake_import) + if product_version is None: + product_version = (5, 6, 2) + stubs.Set(xenapi_conn.XenAPISession, 'get_product_version', + lambda s: product_version) def stub_out_get_target(stubs):