diff options
| author | Matthew Hooker <matt@cloudscaling.com> | 2011-08-08 15:30:44 -0400 |
|---|---|---|
| committer | Matthew Hooker <matt@cloudscaling.com> | 2011-08-08 15:30:44 -0400 |
| commit | 4c7a33ee907ae7abcff020c75dde8ed320fe7aeb (patch) | |
| tree | 32480c25a298268e13e67e2cfc79c9a3cec879db | |
| parent | 23f6ec84a93638e880f60bec00db8587b9e3e8d8 (diff) | |
| download | nova-4c7a33ee907ae7abcff020c75dde8ed320fe7aeb.tar.gz nova-4c7a33ee907ae7abcff020c75dde8ed320fe7aeb.tar.xz nova-4c7a33ee907ae7abcff020c75dde8ed320fe7aeb.zip | |
assert that vmops.revert_migration is called
| -rw-r--r-- | nova/tests/test_xenapi.py | 25 | ||||
| -rw-r--r-- | nova/tests/xenapi/stubs.py | 4 |
2 files changed, 18 insertions, 11 deletions
diff --git a/nova/tests/test_xenapi.py b/nova/tests/test_xenapi.py index 8e3c88f8e..34aba140b 100644 --- a/nova/tests/test_xenapi.py +++ b/nova/tests/test_xenapi.py @@ -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.""" diff --git a/nova/tests/xenapi/stubs.py b/nova/tests/xenapi/stubs.py index 195e4d038..66c79d465 100644 --- a/nova/tests/xenapi/stubs.py +++ b/nova/tests/xenapi/stubs.py @@ -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): |
