Esempio n. 1
0
def test_positive_backup_offline_logical(setup_backup_tests, ansible_module):
    """Take offline backup of server include-db-dumps

    :id: 26c9b3cb-f96a-44bb-828b-69865099af39

    :setup:

        1. foreman-maintain should be installed.
    :steps:
        1. Run foreman-maintain backup offline --include-db-dumps /backup_dir/

    :expectedresults: Backup should successful.

    :CaseImportance: Critical
    """
    subdir = "{}backup-{}".format(BACKUP_DIR, gen_string("alpha"))
    contacted = ansible_module.command(
        Backup.run_offline_backup(["-y", "--include-db-dumps", subdir]))
    for result in contacted.values():
        logger.info(result["stdout"])
        assert "FAIL" not in result["stdout"]
        assert result["rc"] == 0

    contacted = ansible_module.command("ls {}".format(subdir))
    timestamped_dir = contacted.values()[0]["stdout_lines"][0]
    contacted = ansible_module.command("ls -a {}/{}".format(
        subdir, timestamped_dir))
    files_list = contacted.values()[0]["stdout_lines"]
    expected_files = OFFLINE_BACKUP_FILES + ONLINE_BACKUP_FILES

    # capsule-specific file list
    if server() == "capsule":
        expected_files = OFFLINE_CAPS_FILES + ONLINE_CAPS_FILES
    assert set(files_list).issuperset(expected_files +
                                      CONTENT_FILES), assert_msg
Esempio n. 2
0
def test_positive_backup_online(setup_backup_tests, ansible_module):
    """Take online backup of server

    :id: 962d21de-04bc-43fd-9076-cdbfdb9d798e

    :setup:

        1. foreman-maintain should be installed.
    :steps:
        1. Run foreman-maintain backup online /backup_dir/

    :expectedresults: Backup should successful.

    :CaseImportance: Critical
    """
    subdir = f"{BACKUP_DIR}backup-{gen_string('alpha')}"
    contacted = ansible_module.command(Backup.run_online_backup(["-y",
                                                                 subdir]))
    for result in contacted.values():
        logger.info(result["stdout"])
        assert "FAIL" not in result["stdout"]
        assert result["rc"] == 0

    # getting created files
    contacted = ansible_module.command(f"ls {subdir}")
    timestamped_dir = contacted.values()[0]["stdout_lines"][0]
    contacted = ansible_module.command(f"ls -a {subdir}/{timestamped_dir}")
    files_list = contacted.values()[0]["stdout_lines"]
    expected_files = ONLINE_BACKUP_FILES

    # capsule-specific file list
    if server() == "capsule":
        expected_files = ONLINE_CAPS_FILES
    assert set(files_list).issuperset(expected_files +
                                      CONTENT_FILES), assert_msg
Esempio n. 3
0
def test_positive_backup_online_split_pulp_tar(setup_backup_tests,
                                               ansible_module):
    """Take online backup of server spliting pulp tar

    :id: f2c7173f-a955-4c0c-a232-60f6161fda81

    :setup:

        1. foreman-maintain should be installed.
    :steps:
        1. Run foreman-maintain backup online  --split-pulp-tar 1M /backup_dir/

    :expectedresults: Backup should successful.

    :CaseImportance: Critical
    """
    subdir = f"{BACKUP_DIR}backup-{gen_string('alpha')}"
    contacted = ansible_module.command(
        Backup.run_online_backup(["-y", "--split-pulp-tar", "1M", subdir]))
    for result in contacted.values():
        logger.info(result["stdout"])
        assert "FAIL" not in result["stdout"]
        assert result["rc"] == 0

    contacted = ansible_module.command(f"ls {subdir}")
    timestamped_dir = contacted.values()[0]["stdout_lines"][0]
    contacted = ansible_module.command(f"ls -a {subdir}/{timestamped_dir}")
    files_list = contacted.values()[0]["stdout_lines"]
    expected_files = ONLINE_BACKUP_FILES

    # capsule-specific file list
    if server() == "capsule":
        expected_files = ONLINE_CAPS_FILES
    assert set(files_list).issuperset(expected_files +
                                      CONTENT_FILES), assert_msg
Esempio n. 4
0
def test_positive_backup_online_preserve_directory(setup_backup_tests,
                                                   ansible_module):
    """Take online backup of server preserving directory

    :id: 343c79fd-5fd3-45a3-bb75-c807817f2970

    :setup:

        1. foreman-maintain should be installed.
    :steps:
        1. Run foreman-maintain backup online --preserve-directory /backup_dir/

    :expectedresults: Backup should successful.

    :CaseImportance: Critical
    """
    subdir = f"{BACKUP_DIR}backup-{gen_string('alpha')}"
    ansible_module.file(path=f"{subdir}", state="directory", owner="postgres")
    contacted = ansible_module.command(
        Backup.run_online_backup(["-y", "--preserve-directory", subdir]))
    for result in contacted.values():
        logger.info(result["stdout"])
        assert "FAIL" not in result["stdout"]
        assert result["rc"] == 0

    contacted = ansible_module.command(f"ls -a {subdir}")
    files_list = contacted.values()[0]["stdout_lines"]
    expected_files = ONLINE_BACKUP_FILES

    # capsule-specific file list
    if server() == "capsule":
        expected_files = ONLINE_CAPS_FILES
    assert set(files_list).issuperset(expected_files +
                                      CONTENT_FILES), assert_msg
Esempio n. 5
0
def test_positive_foreman_maintain_upgrade_list(ansible_module):
    """List versions this system is upgradable to

    :id: 12efec41-4f09-4199-a20c-a4525e773b78

    :setup:

        1. foreman-maintain should be installed.
    :steps:
        1. Run foreman-maintain upgrade list-versions

    :expectedresults: Versions system is upgradable to are listed.

    :CaseImportance: Critical
    """
    if server() == "satellite":
        satellite_version = ansible_module.command(
            "rpm -q 'satellite' --queryformat='%{VERSION}'").values(
            )[0]["stdout"]
        if satellite_version.startswith("6.9"):
            versions = ["6.9.z"]
        elif satellite_version.startswith("6.8"):
            versions = ["6.8.z", "6.9"]
        elif satellite_version.startswith("6.7"):
            versions = ["6.7.z", "6.8"]
        elif satellite_version.startswith("6.6"):
            versions = ["6.6.z", "6.7"]
        elif satellite_version.startswith("6.5"):
            versions = ["6.5.z", "6.6"]
        elif satellite_version.startswith("6.4"):
            versions = ["6.4.z", "6.5"]
        elif satellite_version.startswith("6.3"):
            versions = ["6.3.z", "6.4"]
        elif satellite_version.startswith("6.2"):
            versions = ["6.2.z", "6.3"]
        else:
            versions = ["unsupported satellite version"]
    else:
        capsule_version = ansible_module.command(
            "rpm -q 'satellite-capsule' --queryformat='%{VERSION}'").values(
            )[0]["stdout"]
        if capsule_version.startswith("6.9"):
            versions = ["6.9.z"]
        elif capsule_version.startswith("6.8"):
            versions = ["6.8.z", "6.9"]
        elif capsule_version.startswith("6.7"):
            versions = ["6.7.z", "6.8"]
        else:
            versions = ["unsupported capsule version"]

    contacted = ansible_module.command(Upgrade.list_versions())
    for result in contacted.values():
        logger.info(result["stdout"])
        assert "FAIL" not in result["stdout"]
        for ver in versions:
            assert ver in result["stdout_lines"]
Esempio n. 6
0
def test_positive_backup_stopped_dynflowd(setup_backup_tests, ansible_module):
    """Take online backup of server when dynflowd is not running

    :id: 321b5f16-337c-4370-87b6-cfe1c78c9139

    :setup:

        1. foreman-maintain should be installed.

    :steps:
        1. Run foreman-maintain service stop --only dynflowd
        2. Run foreman-maintain backup online /backup_dir/

    :expectedresults: Backup should successful.

    :CaseImportance: Critical
    """
    subdir = "{}backup-{}".format(BACKUP_DIR, gen_string("alpha"))
    try:
        setup = ansible_module.command(
            Service.service_stop({u"only": "dynflowd"}))
        for result in setup.values():
            logger.info(result)
            assert result["rc"] == 0
        contacted = ansible_module.command(
            Backup.run_online_backup(["-y", subdir]))
        for result in contacted.values():
            logger.info(result["stdout"])
            assert "FAIL" not in result["stdout"]
            assert result["rc"] == 0

        # getting created files
        contacted = ansible_module.command("ls {}".format(subdir))
        timestamped_dir = contacted.values()[0]["stdout_lines"][0]
        contacted = ansible_module.command("ls -a {}/{}".format(
            subdir, timestamped_dir))
        files_list = contacted.values()[0]["stdout_lines"]
        expected_files = ONLINE_BACKUP_FILES

        # capsule-specific file list
        if server() == "capsule":
            expected_files = ONLINE_CAPS_FILES
        assert set(files_list).issuperset(expected_files +
                                          CONTENT_FILES), assert_msg
    finally:
        teardown = ansible_module.command(Service.service_start())
        for result in teardown.values():
            assert result["rc"] == 0
Esempio n. 7
0
def capsule_only():
    """Run test on Capsule server only.

    Usage:

    To run test on capsule only::

        from TestFM.decorators import capsule_only

        @capsule_only
        def test_health_check():
            # test code continues here
    """
    return pytest.mark.skipif(
        server() == "satellite", reason="This test is only intended to run on Capsule server."
    )
Esempio n. 8
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),
    )
Esempio n. 9
0
def test_positive_backup_offline_preserve_directory(setup_backup_tests,
                                                    ansible_module):
    """Take offline backup of server preserving directory

    :id: 99fc9319-d495-481a-b345-5f6ca12c4225

    :setup:

        1. foreman-maintain should be installed.
    :steps:
        1. Run foreman-maintain backup offline --preserve-directory
        /backup_dir/

    :expectedresults: Backup should successful.

    :CaseImportance: Critical
    """
    subdir = "{}backup-{}".format(BACKUP_DIR, gen_string("alpha"))
    ansible_module.file(
        path="{}".format(subdir),
        state="directory",
        owner="postgres",
    )
    contacted = ansible_module.command(
        Backup.run_offline_backup(["-y", "--preserve-directory", subdir]))
    for result in contacted.values():
        logger.info(result["stdout"])
        assert "FAIL" not in result["stdout"]
        assert result["rc"] == 0

    contacted = ansible_module.command("ls -a {}".format(subdir))
    files_list = contacted.values()[0]["stdout_lines"]
    expected_files = OFFLINE_BACKUP_FILES

    # capsule-specific file list
    if server() == "capsule":
        expected_files = OFFLINE_CAPS_FILES
    assert set(files_list).issuperset(expected_files +
                                      CONTENT_FILES), assert_msg
Esempio n. 10
0
def test_positive_backup_offline_capsule_features(setup_backup_tests,
                                                  ansible_module):
    """Take offline backup of server including capsule features dns, tftp, etc.

    :id: 31f93423-affb-4f41-a666-993aa0a56e12

    :setup:

        1. foreman-maintain should be installed.
    :steps:
        1. Run foreman-maintain backup offline --features dns,tftp
        /backup_dir/

    :expectedresults: Backup should successful.

    :CaseImportance: Critical
    """
    subdir = "{}backup-{}".format(BACKUP_DIR, gen_string("alpha"))
    contacted = ansible_module.command(
        Backup.run_offline_backup(
            ["-y", "--features", "dns,tftp,dhcp,openscap", subdir]))
    for result in contacted.values():
        logger.info(result["stdout"])
        assert "FAIL" not in result["stdout"]
        assert result["rc"] == 0

    contacted = ansible_module.command("ls {}".format(subdir))
    timestamped_dir = contacted.values()[0]["stdout_lines"][0]
    contacted = ansible_module.command("ls -a {}/{}".format(
        subdir, timestamped_dir))
    files_list = contacted.values()[0]["stdout_lines"]
    expected_files = OFFLINE_BACKUP_FILES

    # capsule-specific file list
    if server() == "capsule":
        expected_files = OFFLINE_CAPS_FILES
    assert set(files_list).issuperset(expected_files +
                                      CONTENT_FILES), assert_msg
Esempio n. 11
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(
             f"yum -y localinstall {katello_ca_consumer}")
         if server() == "satellite":
             ansible_module.command(
                 f'subscription-manager register --force --org="{DOGFOOD_ORG}" '
                 f'--activationkey="{DOGFOOD_ACTIVATIONKEY}"')
         else:
             ansible_module.command(
                 f'subscription-manager register --force --org="{DOGFOOD_ORG}" '
                 f'--activationkey="{CAPSULE_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
Esempio n. 12
0
def test_positive_backup_offline_split_pulp_tar(setup_backup_tests,
                                                ansible_module):
    """Take offline backup of server splitting pulp tar

    :id: bdd19e11-89b6-471c-af65-359046686473

    :setup:

        1. foreman-maintain should be installed.
    :steps:
        1. Run foreman-maintain backup offline --split-pulp-tar 10M
        /backup_dir/

    :expectedresults: Backup should successful.

    :CaseImportance: Critical
    """
    subdir = "{}backup-{}".format(BACKUP_DIR, gen_string("alpha"))
    contacted = ansible_module.command(
        Backup.run_offline_backup(["-y", "--split-pulp-tar", "10M", subdir]))
    for result in contacted.values():
        logger.info(result["stdout"])
        assert "FAIL" not in result["stdout"]
        assert result["rc"] == 0

    contacted = ansible_module.command("ls {}".format(subdir))
    timestamped_dir = contacted.values()[0]["stdout_lines"][0]
    contacted = ansible_module.command("ls -a {}/{}".format(
        subdir, timestamped_dir))
    files_list = contacted.values()[0]["stdout_lines"]
    expected_files = OFFLINE_BACKUP_FILES

    # capsule-specific file list
    if server() == "capsule":
        expected_files = OFFLINE_CAPS_FILES
    assert set(files_list).issuperset(expected_files +
                                      CONTENT_FILES), assert_msg
Esempio n. 13
0
def test_positive_backup_online_skip_pulp_content(setup_backup_tests,
                                                  ansible_module):
    """Take online backup skipping pulp content of server

    :id: 0a041aed-8578-40d9-8044-6a1db0daba59

    :setup:

        1. foreman-maintain should be installed.
    :steps:
        1. Run foreman-maintain backup online --skip-pulp-content /backup_dir/

    :expectedresults: Backup should successful.

    :CaseImportance: Critical
    """
    subdir = "{}backup-{}".format(BACKUP_DIR, gen_string("alpha"))
    contacted = ansible_module.command(
        Backup.run_online_backup(["-y", "--skip-pulp-content", subdir]))
    for result in contacted.values():
        logger.info(result["stdout"])
        assert "FAIL" not in result["stdout"]
        assert result["rc"] == 0

    # getting created files
    contacted = ansible_module.command("ls {}".format(subdir))
    timestamped_dir = contacted.values()[0]["stdout_lines"][0]
    contacted = ansible_module.command("ls -a {}/{}".format(
        subdir, timestamped_dir))
    files_list = contacted.values()[0]["stdout_lines"]
    expected_files = ONLINE_BACKUP_FILES

    # capsule-specific file list
    if server() == "capsule":
        expected_files = ONLINE_CAPS_FILES
    assert set(files_list).issuperset(expected_files), assert_msg
    assert CONTENT_FILES not in files_list, "content not skipped"
Esempio n. 14
0
def test_positive_backup_offline(setup_backup_tests, ansible_module):
    """Take offline backup of server

    :id: 2bbd15de-59f4-4ea0-8016-4cc951c6e4b9

    :setup:

        1. foreman-maintain should be installed.
    :steps:
        1. Run foreman-maintain backup offline /backup_dir/

    :expectedresults: Backup should successful.

    :CaseImportance: Critical
    """
    subdir = "{}backup-{}".format(BACKUP_DIR, gen_string("alpha"))
    contacted = ansible_module.command(
        Backup.run_offline_backup(["-y", subdir]))
    for result in contacted.values():
        logger.info(result["stdout"])
        assert "FAIL" not in result["stdout"]
        assert result["rc"] == 0

    # getting created files
    contacted = ansible_module.command("ls {}".format(subdir))
    timestamped_dir = contacted.values()[0]["stdout_lines"][0]
    contacted = ansible_module.command("ls -a {}/{}".format(
        subdir, timestamped_dir))
    files_list = contacted.values()[0]["stdout_lines"]
    expected_files = OFFLINE_BACKUP_FILES

    # capsule-specific file list
    if server() == "capsule":
        expected_files = OFFLINE_CAPS_FILES
    assert set(files_list).issuperset(expected_files +
                                      CONTENT_FILES), assert_msg
Esempio n. 15
0
def test_positive_backup_online_caspule_features(setup_backup_tests,
                                                 ansible_module):
    """Take online backup of server including capsule features dns, tftp, etc.

    :id: a36f8a53-a233-4bc8-bd0f-c4629e383cb9

    :setup:

        1. foreman-maintain should be installed.
    :steps:
        1. Run foreman-maintain backup online  --features dns,tftp /backup_dir/

    :expectedresults: Backup should successful.

    :CaseImportance: Critical
    """
    subdir = f"{BACKUP_DIR}backup-{gen_string('alpha')}"
    contacted = ansible_module.command(
        Backup.run_online_backup(
            ["-y", "--features", "dns,tftp,openscap,dhcp", subdir]))
    for result in contacted.values():
        logger.info(result["stdout"])
        assert "FAIL" not in result["stdout"]
        assert result["rc"] == 0

    # getting created files
    contacted = ansible_module.command(f"ls {subdir}")
    timestamped_dir = contacted.values()[0]["stdout_lines"][0]
    contacted = ansible_module.command(f"ls -a {subdir}/{timestamped_dir}")
    files_list = contacted.values()[0]["stdout_lines"]
    expected_files = ONLINE_BACKUP_FILES
    # capsule-specific file list
    if server() == "capsule":
        expected_files = ONLINE_CAPS_FILES
    assert set(files_list).issuperset(expected_files +
                                      CONTENT_FILES), assert_msg
Esempio n. 16
0
    export_command = "export FOREMAN_MAINTAIN_USE_BETA=1;"
    contacted = ansible_module.shell(
        export_command + Advanced.run_repositories_setup({"version": "6.8"}))
    for result in contacted.values():
        logger.info(result["stdout"])
        assert "FAIL" not in result["stdout"]
        assert result["rc"] == 0
    contacted = ansible_module.command("yum repolist")
    for result in contacted.values():
        logger.info(result["stdout"])
        for repo in sat_beta_repo:
            assert repo in result["stdout"]


@pytest.mark.capsule
@pytest.mark.skipif(server() == "satellite",
                    reason="Test intended to run only on Capsule servers")
def test_positive_capsule_repositories_setup(setup_subscribe_to_cdn_dogfood,
                                             ansible_module):
    """Verify that all required capsule repositories gets enabled.

    :id: 88558fb0-2268-469f-86ae-c4d18ccef782

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

    :steps:
        1. Run 'foreman-maintain advanced procedure run repositories-setup --version 6.y

    :BZ: 1684730, 1869731
Esempio n. 17
0
        logger.info(result["stdout"])
        for repo in sat_beta_repo:
            assert repo in result["stdout"]

    # 7.0 till not GA
    contacted = ansible_module.shell(Advanced.run_repositories_setup({"version": "7.0"}))
    for result in contacted.values():
        logger.info(result["stdout"])
        assert "FAIL" in result["stdout"]
        assert result["rc"] == 1
        for repo in sat_repos["7.0"]:
            assert repo in result["stdout"]


@pytest.mark.capsule
@pytest.mark.skipif(server() == "satellite", reason="Test intended to run only on Capsule servers")
def test_positive_capsule_repositories_setup(setup_subscribe_to_cdn_dogfood, ansible_module):
    """Verify that all required capsule repositories gets enabled.

    :id: 88558fb0-2268-469f-86ae-c4d18ccef782

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

    :steps:
        1. Run 'foreman-maintain advanced procedure run repositories-setup --version 6.y

    :BZ: 1684730, 1869731

    :expectedresults: Required Capsule repositories should get enabled