summaryrefslogtreecommitdiffstats
path: root/nova
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2013-06-27 07:13:21 +0000
committerGerrit Code Review <review@openstack.org>2013-06-27 07:13:21 +0000
commit6aff2c92b366bf4b0c3c6ef72fec5cdde3b7381c (patch)
treeba44b1ef36272b7eeec0a6cee4717c24d66a3a0e /nova
parent73eaa61f468d1c4f6f800862e4eb4d8a70f88bb1 (diff)
parent1a00329f81766f3371cbe53118ee474798218f9c (diff)
downloadnova-6aff2c92b366bf4b0c3c6ef72fec5cdde3b7381c.tar.gz
nova-6aff2c92b366bf4b0c3c6ef72fec5cdde3b7381c.tar.xz
nova-6aff2c92b366bf4b0c3c6ef72fec5cdde3b7381c.zip
Merge "Stop creating folders in virt unit tests"
Diffstat (limited to 'nova')
-rw-r--r--nova/tests/virt/libvirt/test_libvirt.py38
-rw-r--r--nova/tests/virt/test_virt_drivers.py2
2 files changed, 23 insertions, 17 deletions
diff --git a/nova/tests/virt/libvirt/test_libvirt.py b/nova/tests/virt/libvirt/test_libvirt.py
index 3c658a7f5..60a633979 100644
--- a/nova/tests/virt/libvirt/test_libvirt.py
+++ b/nova/tests/virt/libvirt/test_libvirt.py
@@ -77,6 +77,7 @@ CONF.import_opt('compute_manager', 'nova.service')
CONF.import_opt('host', 'nova.netconf')
CONF.import_opt('my_ip', 'nova.netconf')
CONF.import_opt('base_dir_name', 'nova.virt.libvirt.imagecache')
+CONF.import_opt('instances_path', 'nova.compute.manager')
_fake_network_info = fake_network.fake_get_instance_nw_info
_fake_stub_out_get_nw_info = fake_network.stub_out_nw_api_get_instance_nw_info
@@ -286,8 +287,9 @@ class LibvirtConnTestCase(test.TestCase):
self.user_id = 'fake'
self.project_id = 'fake'
self.context = context.get_admin_context()
- self.flags(instances_path='')
- self.flags(libvirt_snapshots_directory='')
+ temp_dir = self.useFixture(fixtures.TempDir()).path
+ self.flags(instances_path=temp_dir)
+ self.flags(libvirt_snapshots_directory=temp_dir)
self.useFixture(fixtures.MonkeyPatch(
'nova.virt.libvirt.driver.libvirt_utils',
fake_libvirt_utils))
@@ -343,6 +345,9 @@ class LibvirtConnTestCase(test.TestCase):
'extra_specs': {},
'system_metadata': sys_meta}
+ def relpath(self, path):
+ return os.path.relpath(path, CONF.instances_path)
+
def tearDown(self):
nova.tests.image.fake.FakeImageService_reset()
super(LibvirtConnTestCase, self).tearDown()
@@ -2078,8 +2083,8 @@ class LibvirtConnTestCase(test.TestCase):
else:
suffix = ''
if expect_kernel:
- check = (lambda t: t.find('./os/kernel').text.split(
- '/')[1], 'kernel' + suffix)
+ check = (lambda t: self.relpath(t.find('./os/kernel').text).
+ split('/')[1], 'kernel' + suffix)
else:
check = (lambda t: t.find('./os/kernel'), None)
check_list.append(check)
@@ -2094,8 +2099,8 @@ class LibvirtConnTestCase(test.TestCase):
check_list.append(check)
if expect_ramdisk:
- check = (lambda t: t.find('./os/initrd').text.split(
- '/')[1], 'ramdisk' + suffix)
+ check = (lambda t: self.relpath(t.find('./os/initrd').text).
+ split('/')[1], 'ramdisk' + suffix)
else:
check = (lambda t: t.find('./os/initrd'), None)
check_list.append(check)
@@ -2146,8 +2151,9 @@ class LibvirtConnTestCase(test.TestCase):
check = (lambda t: t.findall('./devices/serial')[1].get(
'type'), 'pty')
check_list.append(check)
- check = (lambda t: t.findall('./devices/serial/source')[0].get(
- 'path').split('/')[1], 'console.log')
+ check = (lambda t: self.relpath(t.findall(
+ './devices/serial/source')[0].get('path')).
+ split('/')[1], 'console.log')
check_list.append(check)
else:
check = (lambda t: t.find('./devices/console').get(
@@ -2159,16 +2165,16 @@ class LibvirtConnTestCase(test.TestCase):
(lambda t: t.find('./memory').text, '2097152')]
if rescue:
common_checks += [
- (lambda t: t.findall('./devices/disk/source')[0].get(
- 'file').split('/')[1], 'disk.rescue'),
- (lambda t: t.findall('./devices/disk/source')[1].get(
- 'file').split('/')[1], 'disk')]
+ (lambda t: self.relpath(t.findall('./devices/disk/source')[0].
+ get('file')).split('/')[1], 'disk.rescue'),
+ (lambda t: self.relpath(t.findall('./devices/disk/source')[1].
+ get('file')).split('/')[1], 'disk')]
else:
- common_checks += [(lambda t: t.findall(
- './devices/disk/source')[0].get('file').split('/')[1],
+ common_checks += [(lambda t: self.relpath(t.findall(
+ './devices/disk/source')[0].get('file')).split('/')[1],
'disk')]
- common_checks += [(lambda t: t.findall(
- './devices/disk/source')[1].get('file').split('/')[1],
+ common_checks += [(lambda t: self.relpath(t.findall(
+ './devices/disk/source')[1].get('file')).split('/')[1],
'disk.local')]
for (libvirt_type, (expected_uri, checks)) in type_uri_map.iteritems():
diff --git a/nova/tests/virt/test_virt_drivers.py b/nova/tests/virt/test_virt_drivers.py
index 5c2df9854..a21993597 100644
--- a/nova/tests/virt/test_virt_drivers.py
+++ b/nova/tests/virt/test_virt_drivers.py
@@ -60,7 +60,7 @@ class _FakeDriverBackendTestCase(object):
# So that the _supports_direct_io does the test based
# on the current working directory, instead of the
# default instances_path which doesn't exist
- self.flags(instances_path='')
+ self.flags(instances_path=self.useFixture(fixtures.TempDir()).path)
# Put fakelibvirt in place
if 'libvirt' in sys.modules: