Skip to content

Commit

Permalink
individual log should show for each host
Browse files Browse the repository at this point in the history
check debug log for expected host
  • Loading branch information
amolpati30 committed Sep 20, 2024
1 parent 05501d0 commit da4a3a8
Showing 1 changed file with 55 additions and 0 deletions.
55 changes: 55 additions & 0 deletions tests/foreman/ui/test_ansible.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
:CaseImportance: Critical
"""

from broker import Broker
from fauxfactory import gen_string
import pytest
from wait_for import wait_for
Expand All @@ -21,6 +22,7 @@
settings,
user_nailgun_config,
)
from robottelo.hosts import ContentHost


class TestAnsibleCfgMgmt:
Expand Down Expand Up @@ -565,6 +567,59 @@ def test_positive_ansible_config_report_changes_notice_and_failed_tasks_errors(
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.no_containers
@pytest.mark.rhel_ver_list([settings.content_host.default_rhel_version])
@pytest.mark.parametrize('setting_update', ['ansible_verbosity'], indirect=True)
def test_positive_debug_log_for_host(
self, target_sat, module_org, module_location, module_ak_with_cv, setting_update
):
"""Verify debug mode output for host
:id: 06e0a95c-530b-11ef-a28c-36dcd2c0c415
:steps:
1. Enable Ansible Debug
2. Select two or more hosts
3. Run ansible roles on those hosts
4. Check the host execution logs
:expectedresults: The host execution log should show the debug log for expected host instead of the all host present in the inventory.
:BZ: 1912941
:Verifies: SAT-12267
:customerscenario: true
"""
SELECTED_ROLE = 'RedHatInsights.insights-client'
setting_update.value = 'Level 3(-vvv)'
setting_update.update({'value'})
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})
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_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_ak_with_cv.name, target_sat)
assert result2.status == 0, f'Failed to register host: {result2.stderr}'
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:
"""Test class for remote execution via Ansible
Expand Down

0 comments on commit da4a3a8

Please sign in to comment.