assert that vmops.revert_migration is called
This commit is contained in:
@@ -637,6 +637,24 @@ class XenAPIVMTestCase(test.TestCase):
|
||||
# Ensure that it will not unrescue a non-rescued instance.
|
||||
self.assertRaises(Exception, conn.unrescue, instance, None)
|
||||
|
||||
def test_revert_migration(self):
|
||||
instance = self._create_instance()
|
||||
|
||||
class VMOpsMock():
|
||||
|
||||
def __init__(self):
|
||||
self.revert_migration_called = False
|
||||
|
||||
def revert_migration(self, instance):
|
||||
self.revert_migration_called = True
|
||||
|
||||
stubs.stubout_session(self.stubs, stubs.FakeSessionForMigrationTests)
|
||||
|
||||
conn = xenapi_conn.get_connection(False)
|
||||
conn._vmops = VMOpsMock()
|
||||
conn.revert_migration(instance)
|
||||
self.assertTrue(conn._vmops.revert_migration_called)
|
||||
|
||||
def _create_instance(self, instance_id=1, spawn=True):
|
||||
"""Creates and spawns a test instance."""
|
||||
stubs.stubout_loopingcall_start(self.stubs)
|
||||
@@ -669,13 +687,6 @@ class XenAPIVMTestCase(test.TestCase):
|
||||
self.conn.spawn(instance, network_info)
|
||||
return instance
|
||||
|
||||
def test_revert_migration(self):
|
||||
instance = self._create_instance()
|
||||
stubs.stubout_session(self.stubs, stubs.FakeSessionForMigrationTests)
|
||||
stubs.stubout_loopingcall_start(self.stubs)
|
||||
conn = xenapi_conn.get_connection(False)
|
||||
conn.revert_migration(instance)
|
||||
|
||||
|
||||
class XenAPIDiffieHellmanTestCase(test.TestCase):
|
||||
"""Unit tests for Diffie-Hellman code."""
|
||||
|
||||
@@ -230,14 +230,10 @@ def stub_out_vm_methods(stubs):
|
||||
def fake_spawn_rescue(self, inst):
|
||||
inst._rescue = False
|
||||
|
||||
def fake_revert_migration(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)
|
||||
stubs.Set(vmops.VMOps, "revert_migration", fake_revert_migration)
|
||||
|
||||
|
||||
class FakeSessionForVolumeTests(fake.SessionBase):
|
||||
|
||||
Reference in New Issue
Block a user