Added XenAPI rescue unit tests
This commit is contained in:
@@ -186,6 +186,7 @@ class XenAPIVMTestCase(test.TestCase):
|
|||||||
stubs.stubout_stream_disk(self.stubs)
|
stubs.stubout_stream_disk(self.stubs)
|
||||||
stubs.stubout_is_vdi_pv(self.stubs)
|
stubs.stubout_is_vdi_pv(self.stubs)
|
||||||
self.stubs.Set(VMOps, 'reset_network', reset_network)
|
self.stubs.Set(VMOps, 'reset_network', reset_network)
|
||||||
|
stubs.stub_out_vm_methods(self.stubs)
|
||||||
glance_stubs.stubout_glance_client(self.stubs,
|
glance_stubs.stubout_glance_client(self.stubs,
|
||||||
glance_stubs.FakeGlance)
|
glance_stubs.FakeGlance)
|
||||||
self.conn = xenapi_conn.get_connection(False)
|
self.conn = xenapi_conn.get_connection(False)
|
||||||
@@ -369,6 +370,17 @@ class XenAPIVMTestCase(test.TestCase):
|
|||||||
self.assertEquals(vif_rec['qos_algorithm_params']['kbps'],
|
self.assertEquals(vif_rec['qos_algorithm_params']['kbps'],
|
||||||
str(4 * 1024))
|
str(4 * 1024))
|
||||||
|
|
||||||
|
def test_rescue(self):
|
||||||
|
instance = self._create_instance()
|
||||||
|
conn = xenapi_conn.get_connection(False)
|
||||||
|
conn.rescue(instance, None)
|
||||||
|
|
||||||
|
def test_unrescue(self):
|
||||||
|
instance = self._create_instance()
|
||||||
|
conn = xenapi_conn.get_connection(False)
|
||||||
|
# Ensure that it will not unrescue a non-rescued instance.
|
||||||
|
self.assertRaises(Exception, conn.unrescue, instance, None)
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
super(XenAPIVMTestCase, self).tearDown()
|
super(XenAPIVMTestCase, self).tearDown()
|
||||||
self.manager.delete_project(self.project)
|
self.manager.delete_project(self.project)
|
||||||
|
|||||||
@@ -185,6 +185,25 @@ class FakeSessionForVMTests(fake.SessionBase):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
def stub_out_vm_methods(stubs):
|
||||||
|
def fake_shutdown(self, inst, vm, method="clean"):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def fake_acquire_bootlock(self, vm):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def fake_release_bootlock(self, vm):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def fake_spawn_rescue(self, inst):
|
||||||
|
pass
|
||||||
|
|
||||||
|
stubs.Set(vmops.VMOps, "_shutdown", fake_shutdown)
|
||||||
|
stubs.Set(vmops.VMOps, "_acquire_bootlock", fake_acquire_bootlock)
|
||||||
|
stubs.Set(vmops.VMOps, "_release_bootlock", fake_release_bootlock)
|
||||||
|
stubs.Set(vmops.VMOps, "spawn_rescue", fake_spawn_rescue)
|
||||||
|
|
||||||
|
|
||||||
class FakeSessionForVolumeTests(fake.SessionBase):
|
class FakeSessionForVolumeTests(fake.SessionBase):
|
||||||
""" Stubs out a XenAPISession for Volume tests """
|
""" Stubs out a XenAPISession for Volume tests """
|
||||||
def __init__(self, uri):
|
def __init__(self, uri):
|
||||||
|
|||||||
Reference in New Issue
Block a user