Ejemplo n.º 1
0
    def setUpClass(self):
        self.maxDiff = None

        repo_dir = tempfile.mkdtemp(prefix="lorax.test.repo.")
        server.config["REPO_DIR"] = repo_dir
        repo = open_or_create_repo(server.config["REPO_DIR"])
        server.config["GITLOCK"] = GitLock(repo=repo, lock=Lock(), dir=repo_dir)

        server.config["COMPOSER_CFG"] = configure(root_dir=repo_dir, test_config=True)
        os.makedirs(joinpaths(server.config["COMPOSER_CFG"].get("composer", "share_dir"), "composer"))
        errors = make_queue_dirs(server.config["COMPOSER_CFG"], 0)
        if errors:
            raise RuntimeError("\n".join(errors))

        make_dnf_dirs(server.config["COMPOSER_CFG"])
        dbo = get_base_object(server.config["COMPOSER_CFG"])
        server.config["DNFLOCK"] = DNFLock(dbo=dbo, lock=Lock())

        server.config['TESTING'] = True
        self.server = server.test_client()
        self.repo_dir = repo_dir

        self.examples_path = "./tests/pylorax/blueprints/"

        # Copy the shared files over to the directory tree we are using
        share_path = "./share/composer/"
        for f in glob(joinpaths(share_path, "*")):
            shutil.copy(f, joinpaths(server.config["COMPOSER_CFG"].get("composer", "share_dir"), "composer"))

        # Import the example blueprints
        commit_recipe_directory(server.config["GITLOCK"].repo, "master", self.examples_path)

        start_queue_monitor(server.config["COMPOSER_CFG"], 0, 0)
Ejemplo n.º 2
0
    def test_creates_missing_dnf_root_directory(self):
        config = configure(test_config=True, root_dir=self.tmp_dir)

        # will create the above directory if missing
        make_dnf_dirs(config)

        self.assertTrue(os.path.exists(self.tmp_dir + '/var/tmp/composer/dnf/root'))
Ejemplo n.º 3
0
 def setUpClass(self):
     self.tmp_dir = tempfile.mkdtemp(prefix="lorax.test.repo.")
     self.config = configure(root_dir=self.tmp_dir, test_config=True)
     make_dnf_dirs(self.config)
     self.dbo = get_base_object(self.config)
     os.environ["TZ"] = "UTC"
     time.tzset()
Ejemplo n.º 4
0
    def setUpClass(self):
        self.tmp_dir = tempfile.mkdtemp(prefix="lorax.test.dnfbase.")

        # will read the above configuration
        config = configure(root_dir=self.tmp_dir)
        make_dnf_dirs(config)

        # will read composer config and store a dnf config file
        self.dbo = get_base_object(config)

        # will read the stored dnf config file
        self.dnfconf = configparser.ConfigParser()
        self.dnfconf.read([config.get("composer", "dnf_conf")])
Ejemplo n.º 5
0
    def setUpClass(self):
        self.maxDiff = None
        self.config = dict()

        repo_dir = tempfile.mkdtemp(prefix="lorax.test.repo.")
        self.config["REPO_DIR"] = repo_dir

        self.config["COMPOSER_CFG"] = configure(root_dir=repo_dir, test_config=True)
        lifted.config.configure(self.config["COMPOSER_CFG"])
        os.makedirs(joinpaths(self.config["COMPOSER_CFG"].get("composer", "share_dir"), "composer"))
        errors = make_queue_dirs(self.config["COMPOSER_CFG"], os.getgid())
        if errors:
            raise RuntimeError("\n".join(errors))

        lib_dir = self.config["COMPOSER_CFG"].get("composer", "lib_dir")
        share_dir = self.config["COMPOSER_CFG"].get("composer", "share_dir")
        tmp = self.config["COMPOSER_CFG"].get("composer", "tmp")
        self.monitor_cfg = DataHolder(composer_dir=lib_dir, share_dir=share_dir, uid=0, gid=0, tmp=tmp)
Ejemplo n.º 6
0
    def setUpClass(self):
        self.tmp_dir = tempfile.mkdtemp(prefix="lorax.test.dnfbase.")
        conf_file = os.path.join(self.tmp_dir, 'test.conf')
        open(conf_file, 'w').write("""[composer]
# releasever different from the current default
releasever = 6
[dnf]
proxy = https://proxy.example.com
sslverify = False
[repos]
use_system_repos = False
""")

        # will read the above configuration
        config = configure(conf_file=conf_file, root_dir=self.tmp_dir)
        make_dnf_dirs(config)

        # will read composer config and store a dnf config file
        self.dbo = get_base_object(config)

        # will read the stored dnf config file
        self.dnfconf = configparser.ConfigParser()
        self.dnfconf.read([config.get("composer", "dnf_conf")])
Ejemplo n.º 7
0
 def setUpClass(self):
     self.tmp_dir = tempfile.mkdtemp(prefix="lorax.test.repo.")
     self.config = configure(root_dir=self.tmp_dir, test_config=True)
     lifted.config.configure(self.config)
     make_dnf_dirs(self.config, os.getuid(), os.getgid())
     self.dbo = get_base_object(self.config)
Ejemplo n.º 8
0
    def setUpClass(self):
        self.rawhide = False
        self.maxDiff = None

        repo_dir = tempfile.mkdtemp(prefix="lorax.test.repo.")
        server.config["REPO_DIR"] = repo_dir
        repo = open_or_create_repo(server.config["REPO_DIR"])
        server.config["GITLOCK"] = GitLock(repo=repo,
                                           lock=Lock(),
                                           dir=repo_dir)

        server.config["COMPOSER_CFG"] = configure(root_dir=repo_dir,
                                                  test_config=True)
        os.makedirs(
            joinpaths(
                server.config["COMPOSER_CFG"].get("composer", "share_dir"),
                "composer"))
        errors = make_queue_dirs(server.config["COMPOSER_CFG"], 0)
        if errors:
            raise RuntimeError("\n".join(errors))

        make_dnf_dirs(server.config["COMPOSER_CFG"])

        # copy over the test dnf repositories
        dnf_repo_dir = server.config["COMPOSER_CFG"].get(
            "composer", "repo_dir")
        for f in glob("./tests/pylorax/repos/*.repo"):
            shutil.copy2(f, dnf_repo_dir)

        # Modify fedora vs. rawhide tests when running on rawhide
        if os.path.exists("/etc/yum.repos.d/fedora-rawhide.repo"):
            self.rawhide = True

        # dnf repo baseurl has to point to an absolute directory, so we use /tmp/lorax-empty-repo/ in the files
        # and create an empty repository
        os.makedirs("/tmp/lorax-empty-repo/")
        os.system("createrepo_c /tmp/lorax-empty-repo/")

        dbo = get_base_object(server.config["COMPOSER_CFG"])
        server.config["DNFLOCK"] = DNFLock(dbo=dbo, lock=Lock())

        server.config['TESTING'] = True
        self.server = server.test_client()
        self.repo_dir = repo_dir

        self.examples_path = "./tests/pylorax/blueprints/"

        # Copy the shared files over to the directory tree we are using
        share_path = "./share/composer/"
        for f in glob(joinpaths(share_path, "*")):
            shutil.copy(
                f,
                joinpaths(
                    server.config["COMPOSER_CFG"].get("composer", "share_dir"),
                    "composer"))

        # Import the example blueprints
        commit_recipe_directory(server.config["GITLOCK"].repo, "master",
                                self.examples_path)

        start_queue_monitor(server.config["COMPOSER_CFG"], 0, 0)
Ejemplo n.º 9
0
 def test_configure_reads_non_existing_file(self):
     config = configure(conf_file=self.conf_file + '.non-existing')
     lifted.config.configure(config)
     self.assertEqual(config.get('composer', 'cache_dir'),
                      '/var/tmp/composer/cache')
Ejemplo n.º 10
0
 def test_configure_reads_existing_file(self):
     config = configure(conf_file=self.conf_file)
     lifted.config.configure(config)
     self.assertEqual(config.get('composer', 'cache_dir'),
                      '/tmp/cache-test')