From bb58fc1f7166f13a6067c6115c27689e55123f06 Mon Sep 17 00:00:00 2001 From: amol patil Date: Tue, 13 Aug 2024 00:06:09 +0530 Subject: [PATCH] check debug log for expected host --- tests/foreman/ui/test_ansible.py | 47 +++++++++++++++++++------------- 1 file changed, 28 insertions(+), 19 deletions(-) diff --git a/tests/foreman/ui/test_ansible.py b/tests/foreman/ui/test_ansible.py index 67feb3c3d7f..1c31719b1b0 100644 --- a/tests/foreman/ui/test_ansible.py +++ b/tests/foreman/ui/test_ansible.py @@ -603,11 +603,10 @@ def test_positive_ansible_config_report_changes_notice_and_failed_tasks_errors( notice_log = session.configreport.search(rhel_contenthost.hostname) assert f'notice Install the {package_name} package' in notice_log['permission_denied'] assert f'Installed: rubygem-{package_name}' in notice_log['permission_denied'] - - @pytest.mark.tier3 - def test_positive_debug_log_for_host( - self, module_target_sat, module_org, module_location, module_activation_key - ): + + @pytest.mark.no_containers + @pytest.mark.rhel_ver_list([settings.content_host.default_rhel_version]) + def test_positive_debug_log_for_host(self, target_sat, module_org, module_location, module_ak_with_cv): """Verify debug mode output for host :id: 06e0a95c-530b-11ef-a28c-36dcd2c0c415 @@ -627,28 +626,37 @@ def test_positive_debug_log_for_host( :customerscenario: true """ SELECTED_ROLE = 'RedHatInsights.insights-client' - id = module_target_sat.nailgun_smart_proxy.id - module_target_sat.api.AnsibleRoles().sync( - data={'proxy_id': id, 'role_names': SELECTED_ROLE} + nc = target_sat.nailgun_smart_proxy + nc.location = [module_location] + nc.organization = [module_org] + nc.update(['organization', 'location']) + target_sat.api.AnsibleRoles().sync( + data={'proxy_id': nc.id, 'role_names': SELECTED_ROLE} ) - with Broker(nick='rhel7', host_class=ContentHost, _count=2) as clients: + rhel_ver = settings.content_host.default_rhel_version + with Broker(nick=f'rhel{rhel_ver}', host_class=ContentHost, _count=2) as clients: vm1, vm2 = clients + vm1.create_custom_repos(rhel8=settings.repos.rhel8_os) result1 = vm1.register( - module_org, module_location, module_activation_key.name, module_target_sat + module_org, module_location, module_ak_with_cv.name, target_sat ) assert result1.status == 0, f'Failed to register host: {result1.stderr}' + vm2.create_custom_repos(rhel8=settings.repos.rhel8_os) result2 = vm2.register( - module_org, module_location, module_activation_key.name, module_target_sat + module_org, module_location, module_ak_with_cv.name, target_sat ) assert result2.status == 0, f'Failed to register host: {result2.stderr}' - with module_target_sat.ui_session() as session: - session.organization.select(module_org.name) - session.location.select(module_location.name) - session.host.select_checkbox() - session.host.apply_action( - 'Run all Ansible roles', entities_list=None) - result = session.jobinvocation.search('overview') - wait_for(lambda: result['job_status'] == 'passed') + with target_sat.ui_session() as session: + session.organization.select(module_org.name) + session.location.select(module_location.name) + session.host.select_checkbox() + session.host._select_action('Run all Ansible roles', [vm1.hostname, vm2.hostname]) + session.jobinvocation.wait_job_invocation_state( + entity_name='Run ansible roles', host_name=vm1.hostname + ) + output = session.jobinvocation.dynflow_output('Run ansible roles', vm1.hostname) + assert vm1.hostname in output + assert vm2.hostname not in output class TestAnsibleREX: @@ -916,3 +924,4 @@ def test_positive_schedule_recurring_hostgroup_job(self): :expectedresults: Scheduled Job appears in the Job Invocation list at the appointed time """ +