From 25894a47aba7c09d320cd101383bd1aa56ef0f78 Mon Sep 17 00:00:00 2001 From: Gaurav Talreja Date: Tue, 12 Mar 2024 19:18:47 +0530 Subject: [PATCH] [6.12.z] Update Ansible tests to reflect the new split Ansible components (#14374) Update Ansible tests to reflect the new split Ansible components (#14302) Signed-off-by: Gaurav Talreja --- testimony.yaml | 3 +- tests/foreman/api/test_ansible.py | 96 +++++++++++------------ tests/foreman/cli/test_ansible.py | 4 +- tests/foreman/cli/test_remoteexecution.py | 2 +- tests/foreman/destructive/test_ansible.py | 5 +- tests/foreman/ui/test_ansible.py | 8 +- tests/foreman/ui/test_host.py | 8 +- tests/foreman/ui/test_jobinvocation.py | 4 +- tests/foreman/ui/test_remoteexecution.py | 22 +++--- 9 files changed, 73 insertions(+), 79 deletions(-) diff --git a/testimony.yaml b/testimony.yaml index fbb5f1a48ba..9a198435f11 100644 --- a/testimony.yaml +++ b/testimony.yaml @@ -14,7 +14,8 @@ CaseComponent: choices: # No spaces allowed - ActivationKeys - - Ansible + - Ansible-ConfigurationManagement + - Ansible-RemoteExecution - AnsibleCollection - API - AuditLog diff --git a/tests/foreman/api/test_ansible.py b/tests/foreman/api/test_ansible.py index 13feab2799d..42d3743e2af 100644 --- a/tests/foreman/api/test_ansible.py +++ b/tests/foreman/api/test_ansible.py @@ -6,13 +6,13 @@ :CaseLevel: Acceptance -:CaseComponent: Ansible +:CaseComponent: Ansible-ConfigurationManagement :Team: Rocket :TestType: Functional -:CaseImportance: High +:CaseImportance: Critical :Upstream: No """ @@ -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): """ @@ -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. @@ -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 " @@ -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 @@ -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: @@ -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' @@ -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( diff --git a/tests/foreman/cli/test_ansible.py b/tests/foreman/cli/test_ansible.py index 9742514d2db..a515d20b2cc 100644 --- a/tests/foreman/cli/test_ansible.py +++ b/tests/foreman/cli/test_ansible.py @@ -6,7 +6,7 @@ :CaseLevel: Acceptance -:CaseComponent: Ansible +:CaseComponent: Ansible-ConfigurationManagement :Team: Rocket @@ -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' diff --git a/tests/foreman/cli/test_remoteexecution.py b/tests/foreman/cli/test_remoteexecution.py index e1d1cbf06f6..1d6a555c741 100644 --- a/tests/foreman/cli/test_remoteexecution.py +++ b/tests/foreman/cli/test_remoteexecution.py @@ -652,7 +652,7 @@ def test_positive_install_ansible_collection( :id: ad25aee5-4ea3-4743-a301-1c6271856f79 - :CaseComponent: Ansible + :CaseComponent: Ansible-RemoteExecution :Team: Rocket """ diff --git a/tests/foreman/destructive/test_ansible.py b/tests/foreman/destructive/test_ansible.py index 621fa2b3d07..cde68a6fecb 100644 --- a/tests/foreman/destructive/test_ansible.py +++ b/tests/foreman/destructive/test_ansible.py @@ -6,7 +6,7 @@ :CaseLevel: Acceptance -:CaseComponent: Ansible +:CaseComponent: Ansible-ConfigurationManagement :Team: Rocket @@ -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. diff --git a/tests/foreman/ui/test_ansible.py b/tests/foreman/ui/test_ansible.py index 08486586d05..346c3f859a9 100644 --- a/tests/foreman/ui/test_ansible.py +++ b/tests/foreman/ui/test_ansible.py @@ -6,13 +6,13 @@ :CaseLevel: Acceptance -:CaseComponent: Ansible +:CaseComponent: Ansible-ConfigurationManagement :Team: Rocket :TestType: Functional -:CaseImportance: High +:CaseImportance: Critical :Upstream: No """ @@ -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: @@ -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' diff --git a/tests/foreman/ui/test_host.py b/tests/foreman/ui/test_host.py index bafeccec7a5..18680af2324 100644 --- a/tests/foreman/ui/test_host.py +++ b/tests/foreman/ui/test_host.py @@ -2512,7 +2512,7 @@ def test_positive_host_role_information(self): :id: 7da913ef-3b43-4bfa-9a45-d895431c8b56 - :caseComponent: Ansible + :caseComponent: Ansible-ConfigurationManagement :Team: Rocket @@ -2541,7 +2541,7 @@ def test_positive_role_variable_information(self): :id: 4ab2813a-6b83-4907-b104-0473465814f5 - :caseComponent: Ansible + :caseComponent: Ansible-ConfigurationManagement :Team: Rocket @@ -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 @@ -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 diff --git a/tests/foreman/ui/test_jobinvocation.py b/tests/foreman/ui/test_jobinvocation.py index c742f7ab154..492452a8315 100644 --- a/tests/foreman/ui/test_jobinvocation.py +++ b/tests/foreman/ui/test_jobinvocation.py @@ -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 @@ -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 diff --git a/tests/foreman/ui/test_remoteexecution.py b/tests/foreman/ui/test_remoteexecution.py index 26d530ed79f..d265ef96d7c 100644 --- a/tests/foreman/ui/test_remoteexecution.py +++ b/tests/foreman/ui/test_remoteexecution.py @@ -305,7 +305,7 @@ def test_positive_ansible_job_check_mode(session): :CaseAutomation: NotAutomated - :CaseComponent: Ansible + :CaseComponent: Ansible-RemoteExecution :Team: Rocket """ @@ -330,7 +330,7 @@ def test_positive_ansible_config_report_failed_tasks_errors(session): :CaseAutomation: NotAutomated - :CaseComponent: Ansible + :CaseComponent: Ansible-ConfigurationManagement :Team: Rocket """ @@ -356,7 +356,7 @@ def test_positive_ansible_config_report_changes_notice(session): :CaseAutomation: NotAutomated - :CaseComponent: Ansible + :CaseComponent: Ansible-ConfigurationManagement :Team: Rocket """ @@ -379,7 +379,7 @@ def test_positive_ansible_variables_imported_with_roles(session): :CaseAutomation: NotAutomated - :CaseComponent: Ansible + :CaseComponent: Ansible-ConfigurationManagement :Team: Rocket """ @@ -402,7 +402,7 @@ def test_positive_roles_import_in_background(session): :CaseAutomation: NotAutomated - :CaseComponent: Ansible + :CaseComponent: Ansible-ConfigurationManagement :Team: Rocket """ @@ -426,7 +426,7 @@ def test_positive_ansible_roles_ignore_list(session): :CaseAutomation: NotAutomated - :CaseComponent: Ansible + :CaseComponent: Ansible-ConfigurationManagement :Team: Rocket """ @@ -452,7 +452,7 @@ def test_positive_ansible_variables_installed_with_collection(session): :CaseAutomation: NotAutomated - :CaseComponent: Ansible + :CaseComponent: Ansible-ConfigurationManagement :Team: Rocket """ @@ -480,7 +480,7 @@ def test_positive_install_ansible_collection_via_job_invocation(session): :CaseAutomation: NotAutomated - :CaseComponent: Ansible + :CaseComponent: Ansible-RemoteExecution :Team: Rocket """ @@ -507,7 +507,7 @@ def test_positive_set_ansible_role_order_per_host(session): :CaseAutomation: NotAutomated - :CaseComponent: Ansible + :CaseComponent: Ansible-ConfigurationManagement :Team: Rocket """ @@ -536,7 +536,7 @@ def test_positive_set_ansible_role_order_per_hostgroup(session): :CaseAutomation: NotAutomated - :CaseComponent: Ansible + :CaseComponent: Ansible-ConfigurationManagement :Team: Rocket """ @@ -564,7 +564,7 @@ def test_positive_matcher_field_highlight(session): :CaseAutomation: NotAutomated - :CaseComponent: Ansible + :CaseComponent: Ansible-ConfigurationManagement :Team: Rocket """