Пример #1
0
 def teardown_hotfix_check():
     if float(product()) >= 6.6:
         teardown = ansible_module.command(Packages.unlock())
         for result in teardown.values():
             logger.info(result["stdout"])
             assert "FAIL" not in result["stdout"]
             assert result["rc"] == 0
     if pkgs_locked == 0:
         ansible_module.command(Packages.unlock())
     teardown = ansible_module.command("yum -y reinstall tfm-rubygem-fog-vsphere")
     for result in teardown.values():
         assert result["rc"] == 0
     if float(product()) >= 6.6:
         teardown = ansible_module.command(Packages.lock())
         for result in teardown.values():
             logger.info(result["stdout"])
             assert "FAIL" not in result["stdout"]
             assert result["rc"] == 0
     teardown = ansible_module.file(path="/etc/yum.repos.d/hotfix_repo.repo", state="absent")
     assert teardown.values()[0]["changed"] == 1
     teardown = ansible_module.yum(name=["hotfix-package"], state="absent")
     for result in teardown.values():
         assert result["rc"] == 0
     if pkgs_locked == 0:
         ansible_module.command(Packages.lock())
     ansible_module.command("yum clean all")
Пример #2
0
def setup_hotfix_check(request, ansible_module):
    """This fixture is used for installing hofix package and modifying foreman file.
    This fixture is used in test_positive_check_hotfix_installed_with_hotfix of test_health.py
    """
    file = ansible_module.find(
        paths="/opt/theforeman/tfm/root/usr/share/gems/gems/",
        patterns="fog-vsphere-*",
        file_type="directory",
    )
    dpath = file.values()[0]["files"][0]["path"]
    fpath = dpath + "/lib/fog/vsphere/requests/compute/list_clusters.rb"
    ansible_module.lineinfile(dest=fpath,
                              insertafter="EOF",
                              line="#modifying_file")

    ansible_module.yum_repository(
        name="hotfix_repo",
        description="hotfix_repo",
        file="hotfix_repo",
        baseurl=HOTFIX_URL,
        enabled="yes",
        gpgcheck="no",
    )
    setup = ansible_module.file(path="/etc/yum.repos.d/hotfix_repo.repo",
                                state="present")
    assert setup.values()[0]["changed"] == 0
    pkgs_locked = ansible_module.command(
        Packages.is_locked()).values()[0]["rc"]
    if pkgs_locked == 0:
        ansible_module.command(Packages.unlock())
    setup = ansible_module.yum(name="hotfix-package", state="present")
    for result in setup.values():
        assert result["rc"] == 0
    if pkgs_locked == 0:
        ansible_module.command(Packages.lock())

    def teardown_hotfix_check():
        pkgs_locked = ansible_module.command(
            Packages.is_locked()).values()[0]["rc"]
        if pkgs_locked == 0:
            ansible_module.command(Packages.unlock())
        teardown = ansible_module.command(
            "yum -y reinstall tfm-rubygem-fog-vsphere")
        for result in teardown.values():
            assert result["rc"] == 0

        teardown = ansible_module.file(
            path="/etc/yum.repos.d/hotfix_repo.repo", state="absent")
        assert teardown.values()[0]["changed"] == 1
        teardown = ansible_module.yum(name=["hotfix-package"], state="absent")
        for result in teardown.values():
            assert result["rc"] == 0
        if pkgs_locked == 0:
            ansible_module.command(Packages.lock())
        ansible_module.command("yum clean all")

    request.addfinalizer(teardown_hotfix_check)
    return fpath
Пример #3
0
def setup_install_pkgs(ansible_module):
    """This fixture installs necessary packages required by Testfm testcases to run properly.
    This fixture is used in test_positive_check_hotfix_installed_with_hotfix and
    test_positive_check_hotfix_installed_without_hotfix of test_health.py
    """
    setup = ansible_module.yum(name="fio", state="present")
    for result in setup.values():
        assert result["rc"] == 0
    setup = ansible_module.command(Packages.unlock())
    for result in setup.values():
        assert result["rc"] == 0
    setup = ansible_module.yum(name=["python-kitchen", "yum-utils"], state="present")
    for result in setup.values():
        assert result["rc"] == 0
    teardown = ansible_module.command(Packages.lock())
    for result in teardown.values():
        assert result["rc"] == 0
Пример #4
0
    def teardown_hotfix_check():
        pkgs_locked = ansible_module.command(
            Packages.is_locked()).values()[0]["rc"]
        if pkgs_locked == 0:
            ansible_module.command(Packages.unlock())
        teardown = ansible_module.command(
            "yum -y reinstall tfm-rubygem-fog-vsphere")
        for result in teardown.values():
            assert result["rc"] == 0

        teardown = ansible_module.file(
            path="/etc/yum.repos.d/hotfix_repo.repo", state="absent")
        assert teardown.values()[0]["changed"] == 1
        teardown = ansible_module.yum(name=["hotfix-package"], state="absent")
        for result in teardown.values():
            assert result["rc"] == 0
        if pkgs_locked == 0:
            ansible_module.command(Packages.lock())
        ansible_module.command("yum clean all")
Пример #5
0
def setup_custom_package(request, ansible_module):
    """Setup/Teardown cusom yum repo/package for non-rh-packages check."""
    ansible_module.yum_repository(
        name="custom_repo",
        description="custom repo",
        file="custom_repo",
        baseurl=f"{FAKE_YUM0_REPO}",
        enabled="yes",
        gpgcheck="no",
    )
    setup = ansible_module.file(path="/etc/yum.repos.d/custom_repo.repo",
                                state="present")
    assert setup.values()[0]["changed"] == 0

    pkgs_locked = ansible_module.command(
        Packages.is_locked()).values()[0]["rc"]
    if pkgs_locked == 0:
        ansible_module.command(Packages.unlock())

    contacted = ansible_module.yum(name="walrus", state="present")
    for result in contacted.values():
        assert result["rc"] == 0

    if pkgs_locked == 0:
        ansible_module.command(Packages.lock())

    def teardown_custom_package():
        teardown = ansible_module.yum(name="walrus", state="absent")
        for result in contacted.values():
            assert result["rc"] == 0

        teardown = ansible_module.file(
            path="/etc/yum.repos.d/custom_repo.repo", state="absent")
        assert teardown.values()[0]["changed"] == 1

    request.addfinalizer(teardown_custom_package)
Пример #6
0
def test_positive_fm_packages_lock(ansible_module):
    """Verify whether satellite related packages get locked

    :id: d387d8be-10ad-4a62-aeff-3bc6a82e6bae

    :setup:
        1. foreman-maintain should be installed.

    :steps:
        1. Run foreman-maintain packages lock
        2. Run foreman-maintain packages status
        3. Run foreman-maintain packages is-locked
        4. check 'satellite' is mentioned in /etc/yum/pluginconf.d/versionlock.list
        5. Run foreman-maintain packages unlock
        6. Run foreman-maintain packages status
        7. Run foreman-maintain packages is-locked
        8. check 'satellite' is not mentioned in /etc/yum/pluginconf.d/versionlock.list

    :expectedresults: expected packages get locked and unlocked.

    :CaseImportance: Critical
    """
    # Test Package lock command
    contacted = ansible_module.command(Packages.lock(["--assumeyes"]))
    for result in contacted.values():
        logger.info(result["stdout"])
        assert "FAIL" not in result["stdout"]
        assert result["rc"] == 0
    contacted = ansible_module.command(Packages.status())
    for result in contacted.values():
        logger.info(result["stdout"])
        assert "Packages are locked." in result["stdout"]
        assert "Automatic locking of package versions is enabled in installer." in result[
            "stdout"]
        assert "FAIL" not in result["stdout"]
        assert result["rc"] == 0
    contacted = ansible_module.command(Packages.is_locked())
    for result in contacted.values():
        logger.info(result["stdout"])
        assert "Packages are locked" in result["stdout"]
        assert result["rc"] == 0
    # Test package unlock command
    contacted = ansible_module.command(Packages.unlock())
    for result in contacted.values():
        logger.info(result["stdout"])
        assert "FAIL" not in result["stdout"]
        assert result["rc"] == 0
    contacted = ansible_module.command(Packages.status())
    for result in contacted.values():
        logger.info(result["stdout"])
        assert "FAIL" not in result["stdout"]
        assert "Packages are not locked." in result["stdout"]
        assert "Automatic locking of package versions is enabled in installer." in result[
            "stdout"]
        assert result["rc"] == 0
    contacted = ansible_module.command(Packages.is_locked())
    for result in contacted.values():
        logger.info(result["stdout"])
        assert "Packages are not locked" in result["stdout"]
        assert result["rc"] == 1
    # lock packages
    teardown = ansible_module.command(Packages.lock())
    for result in teardown.values():
        logger.info(result["stdout"])
        assert "FAIL" not in result["stdout"]
        assert result["rc"] == 0