From 904ca1d3039fdba8893d629bb6e8617a8f5caec4 Mon Sep 17 00:00:00 2001 From: shwsingh Date: Thu, 15 Feb 2024 12:55:20 +0530 Subject: [PATCH] Test leapp upgrade with non-admin user BZ#2257302 --- tests/foreman/cli/test_leapp_client.py | 89 ++++++++++++++++++++++++++ 1 file changed, 89 insertions(+) diff --git a/tests/foreman/cli/test_leapp_client.py b/tests/foreman/cli/test_leapp_client.py index 6ab248b0f92..80566662f41 100644 --- a/tests/foreman/cli/test_leapp_client.py +++ b/tests/foreman/cli/test_leapp_client.py @@ -12,6 +12,7 @@ """ from broker import Broker +from fauxfactory import gen_string import pytest from robottelo.config import settings @@ -286,3 +287,91 @@ def test_leapp_upgrade_rhel( custom_leapp_host.clean_cached_properties() new_ver = str(custom_leapp_host.os_version) assert new_ver == upgrade_path['target_version'] + + +@pytest.mark.parametrize( + 'upgrade_path', + [ + {'source_version': RHEL8_VER, 'target_version': RHEL9_VER}, + ], + ids=lambda upgrade_path: f'{upgrade_path["source_version"]}' + f'_to_{upgrade_path["target_version"]}', +) +def test_leapp_upgrade_rhel_non_admin( + module_target_sat, + module_sca_manifest_org, + default_location, + custom_leapp_host, + upgrade_path, + verify_target_repo_on_satellite, + precondition_check_upgrade_and_install_leapp_tool, +): + """Test to upgrade RHEL host to next major RHEL release using leapp preupgrade and leapp upgrade + job templates + + :id: afd295ca-4b0e-439f-b880-ae92c300fd9f + + :BZ: 2257302 + + :customerscenario: true + + :steps: + 1. Import a subscription manifest and enable, sync source & target repositories + 2. Create LCE, Create CV, add repositories to it, publish and promote CV, Create AK, etc. + 3. Register content host with AK + 4. Verify that target rhel repositories are enabled on Satellite + 5. Update all packages, install leapp tool and fix inhibitors + 6. Create a non-admin user with "Organization admin", "Remote Execution Manager" and "Remote Execution User" role assigned to it. + 7. Run Leapp Preupgrade and Leapp Upgrade job template from the user created in step 6. + + :expectedresults: + 1. Update RHEL OS major version to another major version from non-admin user role. + """ + login = gen_string('alpha') + password = gen_string('alpha') + roles = ['Organization admin', 'Remote Execution Manager', 'Remote Execution User'] + user = module_target_sat.cli_factory.user( + { + 'admin': False, + 'login': login, + 'password': password, + 'organization-ids': module_sca_manifest_org.id, + 'location-ids': default_location.id, + } + ) + for role in roles: + module_target_sat.cli.User.add_role({'id': user['id'], 'login': login, 'role': role}) + + # Fixing known inhibitors for source rhel version 8 + if custom_leapp_host.os_version.major == 8: + # Inhibitor - Firewalld Configuration AllowZoneDrifting Is Unsupported + custom_leapp_host.run( + 'sed -i "s/^AllowZoneDrifting=.*/AllowZoneDrifting=no/" /etc/firewalld/firewalld.conf' + ) + + invocation_command = module_target_sat.cli_factory.job_invocation_with_credentials( + { + 'job-template': 'Run preupgrade via Leapp', + 'search-query': f'name = {custom_leapp_host.hostname}', + 'organization-id': module_sca_manifest_org.id, + 'location-id': default_location.id, + 'inputs': 'Channel=ga', + }, + (login, password), + ) + result = module_target_sat.cli.JobInvocation.info({'id': invocation_command['id']}) + assert result['success'] == '1' + + invocation_command = module_target_sat.cli_factory.job_invocation_with_credentials( + { + 'job-template': 'Run upgrade via Leapp', + 'search-query': f'name = {custom_leapp_host.hostname}', + 'organization-id': module_sca_manifest_org.id, + 'location-id': default_location.id, + 'inputs': 'Reboot=false, Channel=ga', + }, + (login, password), + ) + custom_leapp_host.power_control(state='reboot') + result = module_target_sat.cli.JobInvocation.info({'id': invocation_command['id']}) + assert result['success'] == '1'