summaryrefslogtreecommitdiffstats
path: root/nova/tests
diff options
context:
space:
mode:
authormatt.dietz@rackspace.com <>2011-03-08 23:45:19 +0000
committerTarmac <>2011-03-08 23:45:19 +0000
commita02c0db7cd72aa3d716116c87cab98b243b5b618 (patch)
tree460c660eb4ef22a120843879a5bfb7da0758f90b /nova/tests
parentca3314b82aa47fe54386d1169481836c07ae8913 (diff)
parent698398fdc2a05a0930591d3f3d386ad24a322359 (diff)
Fixes lp730960 - mangled instance creation in virt drivers due to improper merge conflict resolution
Diffstat (limited to 'nova/tests')
-rw-r--r--nova/tests/test_xenapi.py24
-rw-r--r--nova/tests/xenapi/stubs.py16
2 files changed, 34 insertions, 6 deletions
diff --git a/nova/tests/test_xenapi.py b/nova/tests/test_xenapi.py
index 7f437c2b8..c26dc8639 100644
--- a/nova/tests/test_xenapi.py
+++ b/nova/tests/test_xenapi.py
@@ -360,16 +360,28 @@ class XenAPIMigrateInstance(test.TestCase):
db_fakes.stub_out_db_instance_api(self.stubs)
stubs.stub_out_get_target(self.stubs)
xenapi_fake.reset()
+ self.manager = manager.AuthManager()
+ self.user = self.manager.create_user('fake', 'fake', 'fake',
+ admin=True)
+ self.project = self.manager.create_project('fake', 'fake', 'fake')
self.values = {'name': 1, 'id': 1,
- 'project_id': 'fake',
- 'user_id': 'fake',
+ 'project_id': self.project.id,
+ 'user_id': self.user.id,
'image_id': 1,
- 'kernel_id': 2,
- 'ramdisk_id': 3,
+ 'kernel_id': None,
+ 'ramdisk_id': None,
'instance_type': 'm1.large',
'mac_address': 'aa:bb:cc:dd:ee:ff',
}
stubs.stub_out_migration_methods(self.stubs)
+ glance_stubs.stubout_glance_client(self.stubs,
+ glance_stubs.FakeGlance)
+
+ def tearDown(self):
+ super(XenAPIMigrateInstance, self).tearDown()
+ self.manager.delete_project(self.project)
+ self.manager.delete_user(self.user)
+ self.stubs.UnsetAll()
def test_migrate_disk_and_power_off(self):
instance = db.instance_create(self.values)
@@ -377,11 +389,11 @@ class XenAPIMigrateInstance(test.TestCase):
conn = xenapi_conn.get_connection(False)
conn.migrate_disk_and_power_off(instance, '127.0.0.1')
- def test_attach_disk(self):
+ def test_finish_resize(self):
instance = db.instance_create(self.values)
stubs.stubout_session(self.stubs, stubs.FakeSessionForMigrationTests)
conn = xenapi_conn.get_connection(False)
- conn.attach_disk(instance, {'base_copy': 'hurr', 'cow': 'durr'})
+ conn.finish_resize(instance, dict(base_copy='hurr', cow='durr'))
class XenAPIDetermineDiskImageTestCase(test.TestCase):
diff --git a/nova/tests/xenapi/stubs.py b/nova/tests/xenapi/stubs.py
index 11e89c9b4..70d46a1fb 100644
--- a/nova/tests/xenapi/stubs.py
+++ b/nova/tests/xenapi/stubs.py
@@ -225,6 +225,18 @@ class FakeSessionForMigrationTests(fake.SessionBase):
def __init__(self, uri):
super(FakeSessionForMigrationTests, self).__init__(uri)
+ def VDI_get_by_uuid(*args):
+ return 'hurr'
+
+ def VM_start(self, _1, ref, _2, _3):
+ vm = fake.get_record('VM', ref)
+ if vm['power_state'] != 'Halted':
+ raise fake.Failure(['VM_BAD_POWER_STATE', ref, 'Halted',
+ vm['power_state']])
+ vm['power_state'] = 'Running'
+ vm['is_a_template'] = False
+ vm['is_control_domain'] = False
+
def stub_out_migration_methods(stubs):
def fake_get_snapshot(self, instance):
@@ -251,6 +263,9 @@ def stub_out_migration_methods(stubs):
def fake_destroy(*args, **kwargs):
pass
+ def fake_reset_network(*args, **kwargs):
+ pass
+
stubs.Set(vmops.VMOps, '_destroy', fake_destroy)
stubs.Set(vm_utils.VMHelper, 'scan_default_sr', fake_sr)
stubs.Set(vm_utils.VMHelper, 'scan_sr', fake_sr)
@@ -258,4 +273,5 @@ def stub_out_migration_methods(stubs):
stubs.Set(vm_utils.VMHelper, 'get_vdi_for_vm_safely', fake_get_vdi)
stubs.Set(xenapi_conn.XenAPISession, 'wait_for_task', lambda x, y, z: None)
stubs.Set(vm_utils.VMHelper, 'get_sr_path', fake_get_sr_path)
+ stubs.Set(vmops.VMOps, 'reset_network', fake_reset_network)
stubs.Set(vmops.VMOps, '_shutdown', fake_shutdown)