示例#1
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
示例#2
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
示例#3
0
def test_positive_backup_offline_skip_pulp_content(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 = "{0}backup-{1}".format(BACKUP_DIR, 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('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), assert_msg
    assert CONTENT_FILES not in files_list, "content not skipped"
示例#4
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"
示例#5
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
示例#6
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
示例#7
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
示例#8
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
示例#9
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
示例#10
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
示例#11
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
示例#12
0
def test_positive_backup_offline(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 = "{0}backup-{1}".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 {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
示例#13
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
示例#14
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
示例#15
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
示例#16
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
示例#17
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
示例#18
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
示例#19
0
def test_negative_backup_offline_nodir(ansible_module):
    """Take offline backup of server with no destination

    :id: 9377ebc6-663b-47d4-92e2-744398dba376

    :setup:

        1. foreman-maintain should be installed.
    :steps:
        1. Run foreman-maintain backup offline without providing
        directory

    :expectedresults: backup aborted, relevant message is
        returned

    :CaseImportance: Critical
    """
    contacted = ansible_module.command(Backup.run_offline_backup(["-y"]))
    for result in contacted.values():
        logger.info(result["stderr"])
        assert result["rc"] == 1
        assert NODIR_MSG in result["stderr"]
示例#20
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