Skip to content

Commit

Permalink
[6.12.z] Update Ansible tests to reflect the new split Ansible compon…
Browse files Browse the repository at this point in the history
…ents (#14374)

Update Ansible tests to reflect the new split Ansible components (#14302)

Signed-off-by: Gaurav Talreja <[email protected]>
  • Loading branch information
Gauravtalreja1 authored Mar 12, 2024
1 parent 88b2795 commit 25894a4
Show file tree
Hide file tree
Showing 9 changed files with 73 additions and 79 deletions.
3 changes: 2 additions & 1 deletion testimony.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ CaseComponent:
choices:
# No spaces allowed
- ActivationKeys
- Ansible
- Ansible-ConfigurationManagement
- Ansible-RemoteExecution
- AnsibleCollection
- API
- AuditLog
Expand Down
96 changes: 46 additions & 50 deletions tests/foreman/api/test_ansible.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
:CaseLevel: Acceptance
:CaseComponent: Ansible
:CaseComponent: Ansible-ConfigurationManagement
:Team: Rocket
:TestType: Functional
:CaseImportance: High
:CaseImportance: Critical
:Upstream: No
"""
Expand All @@ -24,6 +24,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 @@ -33,8 +73,7 @@ def test_fetch_and_sync_ansible_playbooks(target_sat):
:customerscenario: true
:Steps:
:steps:
1. Install ansible collection with playbooks.
2. Try to fetch the playbooks via api.
3. Sync the playbooks.
Expand All @@ -44,8 +83,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 @@ -77,7 +114,7 @@ def test_positive_ansible_job_on_host(target_sat, module_org, rhel_contenthost):
:id: c8dcdc54-cb98-4b24-bff9-049a6cc36acb
:Steps:
:steps:
1. Register a content host with satellite
2. Import a role into satellite
3. Assign that role to a host
Expand All @@ -89,9 +126,7 @@ def test_positive_ansible_job_on_host(target_sat, module_org, rhel_contenthost):
1. Host should be assigned the proper role.
2. Job execution must be successful.
:CaseAutomation: Automated
:CaseImportance: Critical
:CaseComponent: Ansible-RemoteExecution
"""
SELECTED_ROLE = 'RedHatInsights.insights-client'
if rhel_contenthost.os_version.major <= 7:
Expand Down Expand Up @@ -157,7 +192,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 @@ -200,45 +235,6 @@ def test_positive_ansible_job_on_multiple_host(
assert result.status_label == 'failed'


@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
4 changes: 1 addition & 3 deletions tests/foreman/cli/test_ansible.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
:CaseLevel: Acceptance
:CaseComponent: Ansible
:CaseComponent: Ansible-ConfigurationManagement
:Team: Rocket
Expand Down Expand Up @@ -45,8 +45,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
:CaseImportance: Critical
"""
SELECTED_ROLE = 'RedHatInsights.insights-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 @@ -652,7 +652,7 @@ def test_positive_install_ansible_collection(
:id: ad25aee5-4ea3-4743-a301-1c6271856f79
:CaseComponent: Ansible
:CaseComponent: Ansible-RemoteExecution
:Team: Rocket
"""
Expand Down
5 changes: 2 additions & 3 deletions tests/foreman/destructive/test_ansible.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
:CaseLevel: Acceptance
:CaseComponent: Ansible
:CaseComponent: Ansible-ConfigurationManagement
:Team: Rocket
Expand All @@ -26,8 +26,7 @@ def test_positive_import_all_roles(target_sat):
:id: 53fe3857-a08f-493d-93c7-3fed331ed391
:Steps:
: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 @@ -6,13 +6,13 @@
:CaseLevel: Acceptance
:CaseComponent: Ansible
:CaseComponent: Ansible-ConfigurationManagement
:Team: Rocket
:TestType: Functional
:CaseImportance: High
:CaseImportance: Critical
:Upstream: No
"""
Expand Down Expand Up @@ -114,7 +114,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 @@ -179,7 +179,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
8 changes: 4 additions & 4 deletions tests/foreman/ui/test_host.py
Original file line number Diff line number Diff line change
Expand Up @@ -2512,7 +2512,7 @@ def test_positive_host_role_information(self):
:id: 7da913ef-3b43-4bfa-9a45-d895431c8b56
:caseComponent: Ansible
:caseComponent: Ansible-ConfigurationManagement
:Team: Rocket
Expand Down Expand Up @@ -2541,7 +2541,7 @@ def test_positive_role_variable_information(self):
:id: 4ab2813a-6b83-4907-b104-0473465814f5
:caseComponent: Ansible
:caseComponent: Ansible-ConfigurationManagement
:Team: Rocket
Expand Down Expand Up @@ -2569,7 +2569,7 @@ def test_positive_assign_role_in_new_ui(self):
:id: 044f38b4-cff2-4ddc-b93c-7e9f2826d00d
:caseComponent: Ansible
:caseComponent: Ansible-ConfigurationManagement
:Team: Rocket
Expand All @@ -2594,7 +2594,7 @@ def test_positive_remove_role_in_new_ui(self):
:id: d6de5130-45f6-4349-b490-fbde2aed082c
:caseComponent: Ansible
:caseComponent: Ansible-ConfigurationManagement
:Team: Rocket
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 @@ -135,7 +135,7 @@ def test_positive_schedule_recurring_host_job(self):
:id: 5052be04-28ab-4349-8bee-851ef76e4ffa
:caseComponent: Ansible
:caseComponent: Ansible-RemoteExecution
:Team: Rocket
Expand All @@ -162,7 +162,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 @@ -305,7 +305,7 @@ def test_positive_ansible_job_check_mode(session):
:CaseAutomation: NotAutomated
:CaseComponent: Ansible
:CaseComponent: Ansible-RemoteExecution
:Team: Rocket
"""
Expand All @@ -330,7 +330,7 @@ def test_positive_ansible_config_report_failed_tasks_errors(session):
:CaseAutomation: NotAutomated
:CaseComponent: Ansible
:CaseComponent: Ansible-ConfigurationManagement
:Team: Rocket
"""
Expand All @@ -356,7 +356,7 @@ def test_positive_ansible_config_report_changes_notice(session):
:CaseAutomation: NotAutomated
:CaseComponent: Ansible
:CaseComponent: Ansible-ConfigurationManagement
:Team: Rocket
"""
Expand All @@ -379,7 +379,7 @@ def test_positive_ansible_variables_imported_with_roles(session):
:CaseAutomation: NotAutomated
:CaseComponent: Ansible
:CaseComponent: Ansible-ConfigurationManagement
:Team: Rocket
"""
Expand All @@ -402,7 +402,7 @@ def test_positive_roles_import_in_background(session):
:CaseAutomation: NotAutomated
:CaseComponent: Ansible
:CaseComponent: Ansible-ConfigurationManagement
:Team: Rocket
"""
Expand All @@ -426,7 +426,7 @@ def test_positive_ansible_roles_ignore_list(session):
:CaseAutomation: NotAutomated
:CaseComponent: Ansible
:CaseComponent: Ansible-ConfigurationManagement
:Team: Rocket
"""
Expand All @@ -452,7 +452,7 @@ def test_positive_ansible_variables_installed_with_collection(session):
:CaseAutomation: NotAutomated
:CaseComponent: Ansible
:CaseComponent: Ansible-ConfigurationManagement
:Team: Rocket
"""
Expand Down Expand Up @@ -480,7 +480,7 @@ def test_positive_install_ansible_collection_via_job_invocation(session):
:CaseAutomation: NotAutomated
:CaseComponent: Ansible
:CaseComponent: Ansible-RemoteExecution
:Team: Rocket
"""
Expand All @@ -507,7 +507,7 @@ def test_positive_set_ansible_role_order_per_host(session):
:CaseAutomation: NotAutomated
:CaseComponent: Ansible
:CaseComponent: Ansible-ConfigurationManagement
:Team: Rocket
"""
Expand Down Expand Up @@ -536,7 +536,7 @@ def test_positive_set_ansible_role_order_per_hostgroup(session):
:CaseAutomation: NotAutomated
:CaseComponent: Ansible
:CaseComponent: Ansible-ConfigurationManagement
:Team: Rocket
"""
Expand Down Expand Up @@ -564,7 +564,7 @@ def test_positive_matcher_field_highlight(session):
:CaseAutomation: NotAutomated
:CaseComponent: Ansible
:CaseComponent: Ansible-ConfigurationManagement
:Team: Rocket
"""

0 comments on commit 25894a4

Please sign in to comment.