Skip to content

Commit

Permalink
Update Ansible tests to reflect the new split Ansible components (#14302
Browse files Browse the repository at this point in the history
)

Signed-off-by: Gaurav Talreja <[email protected]>
(cherry picked from commit 73b7bd2)
  • Loading branch information
Gauravtalreja1 authored and web-flow committed Mar 12, 2024
1 parent 842fc89 commit 1866325
Show file tree
Hide file tree
Showing 8 changed files with 73 additions and 80 deletions.
3 changes: 2 additions & 1 deletion testimony.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ CaseComponent:
# No spaces allowed
- ActivationKeys
- AlternateContentSources
- Ansible
- Ansible-ConfigurationManagement
- Ansible-RemoteExecution
- AnsibleCollection
- API
- AuditLog
Expand Down
91 changes: 44 additions & 47 deletions tests/foreman/api/test_ansible.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
:CaseAutomation: Automated
:CaseComponent: Ansible
:CaseComponent: Ansible-ConfigurationManagement
:Team: Rocket
:CaseImportance: High
:CaseImportance: Critical
"""
from fauxfactory import gen_string
Expand All @@ -19,6 +19,46 @@
from robottelo.utils.issue_handlers import is_open


@pytest.fixture
def filtered_user(target_sat, module_org, module_location):
"""
:steps:
1. Create a role with a host view filtered
2. Create a user with that role
3. Setup a host
"""
role = target_sat.api.Role(
name=gen_string('alpha'), location=[module_location], organization=[module_org]
).create()
# assign view_hosts (with a filter, to test BZ 1699188),
# view_hostgroups, view_facts permissions to the role
permission_hosts = target_sat.api.Permission().search(query={'search': 'name="view_hosts"'})
permission_hostgroups = target_sat.api.Permission().search(
query={'search': 'name="view_hostgroups"'}
)
permission_facts = target_sat.api.Permission().search(query={'search': 'name="view_facts"'})
target_sat.api.Filter(
permission=permission_hosts, search='name != nonexistent', role=role
).create()
target_sat.api.Filter(permission=permission_hostgroups, role=role).create()
target_sat.api.Filter(permission=permission_facts, role=role).create()

password = gen_string('alpha')
user = target_sat.api.User(
role=[role], password=password, location=[module_location], organization=[module_org]
).create()

return user, password


@pytest.fixture
def rex_host_in_org_and_loc(target_sat, module_org, module_location, rex_contenthost):
host = target_sat.api.Host().search(query={'search': f'name={rex_contenthost.hostname}'})[0]
target_sat.api.Host(id=host.id, organization=[module_org.id]).update(['organization'])
target_sat.api.Host(id=host.id, location=module_location.id).update(['location'])
return host


@pytest.mark.e2e
def test_fetch_and_sync_ansible_playbooks(target_sat):
"""
Expand All @@ -39,8 +79,6 @@ def test_fetch_and_sync_ansible_playbooks(target_sat):
1. Playbooks should be fetched and synced successfully.
:BZ: 2115686
:CaseAutomation: Automated
"""
target_sat.execute(
"ansible-galaxy collection install -p /usr/share/ansible/collections "
Expand Down Expand Up @@ -88,9 +126,7 @@ def test_positive_ansible_job_on_host(
:BZ: 2164400
:CaseAutomation: Automated
:CaseImportance: Critical
:CaseComponent: Ansible-RemoteExecution
"""
SELECTED_ROLE = 'RedHatInsights.insights-client'
if rhel_contenthost.os_version.major <= 7:
Expand Down Expand Up @@ -161,7 +197,7 @@ def test_positive_ansible_job_on_multiple_host(
:BZ: 2167396, 2190464, 2184117
:CaseAutomation: Automated
:CaseComponent: Ansible-RemoteExecution
"""
hosts = [rhel9_contenthost, rhel8_contenthost, rhel7_contenthost]
SELECTED_ROLE = 'RedHatInsights.insights-client'
Expand Down Expand Up @@ -286,45 +322,6 @@ def test_add_and_remove_ansible_role_hostgroup(target_sat):
assert len(hg_nested_roles) == 0


@pytest.fixture
def filtered_user(target_sat, module_org, module_location):
"""
:steps:
1. Create a role with a host view filtered
2. Create a user with that role
3. Setup a host
"""
api = target_sat.api
role = api.Role(
name=gen_string('alpha'), location=[module_location], organization=[module_org]
).create()
# assign view_hosts (with a filter, to test BZ 1699188),
# view_hostgroups, view_facts permissions to the role
permission_hosts = api.Permission().search(query={'search': 'name="view_hosts"'})
permission_hostgroups = api.Permission().search(query={'search': 'name="view_hostgroups"'})
permission_facts = api.Permission().search(query={'search': 'name="view_facts"'})
api.Filter(permission=permission_hosts, search='name != nonexistent', role=role).create()
api.Filter(permission=permission_hostgroups, role=role).create()
api.Filter(permission=permission_facts, role=role).create()

password = gen_string('alpha')
user = api.User(
role=[role], password=password, location=[module_location], organization=[module_org]
).create()

return user, password


@pytest.fixture
def rex_host_in_org_and_loc(target_sat, module_org, module_location, rex_contenthost):
api = target_sat.api
host = api.Host().search(query={'search': f'name={rex_contenthost.hostname}'})[0]
host_id = host.id
api.Host(id=host_id, organization=[module_org.id]).update(['organization'])
api.Host(id=host_id, location=module_location.id).update(['location'])
return host


@pytest.mark.rhel_ver_match('[78]')
@pytest.mark.tier2
def test_positive_read_facts_with_filter(
Expand Down
12 changes: 4 additions & 8 deletions tests/foreman/cli/test_ansible.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
:CaseAutomation: Automated
:CaseComponent: Ansible
:CaseComponent: Ansible-ConfigurationManagement
:Team: Rocket
Expand Down Expand Up @@ -41,8 +41,6 @@ def test_positive_ansible_e2e(target_sat, module_org, rhel_contenthost):
2. Job execution must be successful.
3. Operations performed with hammer must be successful.
:CaseAutomation: Automated
:BZ: 2154184
:customerscenario: true
Expand All @@ -53,7 +51,7 @@ def test_positive_ansible_e2e(target_sat, module_org, rhel_contenthost):
SELECTED_ROLE_1 = 'theforeman.foreman_scap_client'
SELECTED_VAR = gen_string('alpha')
# disable batch tasks to test BZ#2154184
target_sat.cli.Settings.set({'name': "foreman_tasks_proxy_batch_trigger", 'value': "false"})
target_sat.cli.Settings.set({'name': 'foreman_tasks_proxy_batch_trigger', 'value': 'false'})
if rhel_contenthost.os_version.major <= 7:
rhel_contenthost.create_custom_repos(rhel7=settings.repos.rhel7_os)
assert rhel_contenthost.execute('yum install -y insights-client').status == 0
Expand Down Expand Up @@ -121,7 +119,7 @@ def test_positive_ansible_e2e(target_sat, module_org, rhel_contenthost):
@pytest.mark.tier2
def test_add_and_remove_ansible_role_hostgroup(target_sat):
"""
Test add and remove functionality for ansible roles in hostgroup via cli
Test add and remove functionality for ansible roles in hostgroup via CLI
:id: 2c6fda14-4cd2-490a-b7ef-7a08f8164fad
Expand All @@ -135,11 +133,9 @@ def test_add_and_remove_ansible_role_hostgroup(target_sat):
5. Remove the added ansible roles from the host group
:expectedresults:
1. Ansible role assign/add/remove functionality should work as expected in cli
1. Ansible role assign/add/remove functionality should work as expected in CLI
:BZ: 2029402
:CaseAutomation: Automated
"""
ROLES = [
'theforeman.foreman_scap_client',
Expand Down
2 changes: 1 addition & 1 deletion tests/foreman/cli/test_remoteexecution.py
Original file line number Diff line number Diff line change
Expand Up @@ -854,7 +854,7 @@ def test_positive_install_ansible_collection(
:id: ad25aee5-4ea3-4743-a301-1c6271856f79
:CaseComponent: Ansible
:CaseComponent: Ansible-RemoteExecution
:Team: Rocket
"""
Expand Down
11 changes: 5 additions & 6 deletions tests/foreman/destructive/test_ansible.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
:CaseAutomation: Automated
:CaseComponent: Ansible
:CaseComponent: Ansible-ConfigurationManagement
:Team: Rocket
Expand All @@ -21,10 +21,6 @@ def test_positive_persistent_ansible_cfg_change(target_sat):
:id: c22fcd47-8627-4230-aa1f-7d4fc8517a0e
:BZ: 1786358
:customerscenario: true
:steps:
1. Update value in ansible.cfg.
2. Verify value is updated in the file.
Expand All @@ -33,6 +29,10 @@ def test_positive_persistent_ansible_cfg_change(target_sat):
:expectedresults: Changes in ansible.cfg are persistent after running
"satellite-installer".
:BZ: 1786358
:customerscenario: true
"""
ansible_cfg = '/etc/ansible/ansible.cfg'
param = 'local_tmp = /tmp'
Expand All @@ -49,7 +49,6 @@ def test_positive_import_all_roles(target_sat):
:id: 53fe3857-a08f-493d-93c7-3fed331ed391
:steps:
1. Navigate to the Configure > Roles page.
2. Click the `Import from [hostname]` button.
3. Get total number of importable roles from pagination.
Expand Down
8 changes: 4 additions & 4 deletions tests/foreman/ui/test_ansible.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
:CaseAutomation: Automated
:CaseComponent: Ansible
:CaseComponent: Ansible-ConfigurationManagement
:Team: Rocket
:CaseImportance: High
:CaseImportance: Critical
"""
from fauxfactory import gen_string
Expand Down Expand Up @@ -111,7 +111,7 @@ def test_positive_config_report_ansible(session, target_sat, module_org, rhel_co
1. Host should be assigned the proper role.
2. Job report should be created.
:CaseImportance: Critical
:CaseComponent: Ansible-RemoteExecution
"""
SELECTED_ROLE = 'RedHatInsights.insights-client'
if rhel_contenthost.os_version.major <= 7:
Expand Down Expand Up @@ -176,7 +176,7 @@ def test_positive_ansible_custom_role(target_sat, session, module_org, rhel_cont
:BZ: 2155392
:CaseAutomation: Automated
:CaseComponent: Ansible-RemoteExecution
"""
SELECTED_ROLE = 'custom_role'
playbook = f'{robottelo_tmp_dir}/playbook.yml'
Expand Down
4 changes: 2 additions & 2 deletions tests/foreman/ui/test_jobinvocation.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def test_positive_schedule_recurring_host_job(self):
:id: 5052be04-28ab-4349-8bee-851ef76e4ffa
:caseComponent: Ansible
:caseComponent: Ansible-RemoteExecution
:Team: Rocket
Expand All @@ -152,7 +152,7 @@ def test_positive_schedule_recurring_hostgroup_job(self):
:id: c65db99b-11fe-4a32-89d0-0a4692b07efe
:caseComponent: Ansible
:caseComponent: Ansible-RemoteExecution
:Team: Rocket
Expand Down
22 changes: 11 additions & 11 deletions tests/foreman/ui/test_remoteexecution.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ def test_positive_ansible_job_check_mode(session):
:CaseAutomation: NotAutomated
:CaseComponent: Ansible
:CaseComponent: Ansible-RemoteExecution
:Team: Rocket
"""
Expand All @@ -311,7 +311,7 @@ def test_positive_ansible_config_report_failed_tasks_errors(session):
:CaseAutomation: NotAutomated
:CaseComponent: Ansible
:CaseComponent: Ansible-ConfigurationManagement
:Team: Rocket
"""
Expand All @@ -335,7 +335,7 @@ def test_positive_ansible_config_report_changes_notice(session):
:CaseAutomation: NotAutomated
:CaseComponent: Ansible
:CaseComponent: Ansible-ConfigurationManagement
:Team: Rocket
"""
Expand All @@ -356,7 +356,7 @@ def test_positive_ansible_variables_imported_with_roles(session):
:CaseAutomation: NotAutomated
:CaseComponent: Ansible
:CaseComponent: Ansible-ConfigurationManagement
:Team: Rocket
"""
Expand All @@ -377,7 +377,7 @@ def test_positive_roles_import_in_background(session):
:CaseAutomation: NotAutomated
:CaseComponent: Ansible
:CaseComponent: Ansible-ConfigurationManagement
:Team: Rocket
"""
Expand All @@ -399,7 +399,7 @@ def test_positive_ansible_roles_ignore_list(session):
:CaseAutomation: NotAutomated
:CaseComponent: Ansible
:CaseComponent: Ansible-ConfigurationManagement
:Team: Rocket
"""
Expand All @@ -423,7 +423,7 @@ def test_positive_ansible_variables_installed_with_collection(session):
:CaseAutomation: NotAutomated
:CaseComponent: Ansible
:CaseComponent: Ansible-ConfigurationManagement
:Team: Rocket
"""
Expand All @@ -449,7 +449,7 @@ def test_positive_install_ansible_collection_via_job_invocation(session):
:CaseAutomation: NotAutomated
:CaseComponent: Ansible
:CaseComponent: Ansible-RemoteExecution
:Team: Rocket
"""
Expand All @@ -474,7 +474,7 @@ def test_positive_set_ansible_role_order_per_host(session):
:CaseAutomation: NotAutomated
:CaseComponent: Ansible
:CaseComponent: Ansible-ConfigurationManagement
:Team: Rocket
"""
Expand All @@ -501,7 +501,7 @@ def test_positive_set_ansible_role_order_per_hostgroup(session):
:CaseAutomation: NotAutomated
:CaseComponent: Ansible
:CaseComponent: Ansible-ConfigurationManagement
:Team: Rocket
"""
Expand All @@ -527,7 +527,7 @@ def test_positive_matcher_field_highlight(session):
:CaseAutomation: NotAutomated
:CaseComponent: Ansible
:CaseComponent: Ansible-ConfigurationManagement
:Team: Rocket
"""

0 comments on commit 1866325

Please sign in to comment.