Example #1
0
def test_repo_packagelist(tendrl_repos):
    """
    Check that tendrl core repository contains all expected tendrl packages and
    doesn't contain anything else.
    """
    LOGGER.info(
        "expected tendrl-core packages are: " + ",".join(tendrl_packages))
    # get actual list of packages from tendrl-core repository (via repoquery)
    packages = list_packages('tendrl-core')
    for rpm_name in tendrl_packages:
        msg = "package {} should be present in tendrl-core repo"
        package_present = rpm_name in packages
        pytest.check(package_present, msg.format(rpm_name))
        if package_present:
            packages.remove(rpm_name)
    pytest.check(packages == [], msg="there should be no extra packages")
    for rpm_name in packages:
        LOGGER.failed("unexpected package in tendrl-core: {}".format(rpm_name))
Example #2
0
    try:
        deps_baseurl = get_baseurl(reponame2confname['tendrl-deps'])
        repo_dict['tendrl-deps'] = deps_baseurl
    except ValueError as ex:
        # usm_deps_baseurl is optional
        # ignore exception raised when it is missing in the conf. file
        if "unknown configuration value" in str(ex):
            pass
        else:
            raise ex
    return repo_dict


@pytest.fixture(
    scope="module",
    params=list_packages('tendrl-core') + list_packages('tendrl-deps'))
def rpm_package(request, tendrl_repos):
    """
    Fixture downloads given rpm package from given repository
    and returns it's local path to the test. Downloaded package
    is deleted later during tear down phase.

    GnuPG signature is not verified during package download.
    """
    with tempfile.TemporaryDirectory() as tmpdirname:
        # name of rpm package under test
        rpm_name = request.param
        # we need to trick yumdownloader into thinking that rpm repo is enabled
        # in the system
        yum_repos_d = os.path.join(tmpdirname, "chroot", "etc", "yum.repos.d")
        os.makedirs(yum_repos_d)
Example #3
0
# -*- coding: utf8 -*-

import pytest
import subprocess

from packagelist import list_packages


LOGGER = pytest.get_logger(__name__, module=True)


@pytest.mark.parametrize("rpm_name", list_packages('tendrl-core'))
def test_yum_install(chroot_dir, rpm_name):
    """
    Try to install and uninstall rpm package via yum in CentOS 7 chroot.
    """
    cmd = [
        "sudo",
        "yum", "--installroot=%s" % chroot_dir, "-y", "install", rpm_name]
    # running yum install
    LOGGER.info(" ".join(cmd))
    cp = subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
    LOGGER.debug("STDOUT: %s", cp.stdout)
    if len(cp.stderr) > 0:
        LOGGER.warning("STDERR: %s", cp.stderr)
    else:
        LOGGER.debug("STDERR: %s", cp.stderr)
    check_msg = "return code of 'yum install {}' should be 0 indicating no errors"
    pytest.check(cp.returncode == 0, msg=check_msg.format(rpm_name))
    # check after installation
    cmd = ["rpm", "-q", rpm_name, "--root", chroot_dir]