示例#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_bz_1696862(request, ansible_module):
    """ This fixture is used by test test_positive_fm_service_restart_bz_1696862
    for setup/teardown.
    """
    if float(product()) >= 6.6:
        contacted = ansible_module.lineinfile(
            dest=satellite_answer_file,
            regexp="  initial_admin_password:"******"  initial_admin_password: invalid_password",
            backup="yes",
        )
    else:
        contacted = ansible_module.lineinfile(
            dest=satellite_answer_file,
            regexp="  admin_password:"******"  admin_password: invalid_password",
            backup="yes",
        )
    ansible_module.command("mv .hammer/cli.modules.d/foreman.yml /tmp/foreman.yml")
    ansible_module.command("mv {} /tmp/foreman-maintain-hammer.yml".format(fm_hammer_yml))

    def teardown_bz_1696862():
        ansible_module.command("mv /tmp/foreman.yml .hammer/cli.modules.d/foreman.yml")
        ansible_module.command("mv /tmp/foreman-maintain-hammer.yml {}".format(fm_hammer_yml))
        ansible_module.command(
            "mv {} {}".format(contacted.values()[0]["backup"], satellite_answer_file)
        )

    request.addfinalizer(teardown_bz_1696862)
示例#3
0
def test_positive_repositories_validate(setup_install_pkgs, ansible_module):
    """ Test repositories-validate pre-upgrade check is
     skipped when system is subscribed using custom activationkey.

    :id: 811698c0-09da-4727-8886-077aebb2b5ed

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

    :steps:
        1. Run foreman-maintain upgrade check.

    :BZ: 1632111

    :expectedresults: repositories-validate check should be skipped.

    :CaseImportance: Critical
    """
    skip_message = "Your system is subscribed using custom activation key"
    export_command = "export EXTERNAL_SAT_ORG=Sat6-CI;export EXTERNAL_SAT_ACTIVATION_KEY=Ext_AK;"
    fm_command = Upgrade.check([
        "--target-version",
        "{}.z".format(product()),
        "--whitelist",
        '"disk-performance,check-non-redhat-repository,check-hotfix-installed,'
        'check-upstream-repository"',
        "--assumeyes",
    ])
    contacted = ansible_module.shell(export_command + fm_command)
    for result in contacted.values():
        logger.info(result["stdout"])
        assert "SKIPPED" in result["stdout"]
        assert "FAIL" not in result["stdout"]
        assert skip_message in result["stdout"]
示例#4
0
def run_only_on(*server):
    """Decorator to skip tests based on server version.

    Usage:

    To skip a specific test::

        from TestFM.decorators import run_only_on

        @run_only_on('sat63')
        def test_health_check():
            # test code continues here

    :param str project: Enter 'sat63' , 'sat62' and 'sat61' for specific
     version
    """
    return pytest.mark.skipif(
        product() not in server,
        reason="Server version is '{0}' and this test will run only "
               "on '{1}' version".format(product(), server)
    )
示例#5
0
def ends_in(version):
    """Decorator to select tests based on maximum Satellite version.

    Usage:

    To select a specific test based on maximum Satellite version.::

        from TestFM.decorators import ends_in

        @ends_in(6.6)
        def test_health_check():
            # test code continues here

    :param float version: Enter 6.7, 6.6, 6.5 , 6.4 , 6.3 , 6.2 and 6.1
    for specific version
    """
    return pytest.mark.skipif(
        float(product()) > version,
        reason="Server version is '{}' and this test will run only "
        "on {} <= '{}'".format(product(), server(), version),
    )
示例#6
0
def run_only_on(*server_version):
    """Decorator to skip tests based on server version.

    Usage:

    To skip a specific test::

        from TestFM.decorators import run_only_on

        @run_only_on('6.4')
        def test_health_check():
            # test code continues here

    :param str server_version: Enter '6.8', 6.7', '6.6', '6.5', '6.4' and '6.3'
    for specific version
    """
    return pytest.mark.skipif(
        product() not in server,
        reason="Server version is '{}' and this test will run only "
        "on '{}' version".format(product(), server_version),
    )
示例#7
0
def run_only_on(*server):
    """Decorator to skip tests based on server version.

    Usage:

    To skip a specific test::

        from TestFM.decorators import run_only_on

        @run_only_on('sat63')
        def test_health_check():
            # test code continues here

    :param str project: Enter 'sat65' , 'sat64' , 'sat63' , 'sat62' and 'sat61'
    for specific version
    """
    return pytest.mark.skipif(
        product() not in server,
        reason="Server version is '{0}' and this test will run only "
               "on '{1}' version".format(product(), server)
    )
示例#8
0
 def teardown_subscribe_to_cdn_dogfood():
     if subscribed_to_cdn is False:
         ansible_module.command("subscription-manager unregister")
         ansible_module.command("subscription-manager clean")
         ansible_module.command(
             "yum -y localinstall {}".format(katello_ca_consumer))
         ansible_module.command(
             'subscription-manager register --force --org="{}" --activationkey="{}"'
             .format(DOGFOOD_ORG, DOGFOOD_ACTIVATIONKEY))
     else:
         contacted = ansible_module.command(
             Advanced.run_repositories_setup({"version": product()
                                              })  # Satellite minor version
         )
         for result in contacted.values():
             logger.info(result["stdout"])
             assert "FAIL" not in result["stdout"]
             assert result["rc"] == 0
示例#9
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
    if float(product()) >= 6.6:
        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():
        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")

    request.addfinalizer(teardown_hotfix_check)
    return fpath