def test_positive_backup_online_all(setup_backup_tests, ansible_module):
    """Take online backup of server providing all options

    :id: 86a93e4f-61e3-4206-ae28-ce01136c5518

    :setup:

        1. foreman-maintain should be installed.
        2. Take backup of server.
    :steps:
        1. Run foreman-maintain backup online -y -f -s -p -t 10M -i
        /previous_backup/ --features dns,tftp /backup_dir/

    :expectedresults: Backup should successful.

    :CaseImportance: Critical
    """
    subdir = "{}backup-{}".format(BACKUP_DIR, gen_string("alpha"))
    ansible_module.file(path=subdir, state="directory", mode="0777")
    setup = ansible_module.command(Backup.run_online_backup(["-y", "/mnt/"]))
    for result in setup.values():
        logger.info(result["stdout"])
        assert "FAIL" not in result["stdout"]
        assert result["rc"] == 0
    contacted = ansible_module.command(
        Backup.run_online_backup([
            "-y -f -s -p -t 10M -i", "/mnt/", "--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
Exemple #2
0
def test_positive_backup_online_incremental(ansible_module):
    """Take incremental online backup of server

    :id: e4af1804-8479-47c0-9f50-460b6edbe9e0

    :setup:

        1. foreman-maintain should be installed.
        2. Take backup of server.
    :steps:
        1. Run foreman-maintain backup online --incremental
         /previous_backup_dir/ /backup_dir/

    :expectedresults: Backup should successful.

    :CaseImportance: Critical
    """
    setup = ansible_module.command(Backup.run_online_backup(['-y', '/mnt/']))
    for result in setup.values():
        logger.info(result['stdout'])
        assert "FAIL" not in result['stdout']
        assert result['rc'] == 0
    contacted = ansible_module.command(
        Backup.run_online_backup(['-y', '--incremental', '/mnt/', BACKUP_DIR]))
    for result in contacted.values():
        logger.info(result['stdout'])
        assert "FAIL" not in result['stdout']
        assert result['rc'] == 0
Exemple #3
0
def test_positive_backup_online_all(ansible_module):
    """Take online backup of server providing all options

    :id: 86a93e4f-61e3-4206-ae28-ce01136c5518

    :setup:

        1. foreman-maintain should be installed.
        2. Take backup of server.
    :steps:
        1. Run foreman-maintain backup online -y -f -s -p -t 10M -i
        /previous_backup/ --features dns,tftp /backup_dir/

    :expectedresults: Backup should successful.

    :CaseImportance: Critical
    """
    setup = ansible_module.command(Backup.run_online_backup(['-y', '/mnt/']))
    for result in setup.values():
        logger.info(result['stdout'])
        assert "FAIL" not in result['stdout']
        assert result['rc'] == 0
    contacted = ansible_module.command(
        Backup.run_online_backup([
            '-y -f -s -p -t 10M -i', '/mnt/', '--features',
            'dns,tftp,openscap,dhcp', BACKUP_DIR
        ]))
    for result in contacted.values():
        logger.info(result['stdout'])
        assert "FAIL" not in result['stdout']
        assert result['rc'] == 0
Exemple #4
0
def test_positive_backup_offline_incremental(ansible_module):
    """Take offline incremental backup of server

    :id: 27df1544-0bc6-4922-a45c-3c7f3b805a1d

    :setup:

        1. foreman-maintain should be installed.
        2. Take offline backup of server
    :steps:
        1. Run foreman-maintain backup offline --incremental /previous_backup/
         /backup_dir/

    :expectedresults: Backup should successful.

    :CaseImportance: Critical
    """
    setup = ansible_module.command(Backup.run_offline_backup(['-y', '/mnt/']))
    for result in setup.values():
        logger.info(result['stdout'])
        assert "FAIL" not in result['stdout']
        assert result['rc'] == 0
    contacted = ansible_module.command(
        Backup.run_offline_backup(['-y', '--incremental', '/mnt/',
                                   BACKUP_DIR]))
    for result in contacted.values():
        logger.info(result['stdout'])
        assert "FAIL" not in result['stdout']
        assert result['rc'] == 0
Exemple #5
0
def test_positive_backup_offline_all(ansible_module):
    """Take offline backup of server providing all options

    :id: 2065e58a-4710-4315-af9e-e7049fabf323

    :setup:

        1. foreman-maintain should be installed.
        2. Take offline backup of server.
    :steps:
        1. Run foreman-maintain backup offline -y -f -s -p -t 10M -i
         /prevoius_backup/ --features dns,tfp --include-db-dumps /backup_dir/

    :expectedresults: Backup should successful.

    :CaseImportance: Critical
    """
    setup = ansible_module.command(Backup.run_offline_backup(['-y', '/mnt/']))
    for result in setup.values():
        logger.info(result['stdout'])
        assert "FAIL" not in result['stdout']
        assert result['rc'] == 0
    contacted = ansible_module.command(
        Backup.run_offline_backup([
            '-y -f -s -p -t 10M -i', '/mnt/',
            '--features dns,tfp,dhcp,openscap', '--include-db-dumps',
            BACKUP_DIR
        ]))
    for result in contacted.values():
        logger.info(result['stdout'])
        assert "FAIL" not in result['stdout']
        assert result['rc'] == 0
Exemple #6
0
def test_positive_backup_online_skip_pulp_content(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 = "{0}backup-{1}".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 {0}/{1}'.format(
        subdir, timestamped_dir))
    files_list = contacted.values()[0]['stdout_lines']
    assert set(files_list).issuperset(ONLINE_BACKUP_FILES), assert_msg
    assert CONTENT_FILES not in files_list, "content not skipped"
Exemple #7
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
Exemple #8
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 = f"{BACKUP_DIR}backup-{gen_string('alpha')}"
    ansible_module.file(path=f"{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(f"ls -a {subdir}")
    files_list = contacted.values()[0]["stdout_lines"]
    expected_files = OFFLINE_BACKUP_FILES

    assert set(files_list).issuperset(expected_files +
                                      CONTENT_FILES), assert_msg
Exemple #9
0
def test_positive_backup_offline_skip_pulp_content(setup_backup_tests,
                                                   ansible_module):
    """Take offline backup of server skipping pulp content

    :id: 8c31620f-a1f1-4422-8609-3fd8e05d6056

    :setup:

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

    :expectedresults: Backup should successful.

    :CaseImportance: Critical
    """
    subdir = f"{BACKUP_DIR}backup-{gen_string('alpha')}"
    contacted = ansible_module.command(
        Backup.run_offline_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(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 = OFFLINE_BACKUP_FILES

    assert set(files_list).issuperset(expected_files), assert_msg
    assert CONTENT_FILES not in files_list, "content not skipped"
Exemple #10
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 = f"{BACKUP_DIR}backup-{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(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 = OFFLINE_BACKUP_FILES

    assert set(files_list).issuperset(expected_files +
                                      CONTENT_FILES), assert_msg
Exemple #11
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
Exemple #12
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
Exemple #13
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 = f"{BACKUP_DIR}backup-{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(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 = OFFLINE_BACKUP_FILES

    assert set(files_list).issuperset(expected_files +
                                      CONTENT_FILES), assert_msg
Exemple #14
0
def test_positive_backup_offline_logical(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 = "{0}backup-{1}".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 {0}/{1}'.format(
        subdir, timestamped_dir))
    files_list = contacted.values()[0]['stdout_lines']
    assert set(files_list).issuperset(OFFLINE_BACKUP_FILES +
                                      ONLINE_BACKUP_FILES +
                                      CONTENT_FILES), assert_msg
Exemple #15
0
def test_positive_backup_offline_capsule_features(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 = "{0}backup-{1}".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 {0}/{1}'.format(
        subdir, timestamped_dir))
    files_list = contacted.values()[0]['stdout_lines']
    assert set(files_list).issuperset(OFFLINE_BACKUP_FILES +
                                      CONTENT_FILES), assert_msg
Exemple #16
0
def test_positive_backup_online(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 = "{0}backup-{1}".format(BACKUP_DIR, 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('ls {}'.format(subdir))
    timestamped_dir = contacted.values()[0]['stdout_lines'][0]
    contacted = ansible_module.command('ls -a {0}/{1}'.format(
        subdir, timestamped_dir))
    files_list = contacted.values()[0]['stdout_lines']
    assert set(files_list).issuperset(ONLINE_BACKUP_FILES +
                                      CONTENT_FILES), assert_msg
Exemple #17
0
def test_positive_backup_offline_split_pulp_tar(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 = "{0}backup-{1}".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 {0}/{1}'.format(
        subdir, timestamped_dir))
    files_list = contacted.values()[0]['stdout_lines']
    assert set(files_list).issuperset(OFFLINE_BACKUP_FILES +
                                      CONTENT_FILES), assert_msg
Exemple #18
0
def test_positive_backup_offline_preserve_directory(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 = "{0}backup-{1}".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 {0}'.format(subdir))
    files_list = contacted.values()[0]['stdout_lines']
    assert set(files_list).issuperset(OFFLINE_BACKUP_FILES +
                                      CONTENT_FILES), assert_msg
Exemple #19
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 = f"{BACKUP_DIR}backup-{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(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 = OFFLINE_BACKUP_FILES

    assert set(files_list).issuperset(expected_files +
                                      CONTENT_FILES), assert_msg
Exemple #20
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
Exemple #21
0
def test_positive_backup_stopped_foreman_tasks(setup_backup_tests,
                                               ansible_module):
    """Take online backup of server when foreman-tasks is not running

    :id: 3def9d00-f9be-4817-adf0-acd7cf68460b

    :setup:

        1. foreman-maintain should be installed.

    :steps:
        1. Run foreman-maintain service stop --only foreman-tasks
        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": "foreman-tasks"}))
        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
    finally:
        teardown = ansible_module.command(Service.service_start())
        for result in teardown.values():
            assert result["rc"] == 0
Exemple #22
0
def test_negative_backup_online_incremental_nodir(ansible_module):
    """Take online backup of server with no destination

    :id: cfb68cdf-9d27-4a38-bc16-900fc9488ac6

    :setup:

        1. foreman-maintain should be installed.
    :steps:
        1. Run foreman-maintain backup offline with nonexistent
        directory

    :expectedresults: backup aborted, relevant message is
        returned

    :CaseImportance: Critical
    """
    contacted = ansible_module.command(Backup.run_online_backup([
        '-y',
        '--incremental',
        gen_string('alpha'),
    ]))
    for result in contacted.values():
        logger.info(result['stderr'])
        assert result['rc'] == 1
        assert NOPREV_MSG in result['stderr']
Exemple #23
0
def test_positive_backup_offline_incremental(ansible_module):
    """Take offline incremental backup of server

    :id: 27df1544-0bc6-4922-a45c-3c7f3b805a1d

    :setup:

        1. foreman-maintain should be installed.
        2. Take offline backup of server
    :steps:
        1. Run foreman-maintain backup offline --incremental /previous_backup/
         /backup_dir/

    :expectedresults: Backup should successful.

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

    contacted = ansible_module.stat(path=subdir)
    source_size = contacted.values()[0]['stat']['size']
    contacted = ansible_module.stat(path=dest_dir)
    dest_size = contacted.values()[0]['stat']['size']
    assert source_size >= dest_size
Exemple #24
0
def test_positive_backup_online_incremental(setup_backup_tests,
                                            ansible_module):
    """Take incremental online backup of server

    :id: e4af1804-8479-47c0-9f50-460b6edbe9e0

    :setup:

        1. foreman-maintain should be installed.
        2. Take backup of server.
    :steps:
        1. Run foreman-maintain backup online --incremental
        /previous_backup_dir/ /backup_dir/

    :expectedresults: Backup should successful.

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

    contacted = ansible_module.stat(path=subdir)
    source_size = contacted.values()[0]["stat"]["size"]
    contacted = ansible_module.stat(path=dest_dir)
    dest_size = contacted.values()[0]["stat"]["size"]
    assert source_size >= dest_size
Exemple #25
0
def test_positive_backup_offline_incremental(setup_backup_tests,
                                             ansible_module):
    """Take offline incremental backup of server

    :id: 27df1544-0bc6-4922-a45c-3c7f3b805a1d

    :setup:

        1. foreman-maintain should be installed.
        2. Take offline backup of server
    :steps:
        1. Run foreman-maintain backup offline --incremental /previous_backup/
        /backup_dir/

    :expectedresults: Backup should successful.

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

    contacted = ansible_module.stat(path=subdir)
    source_size = contacted.values()[0]["stat"]["size"]
    contacted = ansible_module.stat(path=dest_dir)
    dest_size = contacted.values()[0]["stat"]["size"]
    assert source_size >= dest_size
Exemple #26
0
def test_positive_backup_offline_all(setup_backup_tests, ansible_module):
    """Take offline backup of server providing all options

    :id: 2065e58a-4710-4315-af9e-e7049fabf323

    :setup:

        1. foreman-maintain should be installed.
        2. Take offline backup of server.

    :steps:
        1. Run foreman-maintain backup offline -y -f -s -p -t 10M -i
        /prevoius_backup/ --features dns,tfp --include-db-dumps /backup_dir/

    :expectedresults: Backup should successful.

    :CaseImportance: Critical
    """
    subdir = "{}backup-{}".format(BACKUP_DIR, gen_string("alpha"))
    ansible_module.file(path=subdir, state="directory", mode="0777")
    setup = ansible_module.command(Backup.run_offline_backup(["-y", subdir]))
    for result in setup.values():
        logger.info(result["stdout"])
        assert "FAIL" not in result["stdout"]
        assert result["rc"] == 0
    contacted = ansible_module.command("ls {}".format(subdir))
    source_dir = contacted.values()[0]["stdout_lines"][0]
    contacted = ansible_module.command(
        Backup.run_offline_backup([
            "-y -f -s -p -t 10M -i",
            "{}/{}".format(subdir, source_dir),
            "--features dns,tfp,dhcp,openscap",
            "--include-db-dumps",
            subdir,
        ]))
    for result in contacted.values():
        logger.info(result["stdout"])
        assert "FAIL" not in result["stdout"]
        assert result["rc"] == 0
Exemple #27
0
def test_positive_backup_stopped_dynflowd(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 = "{0}backup-{1}".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 {0}/{1}'.format(subdir, timestamped_dir))
        files_list = contacted.values()[0]['stdout_lines']
        expected_files = ONLINE_BACKUP_FILES

        # capsule-specific file list
        if ansible_host_pattern == '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
Exemple #28
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
Exemple #29
0
def test_positive_backup_online_preserve_directory(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 = "{0}backup-{1}".format(BACKUP_DIR, gen_string('alpha'))
    ansible_module.file(
        path="{}".format(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(
                'ls -a {0}'.format(subdir))
    files_list = contacted.values()[0]['stdout_lines']
    expected_files = ONLINE_BACKUP_FILES

    # capsule-specific file list
    if ansible_host_pattern == 'capsule':
        expected_files = ONLINE_CAPS_FILES
    assert set(files_list).issuperset(
               expected_files + CONTENT_FILES), assert_msg
Exemple #30
0
def test_positive_restore_offline_backup(ansible_module):
    """Restore offline backup of server

    :id: 1005c983-13d4-451b-8115-8fce504104ee

    :setup:

        1. foreman-maintain should be installed.
        2. Take offline backup of server.
    :steps:
        1. Run foreman-maintain restore /backup_dir/

    :expectedresults: Restore successful.

    :CaseImportance: Critical
    """
    # preparing a target dir
    backup_dir = "offline_backup_restore"
    setup = ansible_module.command(f"rm -rf /tmp/{backup_dir}")
    assert setup.values()[0]["rc"] == 0
    setup = ansible_module.file(
        path=f"/tmp/{backup_dir}",
        state="directory",
        owner="postgres",
    )
    # saving backup to specified dir
    setup = ansible_module.command(
        Backup.run_offline_backup(
            ["-y", "--preserve-directory", f"/tmp/{backup_dir}"]))
    for result in setup.values():
        logger.info(result["stdout"])
        assert "FAIL" not in result["stdout"]
        assert result["rc"] == 0
    # restore from previously saved backup
    contacted = ansible_module.command(
        Restore._construct_command(["-y", f"/tmp/{backup_dir}"]))
    for result in contacted.values():
        logger.info(result)
        assert "FAIL" not in result["stdout"]
        assert result["rc"] == 0
Exemple #31
0
def test_positive_restore_offline_backup(ansible_module):
    """Restore offline backup of server

    :id: 1005c983-13d4-451b-8115-8fce504104ee

    :setup:

        1. foreman-maintain should be installed.
        2. Take offline backup of server.
    :steps:
        1. Run foreman-maintain restore /backup_dir/

    :expectedresults: Restore successful.

    :CaseImportance: Critical
    """
    # preparing a target dir
    backup_dir = 'offline_backup_restore'
    setup = ansible_module.command("rm -rf /tmp/{}".format(backup_dir))
    assert setup.values()[0]["rc"] == 0
    setup = ansible_module.file(
            path="/tmp/{}".format(backup_dir),
            state="directory",
            owner="postgres",
    )
    # saving backup to specified dir
    setup = ansible_module.command(Backup.run_offline_backup([
        '-y', '--preserve-directory', '/tmp/{}'.format(backup_dir)]))
    for result in setup.values():
        logger.info(result['stdout'])
        assert "FAIL" not in result['stdout']
        assert result['rc'] == 0
    # restore from previously saved backup
    contacted = ansible_module.command(Restore._construct_command(
        ['-y', '/tmp/{}'.format(backup_dir)]))
    for result in contacted.values():
        logger.info(result)
        assert "FAIL" not in result['stdout']
        assert result['rc'] == 0