def test_positive_foreman_maintain_hammer_setup(change_admin_passwd, ansible_module): """Hammer setup using advanced procedure :id: 236171c0-5185-465e-9eec-e15dfefb41c3 :setup: 1. foreman-maintain should be installed. :steps: 1. Change password for user to any string 2. Run advanced procedure run hammer-setup with wrong_password. 3. Verify wrong_password isn't updated in fm_hammer_yml 4. Run advanced procedure run hammer-setup with changed password. 5. Verify changed password is updated in fm_hammer_yml 6. Update admin password back to default 7. Verify default password is updated in fm_hammer_yml :expectedresults: 1. Run hammer setup with wrong password, it should fail and password shouldn't be updated in fm_hammer_yml 2. Run hammer setup with changed password, it should pass and password should be updated in fm_hammer_yml :CaseImportance: Critical :BZ: 1830355 """ # try with incorrect password output = ansible_module.expect( command=Advanced.run_hammer_setup(), responses={"Hammer admin password: "******"wrong_password"}, ) for result in output.values(): logger.info(result) assert "Incorrect credential for admin user" in result["stdout"] assert result["rc"] == 1 # Verify wrong_password isn't updated in fm_hammer_yml output = ansible_module.command( f"grep -i ':password: wrong_password' {fm_hammer_yml}") for result in output.values(): assert result["rc"] != 0 assert "wrong_password" not in result["stdout"] # try with correct password output = ansible_module.expect( command=Advanced.run_hammer_setup(), responses={"Hammer admin password: "******"admin"}, ) for result in output.values(): logger.info(result) assert result["rc"] == 0 # Verify new password updated in fm_hammer_yml output = ansible_module.command( f"grep -i ':password: admin' {fm_hammer_yml}") for result in output.values(): assert result["rc"] == 0 assert "admin" in result["stdout"]
def test_positive_foreman_maintain_enable_maintenance_mode(ansible_module): """Enable maintenance mode using advanced procedure run :id: a37c78da-430d-48be-b94a-c25699bddb02 :setup: 1. foreman-maintain should be installed. :steps: 1. Run foreman-maintain advanced procedure run maintenance-mode-enable :expectedresults: iptables rules should add. :CaseImportance: Critical """ contacted = ansible_module.command(Advanced.run_enable_maintenance_mode()) for result in contacted.values(): logger.info(result['stdout']) assert "FAIL" not in result['stdout'] check_iptables = ansible_module.command("iptables -L") for rules in check_iptables.values(): logger.info(rules['stdout']) assert "FOREMAN_MAINTAIN" in rules['stdout'] teardown = ansible_module.command(Advanced.run_disable_maintenance_mode()) for result in teardown.values(): logger.info(result['stdout']) assert "FAIL" not in result['stdout']
def test_positive_sync_plan_with_hammer_defaults(setup_for_hammer_defaults, ansible_module): """Verify that sync plan is disabled and enabled with hammer defaults set. :id: b25734c8-470f-4cad-bc56-5c0f75aa7499 :setup: 1. foreman-maintain should be installed. :steps: 1. Setup hammer on system with defaults set 2. Run foreman-maintain advanced procedure run sync-plans-enable :expectedresults: sync plans should get disabled and enabled. :CaseImportance: Critical """ contacted = ansible_module.command(Advanced.run_sync_plans_disable()) for result in contacted.values(): logger.info(result["stdout"]) assert "FAIL" not in result["stdout"] assert result["rc"] == 0 contacted = ansible_module.command(Advanced.run_sync_plans_enable()) for result in contacted.values(): logger.info(result["stdout"]) assert "FAIL" not in result["stdout"] assert result["rc"] == 0
def test_negative_check_hammer_ping(ansible_module): """Verify hammer ping check :id: ecdc5bfb-2adf-49f6-948d-995dae34bcd3 :setup: 1. foreman-maintain should be installed. :steps: 1. Run Katello-service stop 2. Run foreman-maintain health check --label hammer-ping 3. Run Katello-service start :expectedresults: Health check should perform. :CaseImportance: Critical """ setup = ansible_module.command(Advanced.run_katello_service_stop()) for result in setup.values(): assert result['rc'] == 0 contacted = ansible_module.command(Health.check({ 'label': 'hammer-ping' })) for result in contacted.values(): logger.info(result['stdout']) assert "FAIL" in result['stdout'] teardown = ansible_module.command(Advanced.run_service_start()) for result in teardown.values(): logger.info(result['stdout'])
def test_positive_repositories_setup(setup_subscribe_to_cdn_dogfood, ansible_module): """Verify that all required repositories gets enabled. :id: e32fee2d-2a1f-40ed-9f94-515f75511c5a :setup: 1. foreman-maintain should be installed. :steps: 1. Run 'foreman-maintain advanced procedure run repositories-setup --version 6.y :BZ: 1684730 :expectedresults: Required repositories should get enabled :CaseImportance: Critical """ for ver in ["6.3", "6.4", "6.5", "6.6", "6.7"]: contacted = ansible_module.command(Advanced.run_repositories_setup({"version": ver})) 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_repos[ver]: assert repo in result["stdout"] # For 6.8 repository setup check. Remove this once 6.8 is GA. contacted = ansible_module.command(Advanced.run_repositories_setup({"version": "6.8"})) for result in contacted.values(): logger.info(result["stdout"]) assert "FAIL" in result["stdout"] for repo in sat_repos["6.8"]: assert repo in result["stdout"]
def test_positive_foreman_maintain_disable_maintenance_mode(ansible_module): """Disable maintenance mode using advanced procedure run :id: 3a58ce93-631e-42b6-9b41-1cb620f351e6 :setup: 1. foreman-maintain should be installed. 2. maintenance mode should be enabled. :steps: 1. Run foreman-maintain advanced procedure run maintenance-mode-disable :expectedresults: iptables rules should remove. :CaseImportance: Critical """ setup = ansible_module.command(Advanced.run_enable_maintenance_mode()) for result in setup.values(): logger.info(result['stdout']) assert "FAIL" not in result['stdout'] contacted = ansible_module.command(Advanced.run_disable_maintenance_mode()) for result in contacted.values(): logger.info(result['stdout']) assert "FAIL" not in result['stdout'] check_iptables = ansible_module.command("iptables -L") for rules in check_iptables.values(): logger.info(rules['stdout']) assert "FOREMAN_MAINTAIN" not in rules['stdout']
def test_positive_foreman_maintain_enable_maintenance_mode(ansible_module): """Enable maintenance mode using advanced procedure run :id: a37c78da-430d-48be-b94a-c25699bddb02 :setup: 1. foreman-maintain should be installed. :steps: 1. Run foreman-maintain advanced procedure run maintenance-mode-enable :expectedresults: iptables rules should add. :CaseImportance: Critical """ contacted = ansible_module.command(Advanced.run_enable_maintenance_mode()) for result in contacted.values(): logger.info(result['stdout']) assert "FAIL" not in result['stdout'] check_iptables = ansible_module.command("iptables -L") for rules in check_iptables.values(): logger.info(rules['stdout']) assert "FOREMAN_MAINTAIN" in rules['stdout'] teardown = ansible_module.command(Advanced.run_disable_maintenance_mode()) for result in teardown.values(): logger.info(result['stdout']) assert "FAIL" not in result['stdout']
def test_positive_foreman_maintain_disable_maintenance_mode(ansible_module): """Disable maintenance mode using advanced procedure run :id: 3a58ce93-631e-42b6-9b41-1cb620f351e6 :setup: 1. foreman-maintain should be installed. 2. maintenance mode should be enabled. :steps: 1. Run foreman-maintain advanced procedure run maintenance-mode-disable :expectedresults: iptables rules should remove. :CaseImportance: Critical """ setup = ansible_module.command(Advanced.run_enable_maintenance_mode()) for result in setup.values(): logger.info(result['stdout']) assert "FAIL" not in result['stdout'] contacted = ansible_module.command(Advanced.run_disable_maintenance_mode()) for result in contacted.values(): logger.info(result['stdout']) assert "FAIL" not in result['stdout'] check_iptables = ansible_module.command("iptables -L") for rules in check_iptables.values(): logger.info(rules['stdout']) assert "FOREMAN_MAINTAIN" not in rules['stdout']
def test_positive_sync_plan_with_hammer_defaults(setup_for_hammer_defaults, ansible_module): """Verify that sync plan is disabled and enabled with hammer defaults set. :id: b25734c8-470f-4cad-bc56-5c0f75aa7499 :setup: 1. foreman-maintain should be installed. :steps: 1. Setup hammer on system with defaults set 2. Run foreman-maintain advanced procedure run sync-plans-enable :expectedresults: sync plans should get disabled and enabled. :CaseImportance: Critical """ contacted = ansible_module.command(Advanced.run_sync_plans_disable()) for result in contacted.values(): logger.info(result['stdout']) assert "FAIL" not in result['stdout'] assert result['rc'] == 0 contacted = ansible_module.command(Advanced.run_sync_plans_enable()) for result in contacted.values(): logger.info(result['stdout']) assert "FAIL" not in result['stdout'] assert result['rc'] == 0
def test_positive_satellite_repositories_setup(setup_subscribe_to_cdn_dogfood, ansible_module): """Verify that all required repositories gets enabled. :id: e32fee2d-2a1f-40ed-9f94-515f75511c5a :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 Satellite repositories should get enabled :CaseImportance: Critical """ for ver in ["6.7", "6.8", "6.9", "6.10"]: contacted = ansible_module.command( Advanced.run_repositories_setup({"version": ver})) 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_repos[ver]: assert repo in result["stdout"] # Verify that all required beta repositories gets enabled export_command = "export FOREMAN_MAINTAIN_USE_BETA=1;" contacted = ansible_module.shell( export_command + Advanced.run_repositories_setup({"version": "6.10"})) 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"] # 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"]
def test_positive_beta_repositories(setup_subscribe_to_cdn_dogfood, ansible_module): """Verify that all required beta repositories gets enabled. :id: 2d544863-ebd1-4a60-b189-395b5cd82104 :setup: 1. foreman-maintain should be installed. :steps: 1. Run 'foreman-maintain advanced procedure run repositories-setup --version 6.y :BZ: 1684730 :expectedresults: Required beta repositories should get enabled :CaseImportance: Critical """ 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(): for repo in sat_beta_repo: assert repo in result["stdout"]
def test_positive_repositories_setup(setup_subscribe_to_cdn_dogfood, ansible_module): """Verify that all required repositories gets enabled. :id: e32fee2d-2a1f-40ed-9f94-515f75511c5a :setup: 1. foreman-maintain should be installed. :steps: 1. Run 'foreman-maintain advanced procedure run repositories-setup --version 6.y :BZ: 1684730 :expectedresults: Required repositories should get enabled :CaseImportance: Critical """ for ver in ['6.3', '6.4', '6.5']: contacted = ansible_module.command( Advanced.run_repositories_setup({'version': ver})) 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']) if ver == '6.3': for repo in sat_63_repo: assert repo in result['stdout'] if ver == '6.4': for repo in sat_64_repo: assert repo in result['stdout'] if ver == '6.5': for repo in sat_65_repo: assert repo in result['stdout']
def test_positive_repositories_setup(setup_subscribe_to_cdn_dogfood, ansible_module): """Verify that all required repositories gets enabled. :id: e32fee2d-2a1f-40ed-9f94-515f75511c5a :setup: 1. foreman-maintain should be installed. :steps: 1. Run 'foreman-maintain advanced procedure run repositories-setup --version 6.y :BZ: 1684730 :expectedresults: Required repositories should get enabled :CaseImportance: Critical """ for ver in ['6.3', '6.4', '6.5']: contacted = ansible_module.command(Advanced.run_repositories_setup({ 'version': ver })) 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']) if ver == '6.3': for repo in sat_63_repo: assert repo in result['stdout'] if ver == '6.4': for repo in sat_64_repo: assert repo in result['stdout'] if ver == '6.5': for repo in sat_65_repo: assert repo in result['stdout']
def test_positive_foreman_tasks_ui_investigate(ansible_module): """Run foreman-tasks-ui-investigate using advanced procedure run :id: 3b4f69c6-c0a1-42e3-a099-8a6e26280d17 :setup: 1. foreman-maintain should be installed. :steps: 1. Run foreman-maintain advanced procedure run foreman-tasks-ui-investigate :expectedresults: procedure foreman-tasks-ui-investigate should work. :CaseImportance: Critical """ setup = ansible_module.command("pip install pexpect") for result in setup.values(): assert result["rc"] == 0 output = ansible_module.expect( command=Advanced.run_foreman_tasks_ui_investigate(), responses={"press ENTER after the tasks are resolved.": " "}) for result in output.values(): logger.info(result) assert "OK" in result["stdout"]
def test_positive_sync_plan_disable_enable(setup_sync_plan, ansible_module): """Run sync-plans-enable and sync-plans-disable using advanced procedure run. :id: 865df1e1-1189-437c-8451-22d772ff97d4 :setup: 1. foreman-maintain should be installed. :steps: 1. Run foreman-maintain advanced procedure run sync-plans-disable 2. Run foreman-maintain advanced procedure run sync-plans-enable :expectedresults: procedure sync-plans-enable should work. :CaseImportance: Critical """ sync_ids, sat_hostname = setup_sync_plan() contacted = ansible_module.command(Advanced.run_sync_plans_disable()) for result in contacted.values(): logger.info(result["stdout"]) assert result["rc"] == 0 assert "FAIL" not in result["stdout"] ansible_module.fetch(src="/var/lib/foreman-maintain/data.yml", dest="./") with open("./{}/var/lib/foreman-maintain/data.yml".format( sat_hostname)) as f: data_yml = yaml.safe_load(f) assert len(sync_ids) == len( data_yml[":default"][":sync_plans"][":disabled"]) assert sorted(sync_ids) == sorted( data_yml[":default"][":sync_plans"][":disabled"]) contacted = ansible_module.command(Advanced.run_sync_plans_enable()) for result in contacted.values(): logger.info(result["stdout"]) assert result["rc"] == 0 assert "FAIL" not in result["stdout"] ansible_module.fetch(src="/var/lib/foreman-maintain/data.yml", dest="./") with open("./{}/var/lib/foreman-maintain/data.yml".format( sat_hostname)) as f: data_yml = yaml.safe_load(f) assert len(sync_ids) == len( data_yml[":default"][":sync_plans"][":enabled"]) assert sorted(sync_ids) == sorted( data_yml[":default"][":sync_plans"][":enabled"])
def test_positive_sync_plan_disable_enable(setup_sync_plan, ansible_module): """Run sync-plans-enable and sync-plans-disable using advanced procedure run. :id: 865df1e1-1189-437c-8451-22d772ff97d4 :setup: 1. foreman-maintain should be installed. :steps: 1. Run foreman-maintain advanced procedure run sync-plans-disable 2. Run foreman-maintain advanced procedure run sync-plans-enable :expectedresults: procedure sync-plans-enable should work. :CaseImportance: Critical """ sat_hostname = '' for facts in ansible_module.setup().items(): sat_hostname = facts[0] contacted = ansible_module.command(Advanced.run_sync_plans_disable()) for result in contacted.values(): logger.info(result['stdout']) assert result["rc"] == 0 assert "FAIL" not in result['stdout'] ansible_module.fetch( src="/var/lib/foreman-maintain/data.yml", dest="./" ) with open('./{0}/var/lib/foreman-maintain/data.yml'.format(sat_hostname)) as f: data_yml = yaml.safe_load(f) assert setup_sync_plan in data_yml[':default'][':sync_plans'][':disabled'] contacted = ansible_module.command(Advanced.run_sync_plans_enable()) for result in contacted.values(): logger.info(result['stdout']) assert result["rc"] == 0 assert "FAIL" not in result['stdout'] ansible_module.fetch( src="/var/lib/foreman-maintain/data.yml", dest="./" ) with open('./{0}/var/lib/foreman-maintain/data.yml'.format(sat_hostname)) as f: data_yml = yaml.safe_load(f) assert setup_sync_plan in data_yml[':default'][':sync_plans'][':enabled']
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 :CaseImportance: Critical """ contacted = ansible_module.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 cap_repos["6.8"]: assert repo in result["stdout"] # Verify that all required beta repositories gets enabled 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 cap_beta_repo: assert repo in result["stdout"]
def setup_katello_service_stop(request, ansible_module): """This fixture is used to stop/start katello services. It is used by test test_negative_check_server_ping of test_health.py. """ setup = ansible_module.command(Advanced.run_katello_service_stop()) for result in setup.values(): assert result["rc"] == 0 def teardown_katello_service_start(): teardown = ansible_module.command(Advanced.run_service_start()) for result in teardown.values(): logger.info(result["stdout"]) assert result["rc"] == 0 request.addfinalizer(teardown_katello_service_start)
def default_admin_passwd(): teardown = ansible_module.command( "hammer -u admin -p admin user update --login admin --password 'changeme'" ) for result in teardown.values(): logger.info(result) assert result["rc"] == 0 # Make default admin creds available in fm_hammer_yml output = ansible_module.command(Advanced.run_hammer_setup()) for result in output.values(): logger.info(result) assert result["rc"] == 0 # Make sure default password available in fm_hammer_yml output = ansible_module.command( f"grep -i ':password: changeme' {fm_hammer_yml}") for result in output.values(): assert result["rc"] == 0 assert "changeme" in result["stdout"]
def teardown_subscribe_to_cdn_dogfood(): if subscribed_to_cdn is False: ansible_module.command("subscription-manager unregister") ansible_module.command("subscription-manager clean") ansible_module.command( "yum -y localinstall {}".format(katello_ca_consumer)) ansible_module.command( 'subscription-manager register --force --org="{}" --activationkey="{}"' .format(DOGFOOD_ORG, DOGFOOD_ACTIVATIONKEY)) else: contacted = ansible_module.command( Advanced.run_repositories_setup({"version": product() }) # Satellite minor version ) for result in contacted.values(): logger.info(result["stdout"]) assert "FAIL" not in result["stdout"] assert result["rc"] == 0
def test_positive_foreman_maintain_hammer_setup(setup_install_pexpect, ansible_module): """Hammer setup using advanced procedure :id: 236171c0-5185-465e-9eec-e15dfefb41c3 :setup: 1. foreman-maintain should be installed. :steps: 1. Change password for user to any string 2. Run advanced procedure run hammer-setup 3. Change password to original password :expectedresults: Hammer setup should successful. :CaseImportance: Critical """ try: setup = ansible_module.command( "hammer -u admin -p changeme" " user update" " --login admin " "--password 'JMNBzJ*a-4;XH!C~'" ) for result in setup.values(): logger.info(result) assert result["rc"] == 0 output = ansible_module.expect( command=Advanced.run_hammer_setup(), responses={"Hammer admin password: "******"JMNBzJ*a-4;XH!C~"}, ) for result in output.values(): logger.info(result) assert result["rc"] == 0 finally: teardown = ansible_module.command( "hammer -u admin " "-p 'JMNBzJ*a-4;XH!C~'" " user update --login admin" " --password 'changeme'" ) for result in teardown.values(): logger.info(result) assert result["rc"] == 0
def test_positive_foreman_maintain_service_restart(ansible_module): """Restart service using advanced procedure run :id: 64d3c78e-d602-43d6-bf77-f31135ed019e :setup: 1. foreman-maintain should be installed. :steps: 1. Run foreman-maintain advanced procedure run service-restart :expectedresults: Katello-service should restart. :CaseImportance: Critical """ contacted = ansible_module.command(Advanced.run_service_restart()) for result in contacted.values(): logger.info(result['stdout']) assert "FAIL" not in result['stdout']
def test_positive_foreman_maintain_service_restart(ansible_module): """Restart service using advanced procedure run :id: 64d3c78e-d602-43d6-bf77-f31135ed019e :setup: 1. foreman-maintain should be installed. :steps: 1. Run foreman-maintain advanced procedure run service-restart :expectedresults: Katello-service should restart. :CaseImportance: Critical """ contacted = ansible_module.command(Advanced.run_service_restart()) for result in contacted.values(): logger.info(result["stdout"]) assert "FAIL" not in result["stdout"]
def test_positive_foreman_maintain_packages_update(ansible_module): """Packages update using advanced procedure run :id: d56523d7-7042-40e1-a96e-db8f33b960e5 :setup: 1. foreman-maintain should be installed. :steps: 1. Run foreman-maintain advanced procedure run packages-update :expectedresults: packages should update. :CaseImportance: Critical """ contacted = ansible_module.command(Advanced.run_packages_update()) for result in contacted.values(): logger.info(result["stdout"]) assert "FAIL" not in result["stdout"]
def test_positive_foreman_maintain_packages_update(ansible_module): """Packages update using advanced procedure run :id: d56523d7-7042-40e1-a96e-db8f33b960e5 :setup: 1. foreman-maintain should be installed. :steps: 1. Run foreman-maintain advanced procedure run packages-update :expectedresults: packages should update. :CaseImportance: Critical """ contacted = ansible_module.command(Advanced.run_packages_update()) for result in contacted.values(): logger.info(result['stdout']) assert "FAIL" not in result['stdout']
def advanced_procedure_run_service_restart(): """ Usage: foreman-maintain advanced procedure run katello-service-restart [OPTIONS] Options: --only ONLY A comma-separated list of services to include (comma-separated list) --exclude EXCLUDE A comma-separated list of services to skip (comma-separated list) -y, --assumeyes Automatically answer yes for all questions -w, --whitelist whitelist Comma-separated list of labels of steps to be ignored -f, --force Force steps that would be skipped as they were already run -h, --help print help """ return Advanced.run_katello_service_restart()
def test_positive_foreman_taks_delete_planning(ansible_module): """Delete planning foreman-tasks using advanced procedure run :id: 447f5b05-b6a2-4f3a-8e89-8281995ca1cf :setup: 1. foreman-maintain should be installed. :steps: 1. Run foreman-maintain advanced procedure run foreman-tasks-delete --state planning :expectedresults: foreman tasks in planning state should delete. :CaseImportance: Critical """ contacted = ansible_module.command(Advanced.run_foreman_tasks_delete({"state": "planning"})) for result in contacted.values(): logger.info(result["stdout"]) assert "FAIL" not in result["stdout"]
def test_positive_foreman_taks_delete_old(ansible_module): """Delete old foreman-tasks using advanced procedure run :id: c5deaf67-8fa9-43a6-bf62-1c0d6be63a85 :setup: 1. foreman-maintain should be installed. :steps: 1. Run foreman-maintain advanced procedure run foreman-tasks-delete --state old :expectedresults: Old foreman tasks should delete. :CaseImportance: Critical """ contacted = ansible_module.command(Advanced.run_foreman_tasks_delete({"state": "old"})) for result in contacted.values(): logger.info(result["stdout"]) assert "FAIL" not in result["stdout"]
def test_positive_sync_plan_disable(ansible_module): """Run sync-plans-disable using advanced procedure run :id: 8690d875-6784-41f3-92cc-06e2bc8b5dc0 :setup: 1. foreman-maintain should be installed. :steps: 1. Run foreman-maintain advanced procedure run sync-plans-disable :expectedresults: procedure sync-plans-disable should work. :CaseImportance: Critical """ contacted = ansible_module.command(Advanced.run_sync_plans_disable()) for result in contacted.values(): logger.info(result['stdout']) assert "FAIL" not in result['stdout']
def test_positive_sync_plan_enable(ansible_module): """Run sync-plans-enable using advanced procedure run :id: 865df1e1-1189-437c-8451-22d772ff97d4 :setup: 1. foreman-maintain should be installed. :steps: 1. Run foreman-maintain advanced procedure run sync-plans-enable :expectedresults: procedure sync-plans-enable should work. :CaseImportance: Critical """ contacted = ansible_module.command(Advanced.run_sync_plans_enable()) for result in contacted.values(): logger.info(result['stdout']) assert "FAIL" not in result['stdout']
def advanced_procedure_run_service_restart(): """ Usage: foreman-maintain advanced procedure run katello-service-restart [OPTIONS] Options: --only ONLY A comma-separated list of services to include (comma-separated list) --exclude EXCLUDE A comma-separated list of services to skip (comma-separated list) -y, --assumeyes Automatically answer yes for all questions -w, --whitelist whitelist Comma-separated list of labels of steps to be ignored -f, --force Force steps that would be skipped as they were already run -h, --help print help """ return Advanced.run_katello_service_restart()
def test_positive_foreman_task_resume(ansible_module): """Resume paused foreman-tasks using advanced procedure run :id: e9afe55b-e3a4-425a-8bfd-a8df6674e516 :setup: 1. foreman-maintain should be installed. :steps: 1. Run foreman-maintain advanced procedure run foreman-tasks-resume :expectedresults: foreman tasks in paused state should resume. :CaseImportance: Critical """ contacted = ansible_module.command(Advanced.run_foreman_tasks_resume()) for result in contacted.values(): logger.info(result['stdout']) assert "FAIL" not in result['stdout']
def test_positive_foreman_task_resume(ansible_module): """Resume paused foreman-tasks using advanced procedure run :id: e9afe55b-e3a4-425a-8bfd-a8df6674e516 :setup: 1. foreman-maintain should be installed. :steps: 1. Run foreman-maintain advanced procedure run foreman-tasks-resume :expectedresults: foreman tasks in paused state should resume. :CaseImportance: Critical """ contacted = ansible_module.command(Advanced.run_foreman_tasks_resume()) for result in contacted.values(): logger.info(result["stdout"]) assert "FAIL" not in result["stdout"]
def test_positive_foreman_taks_delete_pending(ansible_module): """Delete pending foreman-tasks using advanced procedure run :id: 6bd3af66-9910-48c4-8cbb-69c3ddd18d6c :setup: 1. foreman-maintain should be installed. :steps: 1. Run foreman-maintain advanced procedure run foreman-tasks-delete --state pending :expectedresults: foreman tasks in pending state should delete. :CaseImportance: Critical """ contacted = ansible_module.command(Advanced.run_foreman_tasks_delete({"state": "pending"})) for result in contacted.values(): logger.info(result["stdout"]) assert "FAIL" not in result["stdout"]
def test_positive_foreman_maintain_hammer_setup(setup_install_pexpect, ansible_module): """Hammer setup using advanced procedure :id: 236171c0-5185-465e-9eec-e15dfefb41c3 :setup: 1. foreman-maintain should be installed. :steps: 1. Change password for user to any string 2. Run advanced procedure run hammer-setup 3. Change password to original password :expectedresults: Hammer setup should successful. :CaseImportance: Critical """ try: setup = ansible_module.command("hammer -u admin -p changeme" " user update" " --login admin " "--password 'JMNBzJ*a-4;XH!C~'") for result in setup.values(): logger.info(result) assert result["rc"] == 0 output = ansible_module.expect( command=Advanced.run_hammer_setup(), responses={"Hammer admin password: "******"JMNBzJ*a-4;XH!C~"} ) for result in output.values(): logger.info(result) assert result["rc"] == 0 finally: teardown = ansible_module.command("hammer -u admin " "-p 'JMNBzJ*a-4;XH!C~'" " user update --login admin" " --password 'changeme'") for result in teardown.values(): logger.info(result) assert result["rc"] == 0
def test_positive_foreman_taks_delete_pending(ansible_module): """Delete pending foreman-tasks using advanced procedure run :id: 6bd3af66-9910-48c4-8cbb-69c3ddd18d6c :setup: 1. foreman-maintain should be installed. :steps: 1. Run foreman-maintain advanced procedure run foreman-tasks-delete --state pending :expectedresults: foreman tasks in pending state should delete. :CaseImportance: Critical """ contacted = ansible_module.command(Advanced.run_foreman_tasks_delete({ u'state': 'pending' })) for result in contacted.values(): logger.info(result['stdout']) assert "FAIL" not in result['stdout']
def test_positive_foreman_taks_delete_planning(ansible_module): """Delete planning foreman-tasks using advanced procedure run :id: 447f5b05-b6a2-4f3a-8e89-8281995ca1cf :setup: 1. foreman-maintain should be installed. :steps: 1. Run foreman-maintain advanced procedure run foreman-tasks-delete --state planning :expectedresults: foreman tasks in planning state should delete. :CaseImportance: Critical """ contacted = ansible_module.command(Advanced.run_foreman_tasks_delete({ u'state': 'planning' })) for result in contacted.values(): logger.info(result['stdout']) assert "FAIL" not in result['stdout']
def test_positive_foreman_taks_delete_old(ansible_module): """Delete old foreman-tasks using advanced procedure run :id: c5deaf67-8fa9-43a6-bf62-1c0d6be63a85 :setup: 1. foreman-maintain should be installed. :steps: 1. Run foreman-maintain advanced procedure run foreman-tasks-delete --state old :expectedresults: Old foreman tasks should delete. :CaseImportance: Critical """ contacted = ansible_module.command(Advanced.run_foreman_tasks_delete({ u'state': 'old' })) for result in contacted.values(): logger.info(result['stdout']) assert "FAIL" not in result['stdout']
def test_positive_foreman_maintain_hammer_setup(ansible_module): """Hammer setup using advanced procedure :id: 236171c0-5185-465e-9eec-e15dfefb41c3 :setup: 1. foreman-maintain should be installed. :steps: 1. Change password for user to any string 2. Run advanced procedure run hammer-setup 3. Change password to original password :expectedresults: Hammer setup should successful. :CaseImportance: Critical """ try: setup = ansible_module.command("hammer -u admin -p changeme" " user update" " --login admin " "--password 'JMNBzJ*a-4;XH!C~'") for result in setup.values(): logger.info(result) assert result["rc"] == 0 output = ansible_module.command(Advanced.run_hammer_setup()) for result in output.values(): logger.info(result) assert "New settings saved into /root/foreman_maintain/config/" \ "foreman-maintain-hammer.yml" in result["stdout_lines"] finally: teardown = ansible_module.command("hammer -u admin " "-p 'JMNBzJ*a-4;XH!C~'" " user update --login admin" " --password 'changeme'") for result in teardown.values(): logger.info(result) assert result["rc"] == 0
def test_positive_foreman_tasks_ui_investigate(setup_install_pexpect, ansible_module): """Run foreman-tasks-ui-investigate using advanced procedure run :id: 3b4f69c6-c0a1-42e3-a099-8a6e26280d17 :setup: 1. foreman-maintain should be installed. :steps: 1. Run foreman-maintain advanced procedure run foreman-tasks-ui-investigate :expectedresults: procedure foreman-tasks-ui-investigate should work. :CaseImportance: Critical """ output = ansible_module.expect( command=Advanced.run_foreman_tasks_ui_investigate(), responses={"press ENTER after the tasks are resolved.": " "} ) for result in output.values(): logger.info(result) assert result["rc"] == 0
def teardown_katello_service_start(): teardown = ansible_module.command(Advanced.run_service_start()) for result in teardown.values(): logger.info(result["stdout"]) assert result["rc"] == 0