Пример #1
0
def test_positive_service_disable(ansible_module):
    """Disable services using foreman-maintain service

    :id: e2c052e5-c2b6-4f0e-952b-3b0c22c66f22

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

    :steps:
        1. Run foreman-maintain service disable.

    :expectedresults: service should disable.

    :CaseImportance: Critical
    """
    try:
        contacted = ansible_module.command(Service.service_disable())
        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_enable())
        for result in teardown.values():
            assert result['rc'] == 0
Пример #2
0
def test_positive_service_disable(ansible_module):
    """Disable services using foreman-maintain service

    :id: e2c052e5-c2b6-4f0e-952b-3b0c22c66f22

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

    :steps:
        1. Run foreman-maintain service disable.

    :expectedresults: service should disable.

    :CaseImportance: Critical
    """
    try:
        contacted = ansible_module.command(Service.service_disable())
        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_enable())
        for result in teardown.values():
            assert result['rc'] == 0
Пример #3
0
def test_positive_automate_bz1626651(ansible_module):
    """Disable services using foreman-maintain service

    :id: dc60e388-f012-4164-a496-b12d6230cdc2

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

    :steps:
        1. Run foreman-maintain service stop.
        2. Run foreman-maintain service restart

    :expectedresults: service should restart.

    :CaseImportance: Critical
    """
    try:
        contacted = ansible_module.command(Service.service_stop())
        for result in contacted.values():
            logger.info(result['stdout'])
            assert "FAIL" not in result['stdout']
            assert result['rc'] == 0
        contacted = ansible_module.command(Service.service_restart())
        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
Пример #4
0
def test_positive_failed_service_status(ansible_module):
    """Verify foreman-maintain service status return error when service stopped

    :id: 74f6e276-1e54-4bf3-9538-19e87059f8b5

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

    :steps:
        1. Run foreman-maintain service stop.
        2. Run foreman-maintain service status.

    :expectedresults: service status should return error code.

    :CaseImportance: Critical
    """
    try:
        setup = ansible_module.command(Service.service_stop())
        for result in setup.values():
            logger.info(result['stdout'])
            assert result['rc'] == 0
        contacted = ansible_module.command(Service.service_status())
        for result in contacted.values():
            logger.info(result)
            assert result['rc'] != 0
    finally:
        teardown = ansible_module.command(Service.service_start())
        for result in teardown.values():
            assert result['rc'] == 0
Пример #5
0
def test_positive_foreman_maintain_service_list_sidekiq(ansible_module):
    """List sidekiq services with service list

    :id: 5acb68a9-c430-485d-bb45-b499adc90927

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

    :steps:
        1. Run foreman-maintain service list
        2. Run foreman-maintain service restart

    :expectedresults: Sidekiq-services should list and should restart.

    :CaseImportance: Medium
    """
    contacted = ansible_module.command(Service.service_list())
    for result in contacted.values():
        logger.info(result["stdout"])
        assert "FAIL" not in result["stdout"]
        assert result["rc"] == 0
        assert "[email protected]" in result["stdout"]

    contacted = ansible_module.command(Service.service_restart())
    for result in contacted.values():
        logger.info(result["stdout"])
        assert "FAIL" not in result["stdout"]
        assert result["rc"] == 0
        assert "dynflow-sidekiq@orchestrator" in result["stdout"]
        assert "dynflow-sidekiq@worker" in result["stdout"]
        assert "dynflow-sidekiq@worker-hosts-queue" in result["stdout"]
Пример #6
0
def test_positive_automate_bz1626651(ansible_module):
    """Disable services using foreman-maintain service

    :id: dc60e388-f012-4164-a496-b12d6230cdc2

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

    :steps:
        1. Run foreman-maintain service stop.
        2. Run foreman-maintain service restart

    :expectedresults: service should restart.

    :CaseImportance: Critical
    """
    try:
        contacted = ansible_module.command(Service.service_stop())
        for result in contacted.values():
            logger.info(result['stdout'])
            assert "FAIL" not in result['stdout']
            assert result['rc'] == 0
        contacted = ansible_module.command(Service.service_restart())
        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
Пример #7
0
def test_positive_failed_service_status(ansible_module):
    """Verify foreman-maintain service status return error when service stopped

    :id: 74f6e276-1e54-4bf3-9538-19e87059f8b5

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

    :steps:
        1. Run foreman-maintain service stop.
        2. Run foreman-maintain service status.

    :expectedresults: service status should return error code.

    :CaseImportance: Critical
    """
    try:
        setup = ansible_module.command(Service.service_stop())
        for result in setup.values():
            logger.info(result['stdout'])
            assert result['rc'] == 0
        contacted = ansible_module.command(Service.service_status())
        for result in contacted.values():
            logger.info(result)
            assert result['rc'] != 0
    finally:
        teardown = ansible_module.command(Service.service_start())
        for result in teardown.values():
            assert result['rc'] == 0
Пример #8
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
Пример #9
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
Пример #10
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
Пример #11
0
def test_positive_service_status_rpmsave(ansible_module, setup_rpmsave_file):
    """Verify foreman-maintain service status doesn't pick up any backup files like .rpmsave,
    or any file with .yml which don't exist as services.

    :id: dda696c9-7385-4450-8380-b694e4016661

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

    :steps:
        1. Run foreman-maintain service status.
        2. Verify foreman-maintain service status doesn't pick up any backup files like
           .rpmsave, or any file with .yml which don't exist as services.


    :expectedresults: foreman-maintain service status shouldn't pick
                      invalid services with extension .rpmsave

    :BZ: 1945916, 1962853

    :CaseImportance: High
    """
    contacted = ansible_module.command(Service.service_status(["-b"]))
    for result in contacted.values():
        logger.info(result["stdout"])
        assert "rpmsave" not in result["stdout"]
        assert "FAIL" not in result["stdout"]
        assert result["rc"] == 0
Пример #12
0
def test_positive_fm_service_restart_bz_1696862(setup_bz_1696862,
                                                ansible_module):
    """Restart services using service restart

    :id: c7518650-d72a-47b1-8d38-42b862f474fc

    :setup:
        1. foreman-maintain should be installed.
        2. Run setup_bz_1696862 from conftest.py

    :steps:
        1. Run foreman-maintain service restart

    :expectedresults: Katello-services should restart even
     if hammer credentials are not available.

    :BZ: 1632768

    :CaseImportance: Critical
    """
    contacted = ansible_module.command(Service.service_restart())
    for result in contacted.values():
        logger.info(result["stdout"])
        assert "FAIL" not in result["stdout"]
        assert result["rc"] == 0
Пример #13
0
def test_positive_automate_bz1624699(ansible_module):
    """Validate correct service restart on dynflowd stopped

    :id: 36f7ea87-12f3-4c12-817d-0031ce3ad241

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

    :steps:
        1. Stop dynflowd service
        2. Run foreman-maintain health check

    :expectedresults: service should restart correctly.

    :CaseImportance: Critical
    """
    setup = ansible_module.command(Service.service_stop({
        u'only': 'dynflowd'
    }))
    for result in setup.values():
        assert result['rc'] == 0
    contacted = ansible_module.command(Health.check(['-y']))
    for result in contacted.values():
        logger.info(result)
        assert result['rc'] == 0
Пример #14
0
def test_positive_automate_bz1624699(ansible_module):
    """Validate correct service restart on dynflowd stopped

    :id: 36f7ea87-12f3-4c12-817d-0031ce3ad241

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

    :steps:
        1. Stop dynflowd service
        2. Run foreman-maintain health check

    :expectedresults: service should restart correctly.

    :CaseImportance: Critical
    """
    setup = ansible_module.command(
        Service.service_stop({u"only": "smart_proxy_dynflow_core"}))
    for result in setup.values():
        assert result["rc"] == 0
        assert "FAIL" not in result["stdout"]
        assert "smart_proxy_dynflow_core" in result["stdout"]

    contacted = ansible_module.command(Health.check(["-y"]))
    for result in contacted.values():
        logger.info(result)
        assert result["rc"] == 0
Пример #15
0
def test_positive_foreman_service(ansible_module):
    """Validate httpd service should work as expected even stopping of the foreman service

    :id: 08a29ea2-2e49-11eb-a22b-d46d6dd3b5b2

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

    :steps:
        1. Stop foreman service
        2. Check the status for httpd should not have affect
        3. Run foreman-maintain health check

    :expectedresults: service should restart correctly.

    :CaseImportance: Critical
    """
    try:
        setup = ansible_module.command(
            Service.service_stop({u"only": "foreman"}))
        for result in setup.values():
            assert result["rc"] == 0
            assert "FAIL" not in result["stdout"]
            assert "foreman" in result["stdout"]

        httpd_service = ansible_module.command(
            Service.service_status({u"only": "httpd"}))
        for result in httpd_service.values():
            logger.info(result)
            assert result["rc"] == 0

        contacted = ansible_module.command(Health.check(["-y"]))
        for result in contacted.values():
            logger.info(result)
            assert result["rc"] == 0
            assert "foreman" in result["stdout"]

    finally:
        teardown = ansible_module.command(
            Service.service_start({u"only": "foreman"}))
        for result in teardown.values():
            assert result["rc"] == 0
Пример #16
0
def setup_backup_tests(request, ansible_module):
    """ Teardown for backup/restore tests."""
    setup = ansible_module.shell("rm -rf /tmp/backup-*; rm -rf /mnt/satellite-backup-*")
    assert setup.values()[0]["rc"] == 0
    ansible_module.command(Service.service_start())

    def teardown_backup_tests():
        teardown = ansible_module.shell("rm -rf /tmp/backup-*; rm -rf /mnt/satellite-backup-*")
        assert teardown.values()[0]["rc"] == 0
        ansible_module.command(Service.service_start())

    request.addfinalizer(teardown_backup_tests)
Пример #17
0
def test_positive_service_status_clocale(ansible_module):
    """Foreman-maintain service on C locale

    :id: 143dda54-5ab5-478a-b33e-af805bace2d7

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

    :steps:
        1. Run LC_ALL=C foreman-maintain service stop.

    :expectedresults: service status should display.

    :CaseImportance: Critical
    """
    contacted = ansible_module.shell("LC_ALL=C " + Service.service_status())
    for result in contacted.values():
        logger.info(result)
        assert result['rc'] == 0
Пример #18
0
def test_positive_service_status_clocale(ansible_module):
    """Foreman-maintain service on C locale

    :id: 143dda54-5ab5-478a-b33e-af805bace2d7

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

    :steps:
        1. Run LC_ALL=C foreman-maintain service stop.

    :expectedresults: service status should display.

    :CaseImportance: Critical
    """
    contacted = ansible_module.shell("LC_ALL=C " + Service.service_status())
    for result in contacted.values():
        logger.info(result)
        assert result['rc'] == 0
Пример #19
0
def test_positive_service_enable(ansible_module):
    """Enable services using foreman-maintain service

    :id: a0e0a052-0e21-465c-bb28-2e7613dbece6

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

    :steps:
        1. Run foreman-maintain service enable.

    :expectedresults: service should enable.

    :CaseImportance: Critical
    """
    contacted = ansible_module.command(Service.service_enable())
    for result in contacted.values():
        logger.info(result['stdout'])
        assert "FAIL" not in result['stdout']
        assert result['rc'] == 0
Пример #20
0
def test_positive_foreman_maintain_service_restart(ansible_module):
    """Restart services using service restart

    :id: c5a38994-8c14-40c7-bc6a-1cfc68fc2d28

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

    :steps:
        1. Run foreman-maintain service restart

    :expectedresults: Katello-services should restart.

    :CaseImportance: Critical
    """
    contacted = ansible_module.command(Service.service_restart())
    for result in contacted.values():
        logger.info(result['stdout'])
        assert "FAIL" not in result['stdout']
        assert result['rc'] == 0
Пример #21
0
def test_positive_foreman_maintain_service_start(ansible_module):
    """Start services using service start

    :id: fa3b02a9-b441-413b-b9d2-1a59d04f285c

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

    :steps:
        1. Run foreman-maintain service start

    :expectedresults: Katello-services should start.

    :CaseImportance: Critical
    """
    contacted = ansible_module.command(Service.service_start())
    for result in contacted.values():
        logger.info(result['stdout'])
        assert "FAIL" not in result['stdout']
        assert result['rc'] == 0
Пример #22
0
def test_positive_foreman_maintain_service_start(ansible_module):
    """Start services using service start

    :id: fa3b02a9-b441-413b-b9d2-1a59d04f285c

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

    :steps:
        1. Run foreman-maintain service start

    :expectedresults: Katello-services should start.

    :CaseImportance: Critical
    """
    contacted = ansible_module.command(Service.service_start())
    for result in contacted.values():
        logger.info(result['stdout'])
        assert "FAIL" not in result['stdout']
        assert result['rc'] == 0
Пример #23
0
def test_positive_foreman_maintain_service_restart(ansible_module):
    """Restart services using service restart

    :id: c5a38994-8c14-40c7-bc6a-1cfc68fc2d28

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

    :steps:
        1. Run foreman-maintain service restart

    :expectedresults: Katello-services should restart.

    :CaseImportance: Critical
    """
    contacted = ansible_module.command(Service.service_restart())
    for result in contacted.values():
        logger.info(result['stdout'])
        assert "FAIL" not in result['stdout']
        assert result['rc'] == 0
Пример #24
0
def test_positive_service_enable(ansible_module):
    """Enable services using foreman-maintain service

    :id: a0e0a052-0e21-465c-bb28-2e7613dbece6

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

    :steps:
        1. Run foreman-maintain service enable.

    :expectedresults: service should enable.

    :CaseImportance: Critical
    """
    contacted = ansible_module.command(Service.service_enable())
    for result in contacted.values():
        logger.info(result['stdout'])
        assert "FAIL" not in result['stdout']
        assert result['rc'] == 0
Пример #25
0
def test_positive_automate_bz1624699(ansible_module):
    """Validate correct service restart on dynflowd stopped

    :id: 36f7ea87-12f3-4c12-817d-0031ce3ad241

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

    :steps:
        1. Stop dynflowd service
        2. Run foreman-maintain health check

    :expectedresults: service should restart correctly.

    :CaseImportance: Critical
    """
    setup = ansible_module.command(Service.service_stop({u'only': 'dynflowd'}))
    for result in setup.values():
        assert result['rc'] == 0
    contacted = ansible_module.command(Health.check(['-y']))
    for result in contacted.values():
        logger.info(result)
        assert result['rc'] == 0
Пример #26
0
 def teardown_backup_tests():
     teardown = ansible_module.shell("rm -rf /tmp/backup-*; rm -rf /mnt/satellite-backup-*")
     assert teardown.values()[0]["rc"] == 0
     ansible_module.command(Service.service_start())