diff options
| author | Rick Harris <rconradharris@gmail.com> | 2011-10-10 17:58:56 -0500 |
|---|---|---|
| committer | Rick Harris <rconradharris@gmail.com> | 2011-10-13 18:46:38 -0500 |
| commit | 46d04831f5c290a40c14da415169749e2ef41383 (patch) | |
| tree | f3d20cf687ff074e719b861ab871bdc73c204e3f /nova/tests | |
| parent | 56be39aedb195576179e73c859db2271a9585496 (diff) | |
Xenapi driver can now generate swap from instance_type
Change-Id: I50268a85ccd62b019436a207c2b52b1901597564
Diffstat (limited to 'nova/tests')
| -rw-r--r-- | nova/tests/db/fakes.py | 15 | ||||
| -rw-r--r-- | nova/tests/test_xenapi.py | 29 |
2 files changed, 35 insertions, 9 deletions
diff --git a/nova/tests/db/fakes.py b/nova/tests/db/fakes.py index 6e6253c1d..d9bdb2351 100644 --- a/nova/tests/db/fakes.py +++ b/nova/tests/db/fakes.py @@ -352,33 +352,38 @@ def stub_out_db_instance_api(stubs, injected=True): vcpus=1, local_gb=0, flavorid=1, - rxtx_cap=1), + rxtx_cap=1, + swap=0), 'm1.small': dict(id=5, memory_mb=2048, vcpus=1, local_gb=20, flavorid=2, - rxtx_cap=2), + rxtx_cap=2, + swap=0), 'm1.medium': dict(id=1, memory_mb=4096, vcpus=2, local_gb=40, flavorid=3, - rxtx_cap=3), + rxtx_cap=3, + swap=0), 'm1.large': dict(id=3, memory_mb=8192, vcpus=4, local_gb=80, flavorid=4, - rxtx_cap=4), + rxtx_cap=4, + swap=0), 'm1.xlarge': dict(id=4, memory_mb=16384, vcpus=8, local_gb=160, flavorid=5, - rxtx_cap=5)} + rxtx_cap=5, + swap=0)} flat_network_fields = {'id': 'fake_flat', 'bridge': 'xenbr0', diff --git a/nova/tests/test_xenapi.py b/nova/tests/test_xenapi.py index 225d51aba..1d0639221 100644 --- a/nova/tests/test_xenapi.py +++ b/nova/tests/test_xenapi.py @@ -16,6 +16,7 @@ """Test suite for XenAPI.""" +import contextlib import functools import json import os @@ -55,10 +56,30 @@ def stub_vm_utils_with_vdi_attached_here(function, should_return=True): """ @functools.wraps(function) def decorated_function(self, *args, **kwargs): - orig_with_vdi_attached_here = vm_utils.with_vdi_attached_here - vm_utils.with_vdi_attached_here = lambda *x: should_return - function(self, *args, **kwargs) - vm_utils.with_vdi_attached_here = orig_with_vdi_attached_here + @contextlib.contextmanager + def fake_vdi_attached_here(*args, **kwargs): + fake_dev = 'fakedev' + yield fake_dev + + def fake_stream_disk(*args, **kwargs): + pass + + def fake_is_vdi_pv(*args, **kwargs): + return should_return + + orig_vdi_attached_here = vm_utils.vdi_attached_here + orig_stream_disk = vm_utils._stream_disk + orig_is_vdi_pv = vm_utils._is_vdi_pv + try: + vm_utils.vdi_attached_here = fake_vdi_attached_here + vm_utils._stream_disk = fake_stream_disk + vm_utils._is_vdi_pv = fake_is_vdi_pv + return function(self, *args, **kwargs) + finally: + vm_utils._is_vdi_pv = orig_is_vdi_pv + vm_utils._stream_disk = orig_stream_disk + vm_utils.vdi_attached_here = orig_vdi_attached_here + return decorated_function |
