Make sure lorax-composer tests only use temporary directories
It was using /var/tmp/composer/, now it places everything under a temporary directory that is removed when it is finished.
This commit is contained in:
parent
597c19466e
commit
1a4a4defcc
@ -45,6 +45,7 @@ def configure(conf_file="/etc/lorax/composer.conf", root_dir="/", test_config=Fa
|
||||
conf.set("composer", "share_dir", os.path.realpath(joinpaths(root_dir, "/usr/share/lorax/")))
|
||||
conf.set("composer", "lib_dir", os.path.realpath(joinpaths(root_dir, "/var/lib/lorax/composer/")))
|
||||
conf.set("composer", "yum_conf", os.path.realpath(joinpaths(root_dir, "/var/tmp/composer/yum.conf")))
|
||||
conf.set("composer", "yum_root", os.path.realpath(joinpaths(root_dir, "/var/tmp/composer/yum/root/")))
|
||||
conf.set("composer", "repo_dir", os.path.realpath(joinpaths(root_dir, "/var/tmp/composer/repos.d/")))
|
||||
conf.set("composer", "cache_dir", os.path.realpath(joinpaths(root_dir, "/var/tmp/composer/cache/")))
|
||||
|
||||
@ -70,7 +71,7 @@ def make_yum_dirs(conf):
|
||||
:type conf: ComposerConfig
|
||||
:returns: None
|
||||
"""
|
||||
for p in ["yum_conf", "repo_dir", "cache_dir"]:
|
||||
for p in ["yum_conf", "repo_dir", "cache_dir", "yum_root"]:
|
||||
p_dir = os.path.dirname(conf.get("composer", p))
|
||||
if not os.path.exists(p_dir):
|
||||
os.makedirs(p_dir)
|
||||
|
@ -39,6 +39,7 @@ def get_base_object(conf):
|
||||
"""
|
||||
cachedir = os.path.abspath(conf.get("composer", "cache_dir"))
|
||||
yumconf = os.path.abspath(conf.get("composer", "yum_conf"))
|
||||
yumroot = os.path.abspath(conf.get("composer", "yum_root"))
|
||||
repodir = os.path.abspath(conf.get("composer", "repo_dir"))
|
||||
|
||||
c = ConfigParser.ConfigParser()
|
||||
@ -71,8 +72,7 @@ def get_base_object(conf):
|
||||
|
||||
yb.preconf.fn = yumconf
|
||||
|
||||
# TODO How to handle this?
|
||||
yb.preconf.root = "/var/tmp/composer/yum/root"
|
||||
yb.preconf.root = yumroot
|
||||
if not os.path.isdir(yb.preconf.root):
|
||||
os.makedirs(yb.preconf.root)
|
||||
|
||||
|
@ -18,7 +18,6 @@ import os
|
||||
import shutil
|
||||
import tempfile
|
||||
import unittest
|
||||
from glob import glob
|
||||
|
||||
import ConfigParser
|
||||
|
||||
@ -73,14 +72,17 @@ use_system_repos = False
|
||||
class CreateYumDirsTest(unittest.TestCase):
|
||||
@classmethod
|
||||
def setUpClass(self):
|
||||
# remove this directory
|
||||
if os.path.exists('/var/tmp/composer/yum/root'):
|
||||
shutil.rmtree('/var/tmp/composer/yum/root')
|
||||
self.tmp_dir = tempfile.mkdtemp(prefix="lorax.test.yumbase.")
|
||||
|
||||
@classmethod
|
||||
def tearDownClass(self):
|
||||
shutil.rmtree(self.tmp_dir)
|
||||
|
||||
def test_creates_missing_yum_root_directory(self):
|
||||
config = configure(test_config=True)
|
||||
config = configure(test_config=True, root_dir=self.tmp_dir)
|
||||
|
||||
# will create the above directory if missing
|
||||
make_yum_dirs(config)
|
||||
_ = get_base_object(config)
|
||||
|
||||
self.assertTrue(os.path.exists('/var/tmp/composer/yum/root'))
|
||||
self.assertTrue(os.path.exists(self.tmp_dir + '/var/tmp/composer/yum/root'))
|
||||
|
Loading…
Reference in New Issue
Block a user