summaryrefslogtreecommitdiffstats
path: root/nova/tests
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2013-02-08 00:19:45 +0000
committerGerrit Code Review <review@openstack.org>2013-02-08 00:19:45 +0000
commit148b34feefbaed561b1269c53320638fa71abfcf (patch)
tree7e080780873fdba92d85c18346c455ada6147b4f /nova/tests
parentbce3806efec31fb0fa536b152d763b333d75120d (diff)
parentf0c9c85760605f0b7460d9bc08ac79487703a6fd (diff)
Merge "Recache or rebuild missing images on hard_reboot"
Diffstat (limited to 'nova/tests')
-rw-r--r--nova/tests/compute/test_compute.py5
-rw-r--r--nova/tests/test_hypervapi.py3
-rw-r--r--nova/tests/test_imagebackend.py9
-rw-r--r--nova/tests/test_libvirt.py4
-rw-r--r--nova/tests/test_virt_drivers.py10
-rw-r--r--nova/tests/test_vmwareapi.py9
-rw-r--r--nova/tests/test_xenapi.py10
7 files changed, 32 insertions, 18 deletions
diff --git a/nova/tests/compute/test_compute.py b/nova/tests/compute/test_compute.py
index 1584cde34..442832553 100644
--- a/nova/tests/compute/test_compute.py
+++ b/nova/tests/compute/test_compute.py
@@ -1126,8 +1126,9 @@ class ComputeTestCase(BaseTestCase):
# this is called with the wrong args, so we have to hack
# around it.
reboot_call_info = {}
- expected_call_info = {'args': (updated_instance1, expected_nw_info,
- reboot_type, fake_block_dev_info),
+ expected_call_info = {'args': (econtext, updated_instance1,
+ expected_nw_info, reboot_type,
+ fake_block_dev_info),
'kwargs': {}}
def fake_reboot(*args, **kwargs):
diff --git a/nova/tests/test_hypervapi.py b/nova/tests/test_hypervapi.py
index 3b624e6d1..0c2f90a4d 100644
--- a/nova/tests/test_hypervapi.py
+++ b/nova/tests/test_hypervapi.py
@@ -486,7 +486,8 @@ class HyperVAPITestCase(test.TestCase):
constants.HYPERV_VM_STATE_REBOOT)
self._mox.ReplayAll()
- self._conn.reboot(self._instance_data, network_info, None)
+ self._conn.reboot(self._context, self._instance_data, network_info,
+ None)
self._mox.VerifyAll()
def test_destroy(self):
diff --git a/nova/tests/test_imagebackend.py b/nova/tests/test_imagebackend.py
index 495e7c947..76fd1d5b6 100644
--- a/nova/tests/test_imagebackend.py
+++ b/nova/tests/test_imagebackend.py
@@ -55,8 +55,8 @@ class _ImageTestCase(object):
def test_cache(self):
self.mox.StubOutWithMock(os.path, 'exists')
- os.path.exists(self.PATH).AndReturn(False)
os.path.exists(self.TEMPLATE_DIR).AndReturn(False)
+ os.path.exists(self.PATH).AndReturn(False)
os.path.exists(self.TEMPLATE_PATH).AndReturn(False)
fn = self.mox.CreateMockAnything()
fn(target=self.TEMPLATE_PATH)
@@ -72,7 +72,9 @@ class _ImageTestCase(object):
def test_cache_image_exists(self):
self.mox.StubOutWithMock(os.path, 'exists')
+ os.path.exists(self.TEMPLATE_DIR).AndReturn(True)
os.path.exists(self.PATH).AndReturn(True)
+ os.path.exists(self.TEMPLATE_PATH).AndReturn(True)
self.mox.ReplayAll()
image = self.image_class(self.INSTANCE, self.NAME)
@@ -82,8 +84,8 @@ class _ImageTestCase(object):
def test_cache_base_dir_exists(self):
self.mox.StubOutWithMock(os.path, 'exists')
- os.path.exists(self.PATH).AndReturn(False)
os.path.exists(self.TEMPLATE_DIR).AndReturn(True)
+ os.path.exists(self.PATH).AndReturn(False)
os.path.exists(self.TEMPLATE_PATH).AndReturn(False)
fn = self.mox.CreateMockAnything()
fn(target=self.TEMPLATE_PATH)
@@ -98,8 +100,8 @@ class _ImageTestCase(object):
def test_cache_template_exists(self):
self.mox.StubOutWithMock(os.path, 'exists')
- os.path.exists(self.PATH).AndReturn(False)
os.path.exists(self.TEMPLATE_DIR).AndReturn(True)
+ os.path.exists(self.PATH).AndReturn(False)
os.path.exists(self.TEMPLATE_PATH).AndReturn(True)
fn = self.mox.CreateMockAnything()
self.mox.ReplayAll()
@@ -195,7 +197,6 @@ class Qcow2TestCase(_ImageTestCase, test.TestCase):
def test_create_image_with_size(self):
fn = self.prepare_mocks()
fn(target=self.TEMPLATE_PATH)
- self.mox.StubOutWithMock(os.path, 'exists')
imagebackend.libvirt_utils.create_cow_image(self.TEMPLATE_PATH,
self.PATH)
imagebackend.disk.extend(self.PATH, self.SIZE)
diff --git a/nova/tests/test_libvirt.py b/nova/tests/test_libvirt.py
index cef9252c5..4b9a4eb7c 100644
--- a/nova/tests/test_libvirt.py
+++ b/nova/tests/test_libvirt.py
@@ -4206,7 +4206,7 @@ class LibvirtDriverTestCase(test.TestCase):
self.counter = 0
- def fake_get_instance_disk_info(instance):
+ def fake_get_instance_disk_info(instance, xml=None):
return '[]'
def fake_destroy(instance):
@@ -4251,7 +4251,7 @@ class LibvirtDriverTestCase(test.TestCase):
'disk_size':'83886080'}]
disk_info_text = jsonutils.dumps(disk_info)
- def fake_get_instance_disk_info(instance):
+ def fake_get_instance_disk_info(instance, xml=None):
return disk_info_text
def fake_destroy(instance):
diff --git a/nova/tests/test_virt_drivers.py b/nova/tests/test_virt_drivers.py
index 29c7f9959..67452bc24 100644
--- a/nova/tests/test_virt_drivers.py
+++ b/nova/tests/test_virt_drivers.py
@@ -104,6 +104,13 @@ class _FakeDriverBackendTestCase(object):
def fake_make_drive(_self, _path):
pass
+ def fake_get_instance_disk_info(_self, instance, xml=None):
+ return '[]'
+
+ self.stubs.Set(nova.virt.libvirt.driver.LibvirtDriver,
+ 'get_instance_disk_info',
+ fake_get_instance_disk_info)
+
self.stubs.Set(nova.virt.libvirt.driver.disk,
'extend', fake_extend)
@@ -227,7 +234,8 @@ class _VirtDriverTestCase(_FakeDriverBackendTestCase):
def test_reboot(self):
reboot_type = "SOFT"
instance_ref, network_info = self._get_running_instance()
- self.connection.reboot(instance_ref, network_info, reboot_type)
+ self.connection.reboot(self.ctxt, instance_ref, network_info,
+ reboot_type)
@catch_notimplementederror
def test_get_host_ip_addr(self):
diff --git a/nova/tests/test_vmwareapi.py b/nova/tests/test_vmwareapi.py
index 34f03a555..22544fd2d 100644
--- a/nova/tests/test_vmwareapi.py
+++ b/nova/tests/test_vmwareapi.py
@@ -199,14 +199,16 @@ class VMwareAPIVMTestCase(test.TestCase):
info = self.conn.get_info({'name': 1})
self._check_vm_info(info, power_state.RUNNING)
reboot_type = "SOFT"
- self.conn.reboot(self.instance, self.network_info, reboot_type)
+ self.conn.reboot(self.context, self.instance, self.network_info,
+ reboot_type)
info = self.conn.get_info({'name': 1})
self._check_vm_info(info, power_state.RUNNING)
def test_reboot_non_existent(self):
self._create_instance_in_the_db()
self.assertRaises(exception.InstanceNotFound, self.conn.reboot,
- self.instance, self.network_info, 'SOFT')
+ self.context, self.instance, self.network_info,
+ 'SOFT')
def test_reboot_not_poweredon(self):
self._create_vm()
@@ -216,7 +218,8 @@ class VMwareAPIVMTestCase(test.TestCase):
info = self.conn.get_info({'name': 1})
self._check_vm_info(info, power_state.SUSPENDED)
self.assertRaises(exception.InstanceRebootFailure, self.conn.reboot,
- self.instance, self.network_info, 'SOFT')
+ self.context, self.instance, self.network_info,
+ 'SOFT')
def test_suspend(self):
self._create_vm()
diff --git a/nova/tests/test_xenapi.py b/nova/tests/test_xenapi.py
index 9285da2b2..cc71ba31e 100644
--- a/nova/tests/test_xenapi.py
+++ b/nova/tests/test_xenapi.py
@@ -955,12 +955,12 @@ class XenAPIVMTestCase(stubs.XenAPITestBase):
def test_reboot_hard(self):
instance = self._create_instance()
conn = xenapi_conn.XenAPIDriver(fake.FakeVirtAPI(), False)
- conn.reboot(instance, None, "HARD")
+ conn.reboot(self.context, instance, None, "HARD")
def test_reboot_soft(self):
instance = self._create_instance()
conn = xenapi_conn.XenAPIDriver(fake.FakeVirtAPI(), False)
- conn.reboot(instance, None, "SOFT")
+ conn.reboot(self.context, instance, None, "SOFT")
def test_reboot_halted(self):
session = xenapi_conn.XenAPISession('test_url', 'root', 'test_pass',
@@ -968,7 +968,7 @@ class XenAPIVMTestCase(stubs.XenAPITestBase):
instance = self._create_instance(spawn=False)
conn = xenapi_conn.XenAPIDriver(fake.FakeVirtAPI(), False)
xenapi_fake.create_vm(instance['name'], 'Halted')
- conn.reboot(instance, None, "SOFT")
+ conn.reboot(self.context, instance, None, "SOFT")
vm_ref = vm_utils.lookup(session, instance['name'])
vm = xenapi_fake.get_record('VM', vm_ref)
self.assertEquals(vm['power_state'], 'Running')
@@ -977,8 +977,8 @@ class XenAPIVMTestCase(stubs.XenAPITestBase):
instance = self._create_instance(spawn=False)
conn = xenapi_conn.XenAPIDriver(fake.FakeVirtAPI(), False)
xenapi_fake.create_vm(instance['name'], 'Unknown')
- self.assertRaises(xenapi_fake.Failure, conn.reboot, instance,
- None, "SOFT")
+ self.assertRaises(xenapi_fake.Failure, conn.reboot, self.context,
+ instance, None, "SOFT")
def _test_maintenance_mode(self, find_host, find_aggregate):
real_call_xenapi = self.conn._session.call_xenapi