<div dir="ltr">Reviewed-by: Daniel Barboza <<a href="mailto:dhbarboza82@gmail.com">dhbarboza82@gmail.com</a>></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Jun 16, 2015 at 5:14 PM, Aline Manera <span dir="ltr"><<a href="mailto:alinefm@linux.vnet.ibm.com" target="_blank">alinefm@linux.vnet.ibm.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">The user may have the Kimchi source code in any directory and using it<br>
as a base to do the tests may cause permission errors while open ISO<br>
files or creating guest disks.<br>
To avoid those errors use a temp directory under /var which already has<br>
the right permissions to all users.<br>
<br>
Signed-off-by: Aline Manera <<a href="mailto:alinefm@linux.vnet.ibm.com">alinefm@linux.vnet.ibm.com</a>><br>
---<br>
tests/test_model.py | 40 ++++++++++++++++++++--------------------<br>
1 file changed, 20 insertions(+), 20 deletions(-)<br>
<br>
diff --git a/tests/test_model.py b/tests/test_model.py<br>
index 602ca6e..3828342 100644<br>
--- a/tests/test_model.py<br>
+++ b/tests/test_model.py<br>
@@ -48,13 +48,13 @@ invalid_repository_urls = ['<a href="http://www.fedora.org" rel="noreferrer" target="_blank">www.fedora.org</a>', # missing protocol<br>
'<a href="http://www.fedora" rel="noreferrer" target="_blank">http://www.fedora</a>', # invalid domain name<br>
'file:///home/foobar'] # invalid path<br>
<br>
-ISO_PATH = '/tmp/kimchi-model-iso/'<br>
-UBUNTU_ISO = ISO_PATH + 'ubuntu14.04.iso'<br>
+TMP_DIR = '/var/lib/kimchi/tests/'<br>
+UBUNTU_ISO = TMP_DIR + 'ubuntu14.04.iso'<br>
<br>
<br>
def setUpModule():<br>
- if not os.path.exists(ISO_PATH):<br>
- os.makedirs(ISO_PATH)<br>
+ if not os.path.exists(TMP_DIR):<br>
+ os.makedirs(TMP_DIR)<br>
<br>
iso_gen.construct_fake_iso(UBUNTU_ISO, True, '14.04', 'ubuntu')<br>
<br>
@@ -68,7 +68,7 @@ def setUpModule():<br>
<br>
<br>
def tearDownModule():<br>
- shutil.rmtree(ISO_PATH)<br>
+ shutil.rmtree(TMP_DIR)<br>
<br>
<br>
class ModelTests(unittest.TestCase):<br>
@@ -382,7 +382,7 @@ class ModelTests(unittest.TestCase):<br>
<br>
@unittest.skipUnless(utils.running_as_root(), 'Must be run as root')<br>
def test_vm_disk(self):<br>
- disk_path = '/tmp/existent2.iso'<br>
+ disk_path = os.path.join(TMP_DIR, 'existent2.iso')<br>
open(disk_path, 'w').close()<br>
modern_disk_bus = get_template_default('modern', 'disk_bus')<br>
<br>
@@ -403,7 +403,7 @@ class ModelTests(unittest.TestCase):<br>
<br>
inst = model.Model(objstore_loc=self.tmp_store)<br>
with RollbackContext() as rollback:<br>
- path = os.path.join(os.getcwd(), 'kimchi-images')<br>
+ path = os.path.join(TMP_DIR, 'kimchi-images')<br>
pool = 'test-pool'<br>
vol = 'test-volume.img'<br>
vol_path = "%s/%s" % (path, vol)<br>
@@ -468,7 +468,7 @@ class ModelTests(unittest.TestCase):<br>
self.assertRaises(<br>
InvalidParameter, inst.vmstorages_create, vm_name, disk_args)<br>
<br>
- old_distro_iso = ISO_PATH + 'rhel4_8.iso'<br>
+ old_distro_iso = TMP_DIR + 'rhel4_8.iso'<br>
iso_gen.construct_fake_iso(old_distro_iso, True, '4.8', 'rhel')<br>
<br>
vm_name = 'kimchi-ide-bus-vm'<br>
@@ -508,8 +508,8 @@ class ModelTests(unittest.TestCase):<br>
self.assertEquals(1, prev_count)<br>
<br>
# dummy .iso files<br>
- iso_path = '/tmp/existent.iso'<br>
- iso_path2 = '/tmp/existent2.iso'<br>
+ iso_path = os.path.join(TMP_DIR, 'existent.iso')<br>
+ iso_path2 = os.path.join(TMP_DIR, 'existent2.iso')<br>
open(iso_path, 'w').close()<br>
rollback.prependDefer(os.remove, iso_path)<br>
open(iso_path2, 'w').close()<br>
@@ -996,20 +996,20 @@ class ModelTests(unittest.TestCase):<br>
inst = model.Model(None,<br>
objstore_loc=self.tmp_store)<br>
with RollbackContext() as rollback:<br>
- path = '/tmp/kimchi-images/tmpdir'<br>
- if not os.path.exists(path):<br>
- os.makedirs(path)<br>
- iso_gen.construct_fake_iso('/tmp/kimchi-images/tmpdir/'<br>
- 'ubuntu12.04.iso', True,<br>
- '12.04', 'ubuntu')<br>
- iso_gen.construct_fake_iso('/tmp/kimchi-images/sles10.iso',<br>
- True, '10', 'sles')<br>
+ deep_path = os.path.join(TMP_DIR, 'deep-scan')<br>
+ subdir_path = os.path.join(deep_path, 'isos')<br>
+ if not os.path.exists(subdir_path):<br>
+ os.makedirs(subdir_path)<br>
+ ubuntu_iso = os.path.join(deep_path, 'ubuntu12.04.iso')<br>
+ sles_iso = os.path.join(subdir_path, 'sles10.iso')<br>
+ iso_gen.construct_fake_iso(ubuntu_iso, True, '12.04', 'ubuntu')<br>
+ iso_gen.construct_fake_iso(sles_iso, True, '10', 'sles')<br>
<br>
args = {'name': 'kimchi-scanning-pool',<br>
- 'path': '/tmp/kimchi-images',<br>
+ 'path': deep_path,<br>
'type': 'kimchi-iso'}<br>
inst.storagepools_create(args)<br>
- rollback.prependDefer(shutil.rmtree, '/tmp/kimchi-images')<br>
+ rollback.prependDefer(shutil.rmtree, deep_path)<br>
rollback.prependDefer(shutil.rmtree, args['path'])<br>
rollback.prependDefer(inst.storagepool_deactivate, args['name'])<br>
<span class="HOEnZb"><font color="#888888"><br>
--<br>
2.1.0<br>
<br>
_______________________________________________<br>
Kimchi-devel mailing list<br>
<a href="mailto:Kimchi-devel@ovirt.org">Kimchi-devel@ovirt.org</a><br>
<a href="http://lists.ovirt.org/mailman/listinfo/kimchi-devel" rel="noreferrer" target="_blank">http://lists.ovirt.org/mailman/listinfo/kimchi-devel</a><br>
</font></span></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr">Daniel Henrique Barboza<div>Senior Software Engineer - IBM Linux Technology Center </div></div></div>
</div>