From 1edcabaf432a2fca2e38fe1403891acbbd898478 Mon Sep 17 00:00:00 2001 From: Satellite QE <115476073+Satellite-QE@users.noreply.github.com> Date: Wed, 18 Oct 2023 00:04:50 -0400 Subject: [PATCH 01/30] [6.13.z] Bump pytest-reportportal from 5.2.2 to 5.3.0 (#12933) --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index a0c2d3518b8..25d7db1a9a1 100644 --- a/requirements.txt +++ b/requirements.txt @@ -15,7 +15,7 @@ python-box==7.1.1 pytest==7.4.2 pytest-services==2.2.1 pytest-mock==3.11.1 -pytest-reportportal==5.2.2 +pytest-reportportal==5.3.0 pytest-xdist==3.3.1 pytest-ibutsu==2.2.4 PyYAML==6.0.1 From 41240743b1328d008a6380244b34bd1c957846c6 Mon Sep 17 00:00:00 2001 From: Satellite QE <115476073+Satellite-QE@users.noreply.github.com> Date: Wed, 18 Oct 2023 03:03:46 -0400 Subject: [PATCH 02/30] [6.13.z] Use sAMAccountName (#12930) Use sAMAccountName (cherry picked from commit ed25cc48b772c07cd307e4dc235508b5954968e4) Co-authored-by: Lukas Hellebrandt --- tests/foreman/cli/test_ldapauthsource.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/foreman/cli/test_ldapauthsource.py b/tests/foreman/cli/test_ldapauthsource.py index 92d5185cc83..3feed9bad43 100644 --- a/tests/foreman/cli/test_ldapauthsource.py +++ b/tests/foreman/cli/test_ldapauthsource.py @@ -127,7 +127,7 @@ def test_positive_refresh_usergroup_with_ad(self, member_group, ad_data): 'attr-firstname': LDAP_ATTR['firstname'], 'attr-lastname': LDAP_ATTR['surname'], 'attr-mail': LDAP_ATTR['mail'], - 'account': ad_data['ldap_user_name'], + 'account': fr"{ad_data['workgroup']}\{ad_data['ldap_user_name']}", 'account-password': ad_data['ldap_user_passwd'], 'base-dn': ad_data['base_dn'], } From c595d566dafdd20032bfd6f3bb7f5cc25439a132 Mon Sep 17 00:00:00 2001 From: Satellite QE <115476073+Satellite-QE@users.noreply.github.com> Date: Wed, 18 Oct 2023 03:26:11 -0400 Subject: [PATCH 03/30] [6.13.z] Bump deepdiff from 6.6.0 to 6.6.1 (#12936) --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 25d7db1a9a1..eeb43316512 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,7 +3,7 @@ betelgeuse==1.10.0 broker[docker]==0.4.1 cryptography==41.0.4 -deepdiff==6.6.0 +deepdiff==6.6.1 dynaconf[vault]==3.2.3 fauxfactory==3.1.0 jinja2==3.1.2 From c95cb3deef7516a8dd89d3217b622e45ccedaabd Mon Sep 17 00:00:00 2001 From: Satellite QE <115476073+Satellite-QE@users.noreply.github.com> Date: Thu, 19 Oct 2023 09:22:38 -0400 Subject: [PATCH 04/30] [6.13.z] Fix maintain CLI caching class attributes (#12942) --- robottelo/cli/sm_packages.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/robottelo/cli/sm_packages.py b/robottelo/cli/sm_packages.py index ece44a773e0..d4674279172 100644 --- a/robottelo/cli/sm_packages.py +++ b/robottelo/cli/sm_packages.py @@ -30,6 +30,7 @@ class Packages(Base): def lock(cls, options=None): """Build satellite-maintain packages lock""" cls.command_sub = 'lock' + cls.command_end = None options = options or {} return cls.sm_execute(cls._construct_command(options)) @@ -37,6 +38,7 @@ def lock(cls, options=None): def unlock(cls, options=None): """Build satellite-maintain packages unlock""" cls.command_sub = 'unlock' + cls.command_end = None options = options or {} return cls.sm_execute(cls._construct_command(options)) @@ -44,6 +46,7 @@ def unlock(cls, options=None): def is_locked(cls, options=None): """Build satellite-maintain packages is-locked""" cls.command_sub = 'is-locked' + cls.command_end = None options = options or {} return cls.sm_execute(cls._construct_command(options)) @@ -75,5 +78,6 @@ def update(cls, packages='', options=None): def check_update(cls, options=None): """Build satellite-maintain packages check-update""" cls.command_sub = 'check-update' + cls.command_end = None options = options or {} return cls.sm_execute(cls._construct_command(options)) From 2b3fb083e3973746ef1ce00eeb4c4f216a82b173 Mon Sep 17 00:00:00 2001 From: Satellite QE <115476073+Satellite-QE@users.noreply.github.com> Date: Fri, 20 Oct 2023 00:16:38 -0400 Subject: [PATCH 05/30] [6.13.z] Bump pytest-mock from 3.11.1 to 3.12.0 (#12949) --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index eeb43316512..ba6fb73a225 100644 --- a/requirements.txt +++ b/requirements.txt @@ -14,7 +14,7 @@ pyotp==2.9.0 python-box==7.1.1 pytest==7.4.2 pytest-services==2.2.1 -pytest-mock==3.11.1 +pytest-mock==3.12.0 pytest-reportportal==5.3.0 pytest-xdist==3.3.1 pytest-ibutsu==2.2.4 From 06aa47b6c0f967d9eafe875a50a4f5a6dbaa8f0b Mon Sep 17 00:00:00 2001 From: Satellite QE <115476073+Satellite-QE@users.noreply.github.com> Date: Fri, 20 Oct 2023 03:25:39 -0400 Subject: [PATCH 06/30] [6.13.z] Fix VMware tests (#12886) Fix VMware tests (#12883) (cherry picked from commit 2211271e46c2dbeb5694177cc452d19dcbcf5256) Signed-off-by: Shubham Ganar Co-authored-by: Shubham Ganar <67952129+shubhamsg199@users.noreply.github.com> --- robottelo/constants/__init__.py | 2 +- .../cli/test_computeresource_vmware.py | 2 +- .../foreman/ui/test_computeresource_vmware.py | 128 ------------------ 3 files changed, 2 insertions(+), 130 deletions(-) diff --git a/robottelo/constants/__init__.py b/robottelo/constants/__init__.py index 107fa56f4cf..919017c16f5 100644 --- a/robottelo/constants/__init__.py +++ b/robottelo/constants/__init__.py @@ -1729,7 +1729,7 @@ class Colored(Box): VMWARE_CONSTANTS = { 'folder': 'vm', - 'guest_os': 'Red Hat Enterprise Linux 8 (64-bit)', + 'guest_os': 'Red Hat Enterprise Linux 8 (64 bit)', 'scsicontroller': 'LSI Logic Parallel', 'virtualhw_version': 'Default', 'pool': 'Resources', diff --git a/tests/foreman/cli/test_computeresource_vmware.py b/tests/foreman/cli/test_computeresource_vmware.py index 84ebc98af7c..3606b0a077d 100644 --- a/tests/foreman/cli/test_computeresource_vmware.py +++ b/tests/foreman/cli/test_computeresource_vmware.py @@ -56,7 +56,7 @@ def test_positive_vmware_cr_end_to_end(target_sat, module_org, module_location): ) assert vmware_cr['name'] == cr_name assert vmware_cr['locations'][0] == module_location.name - assert vmware_cr['organizations'] == module_org.name + assert vmware_cr['organizations'][0] == module_org.name assert vmware_cr['server'] == settings.vmware.vcenter assert vmware_cr['datacenter'] == settings.vmware.datacenter # List diff --git a/tests/foreman/ui/test_computeresource_vmware.py b/tests/foreman/ui/test_computeresource_vmware.py index 1f93bbe673a..df02d618383 100644 --- a/tests/foreman/ui/test_computeresource_vmware.py +++ b/tests/foreman/ui/test_computeresource_vmware.py @@ -27,7 +27,6 @@ from robottelo.config import settings from robottelo.constants import ( COMPUTE_PROFILE_LARGE, - DEFAULT_LOC, FOREMAN_PROVIDERS, VMWARE_CONSTANTS, ) @@ -475,130 +474,3 @@ def test_positive_access_vmware_with_custom_profile(session): if key in expected_disk_value } assert provided_disk_value == expected_disk_value - - -@pytest.mark.tier2 -def test_positive_virt_card(session, target_sat, module_location, module_org): - """Check to see that the Virtualization card appears for an imported VM - - :id: 0502d5a6-64c1-422f-a9ba-ac7c2ee7bad2 - - :parametrized: no - - :expectedresults: Virtualization card appears in the new Host UI for the VM - - :CaseLevel: Integration - - :CaseImportance: Medium - """ - # create entities for hostgroup - default_loc_id = ( - target_sat.api.Location().search(query={'search': f'name="{DEFAULT_LOC}"'})[0].id - ) - target_sat.api.SmartProxy(id=1, location=[default_loc_id, module_location.id]).update() - domain = target_sat.api.Domain( - organization=[module_org.id], location=[module_location] - ).create() - subnet = target_sat.api.Subnet( - organization=[module_org.id], location=[module_location], domain=[domain] - ).create() - architecture = target_sat.api.Architecture().create() - ptable = target_sat.api.PartitionTable( - organization=[module_org.id], location=[module_location] - ).create() - operatingsystem = target_sat.api.OperatingSystem( - architecture=[architecture], ptable=[ptable] - ).create() - medium = target_sat.api.Media( - organization=[module_org.id], location=[module_location], operatingsystem=[operatingsystem] - ).create() - lce = ( - target_sat.api.LifecycleEnvironment(name="Library", organization=module_org.id) - .search()[0] - .read() - .id - ) - cv = target_sat.api.ContentView(organization=module_org).create() - cv.publish() - - # create hostgroup - hostgroup_name = gen_string('alpha') - target_sat.api.HostGroup( - name=hostgroup_name, - architecture=architecture, - domain=domain, - subnet=subnet, - location=[module_location.id], - medium=medium, - operatingsystem=operatingsystem, - organization=[module_org], - ptable=ptable, - lifecycle_environment=lce, - content_view=cv, - content_source=1, - ).create() - cr_name = gen_string('alpha') - with session: - session.computeresource.create( - { - 'name': cr_name, - 'provider': FOREMAN_PROVIDERS['vmware'], - 'provider_content.vcenter': settings.vmware.vcenter, - 'provider_content.user': settings.vmware.username, - 'provider_content.password': settings.vmware.password, - 'provider_content.datacenter.value': settings.vmware.datacenter, - 'locations.resources.assigned': [module_location.name], - 'organizations.resources.assigned': [module_org.name], - } - ) - session.hostgroup.update(hostgroup_name, {'host_group.deploy': cr_name + " (VMware)"}) - session.computeresource.vm_import( - cr_name, - settings.vmware.vm_name, - hostgroup_name, - module_location.name, - ) - host_name = '.'.join([settings.vmware.vm_name, domain.name]) - power_status = session.computeresource.vm_status(cr_name, settings.vmware.vm_name) - if power_status is False: - session.computeresource.vm_poweron(cr_name, settings.vmware.vm_name) - try: - wait_for( - lambda: ( - session.browser.refresh(), - session.computeresource.vm_status(cr_name, settings.vmware.vm_name), - )[1] - is not power_status, - timeout=30, - delay=2, - ) - except TimedOutError: - raise AssertionError('Timed out waiting for VM to toggle power state') - - virt_card = session.host_new.get_virtualization(host_name)['details'] - assert virt_card['datacenter'] == settings.vmware.datacenter - assert virt_card['cluster'] == settings.vmware.cluster - assert virt_card['memory'] == '5 GB' - assert 'public_ip_address' in virt_card - assert virt_card['mac_address'] == settings.vmware.mac_address - assert virt_card['cpus'] == '1' - if 'disk_label' in virt_card: - assert virt_card['disk_label'] == 'Hard disk 1' - if 'disk_capacity' in virt_card: - assert virt_card['disk_capacity'] != '' - if 'partition_capacity' in virt_card: - assert virt_card['partition_capacity'] != '' - if 'partition_path' in virt_card: - assert virt_card['partition_path'] == '/boot' - if 'partition_allocation' in virt_card: - assert virt_card['partition_allocation'] != '' - assert virt_card['cores_per_socket'] == '1' - assert virt_card['firmware'] == 'bios' - assert virt_card['hypervisor'] != '' - assert virt_card['connection_state'] == 'connected' - assert virt_card['overall_status'] == 'green' - assert virt_card['annotation_notes'] == '' - assert virt_card['running_on'] == cr_name - target_sat.api.Host( - id=target_sat.api.Host().search(query={'search': f'name={host_name}'})[0].id - ).delete() From 74390de13f2a1437d3b3ef16407fbb230458478c Mon Sep 17 00:00:00 2001 From: Satellite QE <115476073+Satellite-QE@users.noreply.github.com> Date: Fri, 20 Oct 2023 05:48:45 -0400 Subject: [PATCH 07/30] [6.13.z] fixture support for virt-who config ui : data_form deploy_type virtwho_config (#12876) fixture support for virt-who config ui : data_form deploy_type virtwho_config (cherry picked from commit a1dade860f307866900cd533b3663cfb4ed4b6fc) Co-authored-by: yanpliu --- tests/foreman/virtwho/ui/test_esx.py | 346 ++++++++---------- tests/foreman/virtwho/ui/test_esx_sca.py | 289 ++++++--------- tests/foreman/virtwho/ui/test_hyperv.py | 74 +--- tests/foreman/virtwho/ui/test_hyperv_sca.py | 62 +--- tests/foreman/virtwho/ui/test_kubevirt.py | 72 +--- tests/foreman/virtwho/ui/test_kubevirt_sca.py | 60 +-- tests/foreman/virtwho/ui/test_libvirt.py | 73 +--- tests/foreman/virtwho/ui/test_libvirt_sca.py | 61 +-- tests/foreman/virtwho/ui/test_nutanix.py | 148 +++----- tests/foreman/virtwho/ui/test_nutanix_sca.py | 117 ++---- 10 files changed, 457 insertions(+), 845 deletions(-) diff --git a/tests/foreman/virtwho/ui/test_esx.py b/tests/foreman/virtwho/ui/test_esx.py index f38590b8ddf..2715febb34f 100644 --- a/tests/foreman/virtwho/ui/test_esx.py +++ b/tests/foreman/virtwho/ui/test_esx.py @@ -31,57 +31,22 @@ delete_configure_option, deploy_configure_by_command, deploy_configure_by_command_check, - deploy_configure_by_script, get_configure_command, get_configure_file, get_configure_id, get_configure_option, - get_guest_info, get_virtwho_status, restart_virtwho_service, update_configure_option, ) -@pytest.fixture() -def form_data(): - form = { - 'debug': True, - 'interval': 'Every hour', - 'hypervisor_id': 'hostname', - 'hypervisor_type': settings.virtwho.esx.hypervisor_type, - 'hypervisor_content.server': settings.virtwho.esx.hypervisor_server, - 'hypervisor_content.username': settings.virtwho.esx.hypervisor_username, - 'hypervisor_content.password': settings.virtwho.esx.hypervisor_password, - } - return form - - -@pytest.fixture() -def virtwho_config(form_data, target_sat, session): - name = gen_string('alpha') - form_data['name'] = name - with session: - session.virtwho_configure.create(form_data) - yield virtwho_config - session.virtwho_configure.delete(name) - assert not session.virtwho_configure.search(name) - - -@pytest.fixture(autouse=True) -def delete_host(form_data, target_sat): - guest_name, _ = get_guest_info(form_data['hypervisor_type']) - results = target_sat.api.Host().search(query={'search': guest_name}) - if results: - target_sat.api.Host(id=results[0].read_json()['id']).delete() - - -@pytest.mark.usefixtures('delete_host') +@pytest.mark.delete_host class TestVirtwhoConfigforEsx: @pytest.mark.tier2 - @pytest.mark.parametrize('deploy_type', ['id', 'script']) + @pytest.mark.parametrize('deploy_type_ui', ['id', 'script'], indirect=True) def test_positive_deploy_configure_by_id_script( - self, default_org, virtwho_config, session, form_data, deploy_type + self, default_org, org_session, form_data_ui, deploy_type_ui ): """Verify configure created and deployed with id|script. @@ -98,37 +63,28 @@ def test_positive_deploy_configure_by_id_script( :CaseImportance: High """ - name = form_data['name'] - values = session.virtwho_configure.read(name) - if deploy_type == "id": - command = values['deploy']['command'] - hypervisor_name, guest_name = deploy_configure_by_command( - command, form_data['hypervisor_type'], debug=True, org=default_org.label - ) - elif deploy_type == "script": - script = values['deploy']['script'] - hypervisor_name, guest_name = deploy_configure_by_script( - script, form_data['hypervisor_type'], debug=True, org=default_org.label - ) - assert session.virtwho_configure.search(name)[0]['Status'] == 'ok' - hypervisor_display_name = session.contenthost.search(hypervisor_name)[0]['Name'] + hypervisor_name, guest_name = deploy_type_ui + assert org_session.virtwho_configure.search(form_data_ui['name'])[0]['Status'] == 'ok' + hypervisor_display_name = org_session.contenthost.search(hypervisor_name)[0]['Name'] vdc_physical = f'product_id = {settings.virtwho.sku.vdc_physical} and type=NORMAL' vdc_virtual = f'product_id = {settings.virtwho.sku.vdc_physical} and type=STACK_DERIVED' assert ( - session.contenthost.read_legacy_ui(hypervisor_display_name)['subscriptions']['status'] + org_session.contenthost.read_legacy_ui(hypervisor_display_name)['subscriptions'][ + 'status' + ] == 'Unsubscribed hypervisor' ) - session.contenthost.add_subscription(hypervisor_display_name, vdc_physical) - assert session.contenthost.search(hypervisor_name)[0]['Subscription Status'] == 'green' + org_session.contenthost.add_subscription(hypervisor_display_name, vdc_physical) + assert org_session.contenthost.search(hypervisor_name)[0]['Subscription Status'] == 'green' assert ( - session.contenthost.read_legacy_ui(guest_name)['subscriptions']['status'] + org_session.contenthost.read_legacy_ui(guest_name)['subscriptions']['status'] == 'Unentitled' ) - session.contenthost.add_subscription(guest_name, vdc_virtual) - assert session.contenthost.search(guest_name)[0]['Subscription Status'] == 'green' + org_session.contenthost.add_subscription(guest_name, vdc_virtual) + assert org_session.contenthost.search(guest_name)[0]['Subscription Status'] == 'green' @pytest.mark.tier2 - def test_positive_debug_option(self, default_org, virtwho_config, session, form_data): + def test_positive_debug_option(self, default_org, virtwho_config_ui, org_session, form_data_ui): """Verify debug checkbox and the value changes of VIRTWHO_DEBUG :id: adb435c4-d02b-47b6-89f5-dce9a4ff7939 @@ -141,23 +97,25 @@ def test_positive_debug_option(self, default_org, virtwho_config, session, form_ :CaseImportance: Medium """ - name = form_data['name'] + name = form_data_ui['name'] config_id = get_configure_id(name) config_command = get_configure_command(config_id, default_org.name) deploy_configure_by_command( - config_command, form_data['hypervisor_type'], org=default_org.label + config_command, form_data_ui['hypervisor_type'], org=default_org.label ) assert get_configure_option('debug', ETC_VIRTWHO_CONFIG) == '1' - session.virtwho_configure.edit(name, {'debug': False}) - results = session.virtwho_configure.read(name) + org_session.virtwho_configure.edit(name, {'debug': False}) + results = org_session.virtwho_configure.read(name) assert results['overview']['debug'] is False deploy_configure_by_command( - config_command, form_data['hypervisor_type'], org=default_org.label + config_command, form_data_ui['hypervisor_type'], org=default_org.label ) assert get_configure_option('debug', ETC_VIRTWHO_CONFIG) == '0' @pytest.mark.tier2 - def test_positive_interval_option(self, default_org, virtwho_config, session, form_data): + def test_positive_interval_option( + self, default_org, virtwho_config_ui, org_session, form_data_ui + ): """Verify interval dropdown options and the value changes of VIRTWHO_INTERVAL. :id: 731f8361-38d4-40b9-9530-8d785d61eaab @@ -170,7 +128,7 @@ def test_positive_interval_option(self, default_org, virtwho_config, session, fo :CaseImportance: Medium """ - name = form_data['name'] + name = form_data_ui['name'] config_id = get_configure_id(name) config_command = get_configure_command(config_id, default_org.name) intervals = { @@ -184,16 +142,18 @@ def test_positive_interval_option(self, default_org, virtwho_config, session, fo 'Every 3 days': '259200', } for option, value in sorted(intervals.items(), key=lambda item: int(item[1])): - session.virtwho_configure.edit(name, {'interval': option}) - results = session.virtwho_configure.read(name) + org_session.virtwho_configure.edit(name, {'interval': option}) + results = org_session.virtwho_configure.read(name) assert results['overview']['interval'] == option deploy_configure_by_command( - config_command, form_data['hypervisor_type'], org=default_org.label + config_command, form_data_ui['hypervisor_type'], org=default_org.label ) assert get_configure_option('interval', ETC_VIRTWHO_CONFIG) == value @pytest.mark.tier2 - def test_positive_hypervisor_id_option(self, default_org, virtwho_config, session, form_data): + def test_positive_hypervisor_id_option( + self, default_org, virtwho_config_ui, org_session, form_data_ui + ): """Verify Hypervisor ID dropdown options. :id: cc494bd9-51d9-452a-bfa9-5cdcafef5197 @@ -206,23 +166,25 @@ def test_positive_hypervisor_id_option(self, default_org, virtwho_config, sessio :CaseImportance: Medium """ - name = form_data['name'] + name = form_data_ui['name'] config_id = get_configure_id(name) config_command = get_configure_command(config_id, default_org.name) config_file = get_configure_file(config_id) # esx and rhevm support hwuuid option values = ['uuid', 'hostname', 'hwuuid'] for value in values: - session.virtwho_configure.edit(name, {'hypervisor_id': value}) - results = session.virtwho_configure.read(name) + org_session.virtwho_configure.edit(name, {'hypervisor_id': value}) + results = org_session.virtwho_configure.read(name) assert results['overview']['hypervisor_id'] == value deploy_configure_by_command( - config_command, form_data['hypervisor_type'], org=default_org.label + config_command, form_data_ui['hypervisor_type'], org=default_org.label ) assert get_configure_option('hypervisor_id', config_file) == value @pytest.mark.tier2 - def test_positive_filtering_option(self, default_org, virtwho_config, session, form_data): + def test_positive_filtering_option( + self, default_org, virtwho_config_ui, org_session, form_data_ui + ): """Verify Filtering dropdown options. :id: e17dda14-79cd-4cd2-8f29-60970b24a905 @@ -237,7 +199,7 @@ def test_positive_filtering_option(self, default_org, virtwho_config, session, f :BZ: 1735670 """ - name = form_data['name'] + name = form_data_ui['name'] config_id = get_configure_id(name) config_command = get_configure_command(config_id, default_org.name) config_file = get_configure_file(config_id) @@ -248,28 +210,28 @@ def test_positive_filtering_option(self, default_org, virtwho_config, session, f whitelist['filtering_content.filter_host_parents'] = regex blacklist['filtering_content.exclude_host_parents'] = regex # Update Whitelist and check the result - session.virtwho_configure.edit(name, whitelist) - results = session.virtwho_configure.read(name) + org_session.virtwho_configure.edit(name, whitelist) + results = org_session.virtwho_configure.read(name) assert results['overview']['filter_hosts'] == regex assert results['overview']['filter_host_parents'] == regex deploy_configure_by_command( - config_command, form_data['hypervisor_type'], org=default_org.label + config_command, form_data_ui['hypervisor_type'], org=default_org.label ) assert regex == get_configure_option('filter_hosts', config_file) assert regex == get_configure_option('filter_host_parents', config_file) # Update Blacklist and check the result - session.virtwho_configure.edit(name, blacklist) - results = session.virtwho_configure.read(name) + org_session.virtwho_configure.edit(name, blacklist) + results = org_session.virtwho_configure.read(name) assert results['overview']['exclude_hosts'] == regex assert results['overview']['exclude_host_parents'] == regex deploy_configure_by_command( - config_command, form_data['hypervisor_type'], org=default_org.label + config_command, form_data_ui['hypervisor_type'], org=default_org.label ) assert regex == get_configure_option('exclude_hosts', config_file) assert regex == get_configure_option('exclude_host_parents', config_file) @pytest.mark.tier2 - def test_positive_proxy_option(self, default_org, virtwho_config, session, form_data): + def test_positive_proxy_option(self, default_org, virtwho_config_ui, org_session, form_data_ui): """Verify 'HTTP Proxy' and 'Ignore Proxy' options. :id: 6659d577-0135-4bf0-81af-14b930011536 @@ -285,31 +247,31 @@ def test_positive_proxy_option(self, default_org, virtwho_config, session, form_ http_proxy, http_proxy_name, http_proxy_id = create_http_proxy( http_type='http', org=default_org ) - name = form_data['name'] + name = form_data_ui['name'] config_id = get_configure_id(name) config_command = get_configure_command(config_id, default_org.name) no_proxy = 'test.satellite.com' # Check the https proxy and No_PROXY settings - session.virtwho_configure.edit(name, {'proxy': https_proxy, 'no_proxy': no_proxy}) - results = session.virtwho_configure.read(name) + org_session.virtwho_configure.edit(name, {'proxy': https_proxy, 'no_proxy': no_proxy}) + results = org_session.virtwho_configure.read(name) assert results['overview']['proxy'] == https_proxy assert results['overview']['no_proxy'] == no_proxy deploy_configure_by_command( - config_command, form_data['hypervisor_type'], org=default_org.label + config_command, form_data_ui['hypervisor_type'], org=default_org.label ) assert get_configure_option('https_proxy', ETC_VIRTWHO_CONFIG) == https_proxy assert get_configure_option('no_proxy', ETC_VIRTWHO_CONFIG) == no_proxy # Check the http proxy setting - session.virtwho_configure.edit(name, {'proxy': http_proxy}) - results = session.virtwho_configure.read(name) + org_session.virtwho_configure.edit(name, {'proxy': http_proxy}) + results = org_session.virtwho_configure.read(name) assert results['overview']['proxy'] == http_proxy deploy_configure_by_command( - config_command, form_data['hypervisor_type'], org=default_org.label + config_command, form_data_ui['hypervisor_type'], org=default_org.label ) assert get_configure_option('http_proxy', ETC_VIRTWHO_CONFIG) == http_proxy @pytest.mark.tier2 - def test_positive_virtwho_roles(self, session): + def test_positive_virtwho_roles(self, org_session): """Verify the default roles for virtwho configure :id: cd6a5363-f9ba-4b52-892c-905634168fc5 @@ -337,14 +299,14 @@ def test_positive_virtwho_roles(self, session): }, 'Virt-who Viewer': {'Satellite virt who configure/config': ['view_virt_who_config']}, } - with session: + with org_session: for role_name, role_filters in roles.items(): - assert session.role.search(role_name)[0]['Name'] == role_name - assigned_permissions = session.filter.read_permissions(role_name) + assert org_session.role.search(role_name)[0]['Name'] == role_name + assigned_permissions = org_session.filter.read_permissions(role_name) assert sorted(assigned_permissions) == sorted(role_filters) @pytest.mark.tier2 - def test_positive_virtwho_configs_widget(self, default_org, session, form_data): + def test_positive_virtwho_configs_widget(self, default_org, org_session, form_data_ui): """Check if Virt-who Configurations Status Widget is working in the Dashboard UI :id: 5d61ce00-a640-4823-89d4-7b1d02b50ea6 @@ -363,38 +325,40 @@ def test_positive_virtwho_configs_widget(self, default_org, session, form_data): """ org_name = gen_string('alpha') name = gen_string('alpha') - form_data['name'] = name - with session: - session.organization.create({'name': org_name}) - session.organization.select(org_name) - session.virtwho_configure.create(form_data) + form_data_ui['name'] = name + with org_session: + org_session.organization.create({'name': org_name}) + org_session.organization.select(org_name) + org_session.virtwho_configure.create(form_data_ui) expected_values = [ {'Configuration Status': 'No Reports', 'Count': '1'}, {'Configuration Status': 'No Change', 'Count': '0'}, {'Configuration Status': 'OK', 'Count': '0'}, {'Configuration Status': 'Total Configurations', 'Count': '1'}, ] - values = session.dashboard.read('VirtWhoConfigStatus') + values = org_session.dashboard.read('VirtWhoConfigStatus') assert values['config_status'] == expected_values assert values['latest_config'] == 'No configuration found' # Check the 'Status' changed after deployed the virt-who config config_id = get_configure_id(name) config_command = get_configure_command(config_id, org_name) - deploy_configure_by_command(config_command, form_data['hypervisor_type'], org=org_name) - assert session.virtwho_configure.search(name)[0]['Status'] == 'ok' + deploy_configure_by_command( + config_command, form_data_ui['hypervisor_type'], org=org_name + ) + assert org_session.virtwho_configure.search(name)[0]['Status'] == 'ok' expected_values = [ {'Configuration Status': 'No Reports', 'Count': '0'}, {'Configuration Status': 'No Change', 'Count': '0'}, {'Configuration Status': 'OK', 'Count': '1'}, {'Configuration Status': 'Total Configurations', 'Count': '1'}, ] - values = session.dashboard.read('VirtWhoConfigStatus') + values = org_session.dashboard.read('VirtWhoConfigStatus') assert values['config_status'] == expected_values assert values['latest_config'] == 'No configuration found' - session.organization.select("Default Organization") + org_session.organization.select("Default Organization") @pytest.mark.tier2 - def test_positive_delete_configure(self, default_org, session, form_data): + def test_positive_delete_configure(self, default_org, org_session, form_data_ui): """Verify when a config is deleted the associated user is deleted. :id: 0e66dcf6-dc64-4fb2-b8a9-518f5adfa800 @@ -410,22 +374,24 @@ def test_positive_delete_configure(self, default_org, session, form_data): """ name = gen_string('alpha') - form_data['name'] = name - with session: - session.virtwho_configure.create(form_data) + form_data_ui['name'] = name + with org_session: + org_session.virtwho_configure.create(form_data_ui) config_id = get_configure_id(name) config_command = get_configure_command(config_id, default_org.name) deploy_configure_by_command( - config_command, form_data['hypervisor_type'], org=default_org.label + config_command, form_data_ui['hypervisor_type'], org=default_org.label ) - assert session.virtwho_configure.search(name)[0]['Status'] == 'ok' - session.virtwho_configure.delete(name) - assert not session.virtwho_configure.search(name) + assert org_session.virtwho_configure.search(name)[0]['Status'] == 'ok' + org_session.virtwho_configure.delete(name) + assert not org_session.virtwho_configure.search(name) restart_virtwho_service() assert get_virtwho_status() == 'logerror' @pytest.mark.tier2 - def test_positive_virtwho_reporter_role(self, default_org, session, test_name, form_data): + def test_positive_virtwho_reporter_role( + self, default_org, org_session, test_name, form_data_ui + ): """Verify the virt-who reporter role can TRULY work. :id: cd235ab0-d89c-464b-98d6-9d090ac40d8f @@ -438,9 +404,9 @@ def test_positive_virtwho_reporter_role(self, default_org, session, test_name, f username = gen_string('alpha') password = gen_string('alpha') config_name = gen_string('alpha') - with session: + with org_session: # Create an user - session.user.create( + org_session.user.create( { 'user.login': username, 'user.mail': valid_emails_list()[0], @@ -450,14 +416,14 @@ def test_positive_virtwho_reporter_role(self, default_org, session, test_name, f } ) # Create a virt-who config plugin - form_data['name'] = config_name - session.virtwho_configure.create(form_data) - values = session.virtwho_configure.read(config_name) + form_data_ui['name'] = config_name + org_session.virtwho_configure.create(form_data_ui) + values = org_session.virtwho_configure.read(config_name) command = values['deploy']['command'] deploy_configure_by_command( - command, form_data['hypervisor_type'], org=default_org.label + command, form_data_ui['hypervisor_type'], org=default_org.label ) - assert session.virtwho_configure.search(config_name)[0]['Status'] == 'ok' + assert org_session.virtwho_configure.search(config_name)[0]['Status'] == 'ok' # Update the virt-who config file config_id = get_configure_id(config_name) config_file = get_configure_file(config_id) @@ -467,19 +433,19 @@ def test_positive_virtwho_reporter_role(self, default_org, session, test_name, f restart_virtwho_service() assert get_virtwho_status() == 'logerror' # Check the permissioin of Virt-who Reporter - session.user.update(username, {'roles.resources.assigned': ['Virt-who Reporter']}) - assert session.user.search(username)[0]['Username'] == username - user = session.user.read(username) + org_session.user.update(username, {'roles.resources.assigned': ['Virt-who Reporter']}) + assert org_session.user.search(username)[0]['Username'] == username + user = org_session.user.read(username) assert user['roles']['resources']['assigned'] == ['Virt-who Reporter'] restart_virtwho_service() assert get_virtwho_status() == 'running' with Session(test_name, username, password) as newsession: assert not newsession.virtwho_configure.check_create_permission()['can_view'] - session.user.delete(username) - assert not session.user.search(username) + org_session.user.delete(username) + assert not org_session.user.search(username) @pytest.mark.tier2 - def test_positive_virtwho_viewer_role(self, default_org, session, test_name, form_data): + def test_positive_virtwho_viewer_role(self, default_org, org_session, test_name, form_data_ui): """Verify the virt-who viewer role can TRULY work. :id: bf3be2e4-3853-41cc-9b3e-c8677f0b8c5f @@ -492,9 +458,9 @@ def test_positive_virtwho_viewer_role(self, default_org, session, test_name, for username = gen_string('alpha') password = gen_string('alpha') config_name = gen_string('alpha') - with session: + with org_session: # Create an user - session.user.create( + org_session.user.create( { 'user.login': username, 'user.mail': valid_emails_list()[0], @@ -504,17 +470,17 @@ def test_positive_virtwho_viewer_role(self, default_org, session, test_name, for } ) # Create a virt-who config plugin - form_data['name'] = config_name - session.virtwho_configure.create(form_data) - values = session.virtwho_configure.read(config_name) + form_data_ui['name'] = config_name + org_session.virtwho_configure.create(form_data_ui) + values = org_session.virtwho_configure.read(config_name) command = values['deploy']['command'] deploy_configure_by_command( - command, form_data['hypervisor_type'], org=default_org.label + command, form_data_ui['hypervisor_type'], org=default_org.label ) - assert session.virtwho_configure.search(config_name)[0]['Status'] == 'ok' + assert org_session.virtwho_configure.search(config_name)[0]['Status'] == 'ok' # Check the permissioin of Virt-who Viewer - session.user.update(username, {'roles.resources.assigned': ['Virt-who Viewer']}) - user = session.user.read(username) + org_session.user.update(username, {'roles.resources.assigned': ['Virt-who Viewer']}) + user = org_session.user.read(username) assert user['roles']['resources']['assigned'] == ['Virt-who Viewer'] # Update the virt-who config file config_id = get_configure_id(config_name) @@ -535,11 +501,11 @@ def test_positive_virtwho_viewer_role(self, default_org, session, test_name, for assert not update_permission['can_edit'] newsession.virtwho_configure.read(config_name) # Delete the created user - session.user.delete(username) - assert not session.user.search(username) + org_session.user.delete(username) + assert not org_session.user.search(username) @pytest.mark.tier2 - def test_positive_virtwho_manager_role(self, default_org, session, test_name, form_data): + def test_positive_virtwho_manager_role(self, default_org, org_session, test_name, form_data_ui): """Verify the virt-who manager role can TRULY work. :id: a72023fb-7b23-4582-9adc-c5227dc7859c @@ -551,9 +517,9 @@ def test_positive_virtwho_manager_role(self, default_org, session, test_name, fo username = gen_string('alpha') password = gen_string('alpha') config_name = gen_string('alpha') - with session: + with org_session: # Create an user - session.user.create( + org_session.user.create( { 'user.login': username, 'user.mail': valid_emails_list()[0], @@ -563,28 +529,28 @@ def test_positive_virtwho_manager_role(self, default_org, session, test_name, fo } ) # Create a virt-who config plugin - form_data['name'] = config_name - session.virtwho_configure.create(form_data) - values = session.virtwho_configure.read(config_name) + form_data_ui['name'] = config_name + org_session.virtwho_configure.create(form_data_ui) + values = org_session.virtwho_configure.read(config_name) command = values['deploy']['command'] deploy_configure_by_command( - command, form_data['hypervisor_type'], org=default_org.label + command, form_data_ui['hypervisor_type'], org=default_org.label ) - assert session.virtwho_configure.search(config_name)[0]['Status'] == 'ok' + assert org_session.virtwho_configure.search(config_name)[0]['Status'] == 'ok' # Check the permissioin of Virt-who Manager - session.user.update(username, {'roles.resources.assigned': ['Virt-who Manager']}) - user = session.user.read(username) + org_session.user.update(username, {'roles.resources.assigned': ['Virt-who Manager']}) + user = org_session.user.read(username) assert user['roles']['resources']['assigned'] == ['Virt-who Manager'] with Session(test_name, username, password) as newsession: # create_virt_who_config new_virt_who_name = gen_string('alpha') - form_data['name'] = new_virt_who_name - newsession.virtwho_configure.create(form_data) + form_data_ui['name'] = new_virt_who_name + newsession.virtwho_configure.create(form_data_ui) # view_virt_who_config values = newsession.virtwho_configure.read(new_virt_who_name) command = values['deploy']['command'] deploy_configure_by_command( - command, form_data['hypervisor_type'], org=default_org.label + command, form_data_ui['hypervisor_type'], org=default_org.label ) assert newsession.virtwho_configure.search(new_virt_who_name)[0]['Status'] == 'ok' # edit_virt_who_config @@ -595,11 +561,11 @@ def test_positive_virtwho_manager_role(self, default_org, session, test_name, fo newsession.virtwho_configure.delete(modify_name) assert not newsession.virtwho_configure.search(modify_name) # Delete the created user - session.user.delete(username) - assert not session.user.search(username) + org_session.user.delete(username) + assert not org_session.user.search(username) @pytest.mark.tier2 - def test_positive_overview_label_name(self, default_org, form_data, session): + def test_positive_overview_label_name(self, default_org, form_data_ui, org_session): """Verify the label name on virt-who config Overview Page. :id: 21df8175-bb41-422e-a263-8677bc3a9565 @@ -613,20 +579,20 @@ def test_positive_overview_label_name(self, default_org, form_data, session): :CaseImportance: Medium """ name = gen_string('alpha') - form_data['name'] = name - hypervisor_type = form_data['hypervisor_type'] + form_data_ui['name'] = name + hypervisor_type = form_data_ui['hypervisor_type'] http_proxy_url, proxy_name, proxy_id = create_http_proxy(org=default_org) - form_data['proxy'] = http_proxy_url - form_data['no_proxy'] = 'test.satellite.com' + form_data_ui['proxy'] = http_proxy_url + form_data_ui['no_proxy'] = 'test.satellite.com' regex = '.*redhat.com' whitelist = {'filtering': 'Whitelist', 'filtering_content.filter_hosts': regex} blacklist = {'filtering': 'Blacklist', 'filtering_content.exclude_hosts': regex} if hypervisor_type == 'esx': whitelist['filtering_content.filter_host_parents'] = regex blacklist['filtering_content.exclude_host_parents'] = regex - form_data = dict(form_data, **whitelist) - with session: - session.virtwho_configure.create(form_data) + form_data = dict(form_data_ui, **whitelist) + with org_session: + org_session.virtwho_configure.create(form_data) fields = { 'status_label': 'Status', 'hypervisor_type_label': 'Hypervisor Type', @@ -647,11 +613,11 @@ def test_positive_overview_label_name(self, default_org, form_data, session): fields['kubeconfig_path_label'] = 'Kubeconfig Path' if hypervisor_type == 'esx': fields['filter_host_parents_label'] = 'Filter Host Parents' - results = session.virtwho_configure.read(name) + results = org_session.virtwho_configure.read(name) for key, value in fields.items(): assert results['overview'][key] == value - session.virtwho_configure.edit(name, blacklist) - results = session.virtwho_configure.read(name) + org_session.virtwho_configure.edit(name, blacklist) + results = org_session.virtwho_configure.read(name) del fields['filter_hosts_label'] if hypervisor_type == 'esx': del fields['filter_host_parents_label'] @@ -661,7 +627,9 @@ def test_positive_overview_label_name(self, default_org, form_data, session): assert results['overview'][key] == value @pytest.mark.tier2 - def test_positive_last_checkin_status(self, default_org, virtwho_config, form_data, session): + def test_positive_last_checkin_status( + self, default_org, virtwho_config_ui, form_data_ui, org_session + ): """Verify the Last Checkin status on Content Hosts Page. :id: 7448d482-d05c-4727-8980-176586e9e4a7 @@ -676,15 +644,15 @@ def test_positive_last_checkin_status(self, default_org, virtwho_config, form_da :CaseImportance: Medium """ - name = form_data['name'] - values = session.virtwho_configure.read(name, widget_names='deploy.command') + name = form_data_ui['name'] + values = org_session.virtwho_configure.read(name, widget_names='deploy.command') command = values['deploy']['command'] hypervisor_name, guest_name = deploy_configure_by_command( - command, form_data['hypervisor_type'], debug=True, org=default_org.label + command, form_data_ui['hypervisor_type'], debug=True, org=default_org.label ) - time_now = session.browser.get_client_datetime() - assert session.virtwho_configure.search(name)[0]['Status'] == 'ok' - checkin_time = session.contenthost.search(hypervisor_name)[0]['Last Checkin'] + time_now = org_session.browser.get_client_datetime() + assert org_session.virtwho_configure.search(name)[0]['Status'] == 'ok' + checkin_time = org_session.contenthost.search(hypervisor_name)[0]['Last Checkin'] # 10 mins margin to check the Last Checkin time assert ( abs( @@ -698,7 +666,7 @@ def test_positive_last_checkin_status(self, default_org, virtwho_config, form_da @pytest.mark.tier2 def test_positive_deploy_configure_hypervisor_password_with_special_characters( - self, default_org, form_data, target_sat, session + self, default_org, form_data_ui, target_sat, org_session ): """Verify " hammer virt-who-config deploy hypervisor with special characters" @@ -715,12 +683,12 @@ def test_positive_deploy_configure_hypervisor_password_with_special_characters( :customerscenario: true """ name = gen_string('alpha') - form_data['name'] = name - with session: + form_data_ui['name'] = name + with org_session: # check the hypervisor password contains single quotes - form_data['hypervisor_content.password'] = "Tes't" - session.virtwho_configure.create(form_data) - values = session.virtwho_configure.read(name) + form_data_ui['hypervisor_content.password'] = "Tes't" + org_session.virtwho_configure.create(form_data_ui) + values = org_session.virtwho_configure.read(name) command = values['deploy']['command'] config_id = get_configure_id(name) deploy_status = deploy_configure_by_command_check(command) @@ -731,12 +699,12 @@ def test_positive_deploy_configure_hypervisor_password_with_special_characters( get_configure_option('username', config_file) == settings.virtwho.esx.hypervisor_username ) - session.virtwho_configure.delete(name) - assert not session.virtwho_configure.search(name) + org_session.virtwho_configure.delete(name) + assert not org_session.virtwho_configure.search(name) # check the hypervisor password contains backtick - form_data['hypervisor_content.password'] = "my`password" - session.virtwho_configure.create(form_data) - values = session.virtwho_configure.read(name) + form_data_ui['hypervisor_content.password'] = "my`password" + org_session.virtwho_configure.create(form_data_ui) + values = org_session.virtwho_configure.read(name) command = values['deploy']['command'] config_id = get_configure_id(name) deploy_status = deploy_configure_by_command_check(command) @@ -747,12 +715,12 @@ def test_positive_deploy_configure_hypervisor_password_with_special_characters( get_configure_option('username', config_file) == settings.virtwho.esx.hypervisor_username ) - session.virtwho_configure.delete(name) - assert not session.virtwho_configure.search(name) + org_session.virtwho_configure.delete(name) + assert not org_session.virtwho_configure.search(name) @pytest.mark.tier2 def test_positive_remove_env_option( - self, default_org, virtwho_config, form_data, target_sat, session + self, default_org, virtwho_config_ui, form_data_ui, target_sat, org_session ): """remove option 'env=' from the virt-who configuration file and without any error @@ -770,13 +738,13 @@ def test_positive_remove_env_option( :customerscenario: true """ - name = form_data['name'] - values = session.virtwho_configure.read(name) + name = form_data_ui['name'] + values = org_session.virtwho_configure.read(name) command = values['deploy']['command'] deploy_configure_by_command( - command, form_data['hypervisor_type'], debug=True, org=default_org.label + command, form_data_ui['hypervisor_type'], debug=True, org=default_org.label ) - assert session.virtwho_configure.search(name)[0]['Status'] == 'ok' + assert org_session.virtwho_configure.search(name)[0]['Status'] == 'ok' # Check the option "env=" should be removed from etc/virt-who.d/virt-who.conf option = "env" config_id = get_configure_id(name) diff --git a/tests/foreman/virtwho/ui/test_esx_sca.py b/tests/foreman/virtwho/ui/test_esx_sca.py index 207d2555b8b..2cafc008611 100644 --- a/tests/foreman/virtwho/ui/test_esx_sca.py +++ b/tests/foreman/virtwho/ui/test_esx_sca.py @@ -28,58 +28,23 @@ delete_configure_option, deploy_configure_by_command, deploy_configure_by_command_check, - deploy_configure_by_script, get_configure_command, get_configure_file, get_configure_id, get_configure_option, - get_guest_info, get_virtwho_status, restart_virtwho_service, update_configure_option, ) -@pytest.fixture() -def form_data(): - form = { - 'debug': True, - 'interval': 'Every hour', - 'hypervisor_id': 'hostname', - 'hypervisor_type': settings.virtwho.esx.hypervisor_type, - 'hypervisor_content.server': settings.virtwho.esx.hypervisor_server, - 'hypervisor_content.username': settings.virtwho.esx.hypervisor_username, - 'hypervisor_content.password': settings.virtwho.esx.hypervisor_password, - } - return form - - -@pytest.fixture(autouse=True) -def clean_host(form_data, target_sat): - guest_name, _ = get_guest_info(form_data['hypervisor_type']) - results = target_sat.api.Host().search(query={'search': guest_name}) - if results: - target_sat.api.Host(id=results[0].read_json()['id']).delete() - - -@pytest.fixture() -def virtwho_config(form_data, target_sat, session_sca): - name = gen_string('alpha') - form_data['name'] = name - with session_sca: - session_sca.virtwho_configure.create(form_data) - yield virtwho_config - session_sca.virtwho_configure.delete(name) - assert not session_sca.virtwho_configure.search(name) - - -@pytest.mark.usefixtures('clean_host') +@pytest.mark.delete_host class TestVirtwhoConfigforEsx: @pytest.mark.tier2 @pytest.mark.upgrade - @pytest.mark.parametrize('deploy_type', ['id', 'script']) + @pytest.mark.parametrize('deploy_type_ui', ['id', 'script'], indirect=True) def test_positive_deploy_configure_by_id_script( - self, module_sca_manifest_org, virtwho_config, session_sca, form_data, deploy_type + self, module_sca_manifest_org, org_session, form_data_ui, deploy_type_ui ): """Verify configure created and deployed with id. @@ -96,29 +61,11 @@ def test_positive_deploy_configure_by_id_script( :CaseImportance: High """ - name = form_data['name'] - values = session_sca.virtwho_configure.read(name) - if deploy_type == "id": - command = values['deploy']['command'] - deploy_configure_by_command( - command, - form_data['hypervisor_type'], - debug=True, - org=module_sca_manifest_org.label, - ) - elif deploy_type == "script": - script = values['deploy']['script'] - deploy_configure_by_script( - script, - form_data['hypervisor_type'], - debug=True, - org=module_sca_manifest_org.label, - ) - assert session_sca.virtwho_configure.search(name)[0]['Status'] == 'ok' + assert org_session.virtwho_configure.search(form_data_ui['name'])[0]['Status'] == 'ok' @pytest.mark.tier2 def test_positive_debug_option( - self, module_sca_manifest_org, virtwho_config, session_sca, form_data + self, module_sca_manifest_org, virtwho_config_ui, org_session, form_data_ui ): """Verify debug checkbox and the value changes of VIRTWHO_DEBUG @@ -132,24 +79,24 @@ def test_positive_debug_option( :CaseImportance: Medium """ - name = form_data['name'] + name = form_data_ui['name'] config_id = get_configure_id(name) config_command = get_configure_command(config_id, module_sca_manifest_org.name) deploy_configure_by_command( - config_command, form_data['hypervisor_type'], org=module_sca_manifest_org.label + config_command, form_data_ui['hypervisor_type'], org=module_sca_manifest_org.label ) assert get_configure_option('debug', ETC_VIRTWHO_CONFIG) == '1' - session_sca.virtwho_configure.edit(name, {'debug': False}) - results = session_sca.virtwho_configure.read(name) + org_session.virtwho_configure.edit(name, {'debug': False}) + results = org_session.virtwho_configure.read(name) assert results['overview']['debug'] is False deploy_configure_by_command( - config_command, form_data['hypervisor_type'], org=module_sca_manifest_org.label + config_command, form_data_ui['hypervisor_type'], org=module_sca_manifest_org.label ) assert get_configure_option('debug', ETC_VIRTWHO_CONFIG) == '0' @pytest.mark.tier2 def test_positive_interval_option( - self, module_sca_manifest_org, virtwho_config, session_sca, form_data + self, module_sca_manifest_org, virtwho_config_ui, org_session, form_data_ui ): """Verify interval dropdown options and the value changes of VIRTWHO_INTERVAL. @@ -163,7 +110,7 @@ def test_positive_interval_option( :CaseImportance: Medium """ - name = form_data['name'] + name = form_data_ui['name'] config_id = get_configure_id(name) config_command = get_configure_command(config_id, module_sca_manifest_org.name) intervals = { @@ -177,17 +124,17 @@ def test_positive_interval_option( 'Every 3 days': '259200', } for option, value in intervals.items(): - session_sca.virtwho_configure.edit(name, {'interval': option}) - results = session_sca.virtwho_configure.read(name) + org_session.virtwho_configure.edit(name, {'interval': option}) + results = org_session.virtwho_configure.read(name) assert results['overview']['interval'] == option deploy_configure_by_command( - config_command, form_data['hypervisor_type'], org=module_sca_manifest_org.label + config_command, form_data_ui['hypervisor_type'], org=module_sca_manifest_org.label ) assert get_configure_option('interval', ETC_VIRTWHO_CONFIG) == value @pytest.mark.tier2 def test_positive_hypervisor_id_option( - self, module_sca_manifest_org, virtwho_config, session_sca, form_data + self, module_sca_manifest_org, virtwho_config_ui, org_session, form_data_ui ): """Verify Hypervisor ID dropdown options. @@ -201,17 +148,17 @@ def test_positive_hypervisor_id_option( :CaseImportance: Medium """ - name = form_data['name'] + name = form_data_ui['name'] config_id = get_configure_id(name) config_command = get_configure_command(config_id, module_sca_manifest_org.name) config_file = get_configure_file(config_id) # esx and rhevm support hwuuid option for value in ['uuid', 'hostname', 'hwuuid']: - session_sca.virtwho_configure.edit(name, {'hypervisor_id': value}) - results = session_sca.virtwho_configure.read(name) + org_session.virtwho_configure.edit(name, {'hypervisor_id': value}) + results = org_session.virtwho_configure.read(name) assert results['overview']['hypervisor_id'] == value deploy_configure_by_command( - config_command, form_data['hypervisor_type'], org=module_sca_manifest_org.label + config_command, form_data_ui['hypervisor_type'], org=module_sca_manifest_org.label ) assert get_configure_option('hypervisor_id', config_file) == value @@ -219,7 +166,7 @@ def test_positive_hypervisor_id_option( @pytest.mark.parametrize('filter_type', ['whitelist', 'blacklist']) @pytest.mark.parametrize('option_type', ['edit', 'create']) def test_positive_filtering_option( - self, module_sca_manifest_org, session_sca, form_data, filter_type, option_type + self, module_sca_manifest_org, org_session, form_data_ui, filter_type, option_type ): """Verify Filtering dropdown options. @@ -243,11 +190,11 @@ def test_positive_filtering_option( :customerscenario: true """ name = gen_string('alpha') - form_data['name'] = name + form_data_ui['name'] = name regex = '.*redhat.com' - with session_sca: + with org_session: if option_type == "edit": - session_sca.virtwho_configure.create(form_data) + org_session.virtwho_configure.create(form_data_ui) config_id = get_configure_id(name) config_command = get_configure_command(config_id, module_sca_manifest_org.name) config_file = get_configure_file(config_id) @@ -256,19 +203,21 @@ def test_positive_filtering_option( # esx support filter-host-parents and exclude-host-parents options whitelist['filtering_content.filter_host_parents'] = regex # Update Whitelist and check the result - session_sca.virtwho_configure.edit(name, whitelist) - results = session_sca.virtwho_configure.read(name) + org_session.virtwho_configure.edit(name, whitelist) + results = org_session.virtwho_configure.read(name) assert results['overview']['filter_hosts'] == regex assert results['overview']['filter_host_parents'] == regex elif filter_type == "blacklist": blacklist = {'filtering': 'Blacklist', 'filtering_content.exclude_hosts': regex} blacklist['filtering_content.exclude_host_parents'] = regex - session_sca.virtwho_configure.edit(name, blacklist) - results = session_sca.virtwho_configure.read(name) + org_session.virtwho_configure.edit(name, blacklist) + results = org_session.virtwho_configure.read(name) assert results['overview']['exclude_hosts'] == regex assert results['overview']['exclude_host_parents'] == regex deploy_configure_by_command( - config_command, form_data['hypervisor_type'], org=module_sca_manifest_org.label + config_command, + form_data_ui['hypervisor_type'], + org=module_sca_manifest_org.label, ) if filter_type == "whitelist": assert regex == get_configure_option('filter_hosts', config_file) @@ -276,25 +225,25 @@ def test_positive_filtering_option( elif filter_type == "blacklist": assert regex == get_configure_option('exclude_hosts', config_file) assert regex == get_configure_option('exclude_host_parents', config_file) - session_sca.virtwho_configure.delete(name) - assert not session_sca.virtwho_configure.search(name) + org_session.virtwho_configure.delete(name) + assert not org_session.virtwho_configure.search(name) elif option_type == "create": if filter_type == "whitelist": - form_data['filtering'] = "Whitelist" - form_data['filtering_content.filter_hosts'] = regex - form_data['filtering_content.filter_host_parents'] = regex + form_data_ui['filtering'] = "Whitelist" + form_data_ui['filtering_content.filter_hosts'] = regex + form_data_ui['filtering_content.filter_host_parents'] = regex elif filter_type == "blacklist": - form_data['filtering'] = "Blacklist" - form_data['filtering_content.exclude_hosts'] = regex - form_data['filtering_content.exclude_host_parents'] = regex - session_sca.virtwho_configure.create(form_data) + form_data_ui['filtering'] = "Blacklist" + form_data_ui['filtering_content.exclude_hosts'] = regex + form_data_ui['filtering_content.exclude_host_parents'] = regex + org_session.virtwho_configure.create(form_data_ui) config_id = get_configure_id(name) command = get_configure_command(config_id, module_sca_manifest_org.name) deploy_configure_by_command( - command, form_data['hypervisor_type'], org=module_sca_manifest_org.label + command, form_data_ui['hypervisor_type'], org=module_sca_manifest_org.label ) config_file = get_configure_file(config_id) - results = session_sca.virtwho_configure.read(name) + results = org_session.virtwho_configure.read(name) if filter_type == "whitelist": assert results['overview']['filter_hosts'] == regex assert results['overview']['filter_host_parents'] == regex @@ -308,7 +257,7 @@ def test_positive_filtering_option( @pytest.mark.tier2 def test_positive_last_checkin_status( - self, module_sca_manifest_org, virtwho_config, form_data, session_sca + self, module_sca_manifest_org, virtwho_config_ui, form_data_ui, org_session ): """Verify the Last Checkin status on Content Hosts Page. @@ -324,15 +273,15 @@ def test_positive_last_checkin_status( :CaseImportance: Medium """ - name = form_data['name'] - values = session_sca.virtwho_configure.read(name, widget_names='deploy.command') + name = form_data_ui['name'] + values = org_session.virtwho_configure.read(name, widget_names='deploy.command') command = values['deploy']['command'] hypervisor_name, guest_name = deploy_configure_by_command( - command, form_data['hypervisor_type'], debug=True, org=module_sca_manifest_org.label + command, form_data_ui['hypervisor_type'], debug=True, org=module_sca_manifest_org.label ) - time_now = session_sca.browser.get_client_datetime() - assert session_sca.virtwho_configure.search(name)[0]['Status'] == 'ok' - checkin_time = session_sca.contenthost.search(hypervisor_name)[0]['Last Checkin'] + time_now = org_session.browser.get_client_datetime() + assert org_session.virtwho_configure.search(name)[0]['Status'] == 'ok' + checkin_time = org_session.contenthost.search(hypervisor_name)[0]['Last Checkin'] # 10 mins margin to check the Last Checkin time assert ( abs( @@ -346,7 +295,7 @@ def test_positive_last_checkin_status( @pytest.mark.tier2 def test_positive_remove_env_option( - self, module_sca_manifest_org, virtwho_config, form_data, target_sat, session_sca + self, module_sca_manifest_org, virtwho_config_ui, form_data_ui, target_sat, org_session ): """remove option 'env=' from the virt-who configuration file and without any error @@ -364,13 +313,13 @@ def test_positive_remove_env_option( :customerscenario: true """ - name = form_data['name'] - values = session_sca.virtwho_configure.read(name) + name = form_data_ui['name'] + values = org_session.virtwho_configure.read(name) command = values['deploy']['command'] deploy_configure_by_command( - command, form_data['hypervisor_type'], debug=True, org=module_sca_manifest_org.label + command, form_data_ui['hypervisor_type'], debug=True, org=module_sca_manifest_org.label ) - assert session_sca.virtwho_configure.search(name)[0]['Status'] == 'ok' + assert org_session.virtwho_configure.search(name)[0]['Status'] == 'ok' # Check the option "env=" should be removed from etc/virt-who.d/virt-who.conf option = "env" config_id = get_configure_id(name) @@ -388,7 +337,7 @@ def test_positive_remove_env_option( assert result.status == 1 @pytest.mark.tier2 - def test_positive_virtwho_roles(self, session_sca): + def test_positive_virtwho_roles(self, org_session): """Verify the default roles for virtwho configure :id: 3c2501d5-c122-49f0-baa4-4c0d678cb6fc @@ -416,14 +365,14 @@ def test_positive_virtwho_roles(self, session_sca): }, 'Virt-who Viewer': {'Satellite virt who configure/config': ['view_virt_who_config']}, } - with session_sca: + with org_session: for role_name, role_filters in roles.items(): - assert session_sca.role.search(role_name)[0]['Name'] == role_name - assigned_permissions = session_sca.filter.read_permissions(role_name) + assert org_session.role.search(role_name)[0]['Name'] == role_name + assigned_permissions = org_session.filter.read_permissions(role_name) assert sorted(assigned_permissions) == sorted(role_filters) @pytest.mark.tier2 - def test_positive_delete_configure(self, module_sca_manifest_org, session_sca, form_data): + def test_positive_delete_configure(self, module_sca_manifest_org, org_session, form_data_ui): """Verify when a config is deleted the associated user is deleted. :id: efc7253d-f455-4dc3-ae03-3ed5e215bd11 @@ -442,23 +391,23 @@ def test_positive_delete_configure(self, module_sca_manifest_org, session_sca, f :CaseImportance: Low """ name = gen_string('alpha') - form_data['name'] = name - with session_sca: - session_sca.virtwho_configure.create(form_data) + form_data_ui['name'] = name + with org_session: + org_session.virtwho_configure.create(form_data_ui) config_id = get_configure_id(name) config_command = get_configure_command(config_id, module_sca_manifest_org.name) deploy_configure_by_command( - config_command, form_data['hypervisor_type'], org=module_sca_manifest_org.label + config_command, form_data_ui['hypervisor_type'], org=module_sca_manifest_org.label ) - assert session_sca.virtwho_configure.search(name)[0]['Status'] == 'ok' - session_sca.virtwho_configure.delete(name) - assert not session_sca.virtwho_configure.search(name) + assert org_session.virtwho_configure.search(name)[0]['Status'] == 'ok' + org_session.virtwho_configure.delete(name) + assert not org_session.virtwho_configure.search(name) restart_virtwho_service() assert get_virtwho_status() == 'logerror' @pytest.mark.tier2 def test_positive_virtwho_reporter_role( - self, module_sca_manifest_org, session_sca, test_name, form_data + self, module_sca_manifest_org, org_session, test_name, form_data_ui ): """Verify the virt-who reporter role can TRULY work. @@ -476,9 +425,9 @@ def test_positive_virtwho_reporter_role( username = gen_string('alpha') password = gen_string('alpha') config_name = gen_string('alpha') - with session_sca: + with org_session: # Create an user - session_sca.user.create( + org_session.user.create( { 'user.login': username, 'user.mail': valid_emails_list()[0], @@ -488,14 +437,14 @@ def test_positive_virtwho_reporter_role( } ) # Create a virt-who config plugin - form_data['name'] = config_name - session_sca.virtwho_configure.create(form_data) - values = session_sca.virtwho_configure.read(config_name) + form_data_ui['name'] = config_name + org_session.virtwho_configure.create(form_data_ui) + values = org_session.virtwho_configure.read(config_name) command = values['deploy']['command'] deploy_configure_by_command( - command, form_data['hypervisor_type'], org=module_sca_manifest_org.label + command, form_data_ui['hypervisor_type'], org=module_sca_manifest_org.label ) - assert session_sca.virtwho_configure.search(config_name)[0]['Status'] == 'ok' + assert org_session.virtwho_configure.search(config_name)[0]['Status'] == 'ok' # Update the virt-who config file config_id = get_configure_id(config_name) config_file = get_configure_file(config_id) @@ -505,20 +454,20 @@ def test_positive_virtwho_reporter_role( restart_virtwho_service() assert get_virtwho_status() == 'logerror' # Check the permissioin of Virt-who Reporter - session_sca.user.update(username, {'roles.resources.assigned': ['Virt-who Reporter']}) - assert session_sca.user.search(username)[0]['Username'] == username - user = session_sca.user.read(username) + org_session.user.update(username, {'roles.resources.assigned': ['Virt-who Reporter']}) + assert org_session.user.search(username)[0]['Username'] == username + user = org_session.user.read(username) assert user['roles']['resources']['assigned'] == ['Virt-who Reporter'] restart_virtwho_service() assert get_virtwho_status() == 'running' with Session(test_name, username, password) as newsession: assert not newsession.virtwho_configure.check_create_permission()['can_view'] - session_sca.user.delete(username) - assert not session_sca.user.search(username) + org_session.user.delete(username) + assert not org_session.user.search(username) @pytest.mark.tier2 def test_positive_virtwho_viewer_role( - self, module_sca_manifest_org, session_sca, test_name, form_data + self, module_sca_manifest_org, org_session, test_name, form_data_ui ): """Verify the virt-who viewer role can TRULY work. @@ -536,9 +485,9 @@ def test_positive_virtwho_viewer_role( username = gen_string('alpha') password = gen_string('alpha') config_name = gen_string('alpha') - with session_sca: + with org_session: # Create an user - session_sca.user.create( + org_session.user.create( { 'user.login': username, 'user.mail': valid_emails_list()[0], @@ -548,17 +497,17 @@ def test_positive_virtwho_viewer_role( } ) # Create a virt-who config plugin - form_data['name'] = config_name - session_sca.virtwho_configure.create(form_data) - values = session_sca.virtwho_configure.read(config_name) + form_data_ui['name'] = config_name + org_session.virtwho_configure.create(form_data_ui) + values = org_session.virtwho_configure.read(config_name) command = values['deploy']['command'] deploy_configure_by_command( - command, form_data['hypervisor_type'], org=module_sca_manifest_org.label + command, form_data_ui['hypervisor_type'], org=module_sca_manifest_org.label ) - assert session_sca.virtwho_configure.search(config_name)[0]['Status'] == 'ok' + assert org_session.virtwho_configure.search(config_name)[0]['Status'] == 'ok' # Check the permissioin of Virt-who Viewer - session_sca.user.update(username, {'roles.resources.assigned': ['Virt-who Viewer']}) - user = session_sca.user.read(username) + org_session.user.update(username, {'roles.resources.assigned': ['Virt-who Viewer']}) + user = org_session.user.read(username) assert user['roles']['resources']['assigned'] == ['Virt-who Viewer'] # Update the virt-who config file config_id = get_configure_id(config_name) @@ -579,12 +528,12 @@ def test_positive_virtwho_viewer_role( assert not update_permission['can_edit'] newsession.virtwho_configure.read(config_name) # Delete the created user - session_sca.user.delete(username) - assert not session_sca.user.search(username) + org_session.user.delete(username) + assert not org_session.user.search(username) @pytest.mark.tier2 def test_positive_virtwho_manager_role( - self, module_sca_manifest_org, session_sca, test_name, form_data + self, module_sca_manifest_org, org_session, test_name, form_data_ui ): """Verify the virt-who manager role can TRULY work. @@ -600,9 +549,9 @@ def test_positive_virtwho_manager_role( username = gen_string('alpha') password = gen_string('alpha') config_name = gen_string('alpha') - with session_sca: + with org_session: # Create an user - session_sca.user.create( + org_session.user.create( { 'user.login': username, 'user.mail': valid_emails_list()[0], @@ -612,28 +561,28 @@ def test_positive_virtwho_manager_role( } ) # Create a virt-who config plugin - form_data['name'] = config_name - session_sca.virtwho_configure.create(form_data) - values = session_sca.virtwho_configure.read(config_name) + form_data_ui['name'] = config_name + org_session.virtwho_configure.create(form_data_ui) + values = org_session.virtwho_configure.read(config_name) command = values['deploy']['command'] deploy_configure_by_command( - command, form_data['hypervisor_type'], org=module_sca_manifest_org.label + command, form_data_ui['hypervisor_type'], org=module_sca_manifest_org.label ) - assert session_sca.virtwho_configure.search(config_name)[0]['Status'] == 'ok' + assert org_session.virtwho_configure.search(config_name)[0]['Status'] == 'ok' # Check the permissioin of Virt-who Manager - session_sca.user.update(username, {'roles.resources.assigned': ['Virt-who Manager']}) - user = session_sca.user.read(username) + org_session.user.update(username, {'roles.resources.assigned': ['Virt-who Manager']}) + user = org_session.user.read(username) assert user['roles']['resources']['assigned'] == ['Virt-who Manager'] with Session(test_name, username, password) as newsession: # create_virt_who_config new_virt_who_name = gen_string('alpha') - form_data['name'] = new_virt_who_name - newsession.virtwho_configure.create(form_data) + form_data_ui['name'] = new_virt_who_name + newsession.virtwho_configure.create(form_data_ui) # view_virt_who_config values = newsession.virtwho_configure.read(new_virt_who_name) command = values['deploy']['command'] deploy_configure_by_command( - command, form_data['hypervisor_type'], org=module_sca_manifest_org.label + command, form_data_ui['hypervisor_type'], org=module_sca_manifest_org.label ) assert newsession.virtwho_configure.search(new_virt_who_name)[0]['Status'] == 'ok' # edit_virt_who_config @@ -644,12 +593,12 @@ def test_positive_virtwho_manager_role( newsession.virtwho_configure.delete(modify_name) assert not newsession.virtwho_configure.search(modify_name) # Delete the created user - session_sca.user.delete(username) - assert not session_sca.user.search(username) + org_session.user.delete(username) + assert not org_session.user.search(username) @pytest.mark.tier2 def test_positive_deploy_configure_hypervisor_password_with_special_characters( - self, module_sca_manifest_org, form_data, target_sat, session_sca + self, module_sca_manifest_org, form_data_ui, target_sat, org_session ): """Verify " hammer virt-who-config deploy hypervisor with special characters" @@ -666,12 +615,12 @@ def test_positive_deploy_configure_hypervisor_password_with_special_characters( :customerscenario: true """ name = gen_string('alpha') - form_data['name'] = name - with session_sca: + form_data_ui['name'] = name + with org_session: # check the hypervisor password contains single quotes - form_data['hypervisor_content.password'] = "Tes't" - session_sca.virtwho_configure.create(form_data) - values = session_sca.virtwho_configure.read(name) + form_data_ui['hypervisor_content.password'] = "Tes't" + org_session.virtwho_configure.create(form_data_ui) + values = org_session.virtwho_configure.read(name) command = values['deploy']['command'] config_id = get_configure_id(name) deploy_status = deploy_configure_by_command_check(command) @@ -682,12 +631,12 @@ def test_positive_deploy_configure_hypervisor_password_with_special_characters( get_configure_option('username', config_file) == settings.virtwho.esx.hypervisor_username ) - session_sca.virtwho_configure.delete(name) - assert not session_sca.virtwho_configure.search(name) + org_session.virtwho_configure.delete(name) + assert not org_session.virtwho_configure.search(name) # check the hypervisor password contains backtick - form_data['hypervisor_content.password'] = "my`password" - session_sca.virtwho_configure.create(form_data) - values = session_sca.virtwho_configure.read(name) + form_data_ui['hypervisor_content.password'] = "my`password" + org_session.virtwho_configure.create(form_data_ui) + values = org_session.virtwho_configure.read(name) command = values['deploy']['command'] config_id = get_configure_id(name) deploy_status = deploy_configure_by_command_check(command) @@ -698,5 +647,5 @@ def test_positive_deploy_configure_hypervisor_password_with_special_characters( get_configure_option('username', config_file) == settings.virtwho.esx.hypervisor_username ) - session_sca.virtwho_configure.delete(name) - assert not session_sca.virtwho_configure.search(name) + org_session.virtwho_configure.delete(name) + assert not org_session.virtwho_configure.search(name) diff --git a/tests/foreman/virtwho/ui/test_hyperv.py b/tests/foreman/virtwho/ui/test_hyperv.py index 56c2bbdb476..a35878e2fc2 100644 --- a/tests/foreman/virtwho/ui/test_hyperv.py +++ b/tests/foreman/virtwho/ui/test_hyperv.py @@ -16,13 +16,11 @@ :Upstream: No """ -from fauxfactory import gen_string import pytest from robottelo.config import settings from robottelo.utils.virtwho import ( deploy_configure_by_command, - deploy_configure_by_script, get_configure_command, get_configure_file, get_configure_id, @@ -30,36 +28,11 @@ ) -@pytest.fixture() -def form_data(): - form = { - 'debug': True, - 'interval': 'Every hour', - 'hypervisor_id': 'hostname', - 'hypervisor_type': settings.virtwho.hyperv.hypervisor_type, - 'hypervisor_content.server': settings.virtwho.hyperv.hypervisor_server, - 'hypervisor_content.username': settings.virtwho.hyperv.hypervisor_username, - 'hypervisor_content.password': settings.virtwho.hyperv.hypervisor_password, - } - return form - - -@pytest.fixture() -def virtwho_config(form_data, target_sat, session): - name = gen_string('alpha') - form_data['name'] = name - with session: - session.virtwho_configure.create(form_data) - yield virtwho_config - session.virtwho_configure.delete(name) - assert not session.virtwho_configure.search(name) - - class TestVirtwhoConfigforHyperv: @pytest.mark.tier2 - @pytest.mark.parametrize('deploy_type', ['id', 'script']) + @pytest.mark.parametrize('deploy_type_ui', ['id', 'script'], indirect=True) def test_positive_deploy_configure_by_id_script( - self, default_org, virtwho_config, session, form_data, deploy_type + self, default_org, org_session, form_data_ui, deploy_type_ui ): """Verify configure created and deployed with id. @@ -76,37 +49,30 @@ def test_positive_deploy_configure_by_id_script( :CaseImportance: High """ - name = form_data['name'] - values = session.virtwho_configure.read(name) - if deploy_type == "id": - command = values['deploy']['command'] - hypervisor_name, guest_name = deploy_configure_by_command( - command, form_data['hypervisor_type'], debug=True, org=default_org.label - ) - elif deploy_type == "script": - script = values['deploy']['script'] - hypervisor_name, guest_name = deploy_configure_by_script( - script, form_data['hypervisor_type'], debug=True, org=default_org.label - ) - assert session.virtwho_configure.search(name)[0]['Status'] == 'ok' - hypervisor_display_name = session.contenthost.search(hypervisor_name)[0]['Name'] + hypervisor_name, guest_name = deploy_type_ui + assert org_session.virtwho_configure.search(form_data_ui['name'])[0]['Status'] == 'ok' + hypervisor_display_name = org_session.contenthost.search(hypervisor_name)[0]['Name'] vdc_physical = f'product_id = {settings.virtwho.sku.vdc_physical} and type=NORMAL' vdc_virtual = f'product_id = {settings.virtwho.sku.vdc_physical} and type=STACK_DERIVED' assert ( - session.contenthost.read_legacy_ui(hypervisor_display_name)['subscriptions']['status'] + org_session.contenthost.read_legacy_ui(hypervisor_display_name)['subscriptions'][ + 'status' + ] == 'Unsubscribed hypervisor' ) - session.contenthost.add_subscription(hypervisor_display_name, vdc_physical) - assert session.contenthost.search(hypervisor_name)[0]['Subscription Status'] == 'green' + org_session.contenthost.add_subscription(hypervisor_display_name, vdc_physical) + assert org_session.contenthost.search(hypervisor_name)[0]['Subscription Status'] == 'green' assert ( - session.contenthost.read_legacy_ui(guest_name)['subscriptions']['status'] + org_session.contenthost.read_legacy_ui(guest_name)['subscriptions']['status'] == 'Unentitled' ) - session.contenthost.add_subscription(guest_name, vdc_virtual) - assert session.contenthost.search(guest_name)[0]['Subscription Status'] == 'green' + org_session.contenthost.add_subscription(guest_name, vdc_virtual) + assert org_session.contenthost.search(guest_name)[0]['Subscription Status'] == 'green' @pytest.mark.tier2 - def test_positive_hypervisor_id_option(self, default_org, virtwho_config, session, form_data): + def test_positive_hypervisor_id_option( + self, default_org, virtwho_config_ui, org_session, form_data_ui + ): """Verify Hypervisor ID dropdown options. :id: f2efc018-d57e-4dc5-895e-53af320237de @@ -119,16 +85,16 @@ def test_positive_hypervisor_id_option(self, default_org, virtwho_config, sessio :CaseImportance: Medium """ - name = form_data['name'] + name = form_data_ui['name'] config_id = get_configure_id(name) config_command = get_configure_command(config_id, default_org.name) config_file = get_configure_file(config_id) values = ['uuid', 'hostname'] for value in values: - session.virtwho_configure.edit(name, {'hypervisor_id': value}) - results = session.virtwho_configure.read(name) + org_session.virtwho_configure.edit(name, {'hypervisor_id': value}) + results = org_session.virtwho_configure.read(name) assert results['overview']['hypervisor_id'] == value deploy_configure_by_command( - config_command, form_data['hypervisor_type'], org=default_org.label + config_command, form_data_ui['hypervisor_type'], org=default_org.label ) assert get_configure_option('hypervisor_id', config_file) == value diff --git a/tests/foreman/virtwho/ui/test_hyperv_sca.py b/tests/foreman/virtwho/ui/test_hyperv_sca.py index 2db82168046..867d5097b70 100644 --- a/tests/foreman/virtwho/ui/test_hyperv_sca.py +++ b/tests/foreman/virtwho/ui/test_hyperv_sca.py @@ -14,13 +14,10 @@ :Upstream: No """ -from fauxfactory import gen_string import pytest -from robottelo.config import settings from robottelo.utils.virtwho import ( deploy_configure_by_command, - deploy_configure_by_script, get_configure_command, get_configure_file, get_configure_id, @@ -28,36 +25,11 @@ ) -@pytest.fixture() -def form_data(): - form = { - 'debug': True, - 'interval': 'Every hour', - 'hypervisor_id': 'hostname', - 'hypervisor_type': settings.virtwho.hyperv.hypervisor_type, - 'hypervisor_content.server': settings.virtwho.hyperv.hypervisor_server, - 'hypervisor_content.username': settings.virtwho.hyperv.hypervisor_username, - 'hypervisor_content.password': settings.virtwho.hyperv.hypervisor_password, - } - return form - - -@pytest.fixture() -def virtwho_config(form_data, target_sat, session_sca): - name = gen_string('alpha') - form_data['name'] = name - with session_sca: - session_sca.virtwho_configure.create(form_data) - yield virtwho_config - session_sca.virtwho_configure.delete(name) - assert not session_sca.virtwho_configure.search(name) - - class TestVirtwhoConfigforHyperv: @pytest.mark.tier2 - @pytest.mark.parametrize('deploy_type', ['id', 'script']) + @pytest.mark.parametrize('deploy_type_ui', ['id', 'script'], indirect=True) def test_positive_deploy_configure_by_id_script( - self, module_sca_manifest_org, virtwho_config, session_sca, form_data, deploy_type + self, module_sca_manifest_org, org_session, form_data_ui, deploy_type_ui ): """Verify configure created and deployed with id. @@ -74,29 +46,11 @@ def test_positive_deploy_configure_by_id_script( :CaseImportance: High """ - name = form_data['name'] - values = session_sca.virtwho_configure.read(name) - if deploy_type == "id": - command = values['deploy']['command'] - deploy_configure_by_command( - command, - form_data['hypervisor_type'], - debug=True, - org=module_sca_manifest_org.label, - ) - elif deploy_type == "script": - script = values['deploy']['script'] - deploy_configure_by_script( - script, - form_data['hypervisor_type'], - debug=True, - org=module_sca_manifest_org.label, - ) - assert session_sca.virtwho_configure.search(name)[0]['Status'] == 'ok' + assert org_session.virtwho_configure.search(form_data_ui['name'])[0]['Status'] == 'ok' @pytest.mark.tier2 def test_positive_hypervisor_id_option( - self, module_sca_manifest_org, virtwho_config, session_sca, form_data + self, module_sca_manifest_org, virtwho_config_ui, org_session, form_data_ui ): """Verify Hypervisor ID dropdown options. @@ -110,16 +64,16 @@ def test_positive_hypervisor_id_option( :CaseImportance: Medium """ - name = form_data['name'] + name = form_data_ui['name'] config_id = get_configure_id(name) config_command = get_configure_command(config_id, module_sca_manifest_org.name) config_file = get_configure_file(config_id) values = ['uuid', 'hostname'] for value in values: - session_sca.virtwho_configure.edit(name, {'hypervisor_id': value}) - results = session_sca.virtwho_configure.read(name) + org_session.virtwho_configure.edit(name, {'hypervisor_id': value}) + results = org_session.virtwho_configure.read(name) assert results['overview']['hypervisor_id'] == value deploy_configure_by_command( - config_command, form_data['hypervisor_type'], org=module_sca_manifest_org.label + config_command, form_data_ui['hypervisor_type'], org=module_sca_manifest_org.label ) assert get_configure_option('hypervisor_id', config_file) == value diff --git a/tests/foreman/virtwho/ui/test_kubevirt.py b/tests/foreman/virtwho/ui/test_kubevirt.py index 289e4f385f1..19d5bce7f63 100644 --- a/tests/foreman/virtwho/ui/test_kubevirt.py +++ b/tests/foreman/virtwho/ui/test_kubevirt.py @@ -16,13 +16,11 @@ :Upstream: No """ -from fauxfactory import gen_string import pytest from robottelo.config import settings from robottelo.utils.virtwho import ( deploy_configure_by_command, - deploy_configure_by_script, get_configure_command, get_configure_file, get_configure_id, @@ -30,34 +28,11 @@ ) -@pytest.fixture() -def form_data(): - form = { - 'debug': True, - 'interval': 'Every hour', - 'hypervisor_id': 'hostname', - 'hypervisor_type': settings.virtwho.kubevirt.hypervisor_type, - 'hypervisor_content.kubeconfig': settings.virtwho.kubevirt.hypervisor_config_file, - } - return form - - -@pytest.fixture() -def virtwho_config(form_data, target_sat, session): - name = gen_string('alpha') - form_data['name'] = name - with session: - session.virtwho_configure.create(form_data) - yield virtwho_config - session.virtwho_configure.delete(name) - assert not session.virtwho_configure.search(name) - - class TestVirtwhoConfigforKubevirt: @pytest.mark.tier2 - @pytest.mark.parametrize('deploy_type', ['id', 'script']) + @pytest.mark.parametrize('deploy_type_ui', ['id', 'script'], indirect=True) def test_positive_deploy_configure_by_id_script( - self, default_org, virtwho_config, session, form_data, deploy_type + self, default_org, org_session, form_data_ui, deploy_type_ui ): """Verify configure created and deployed with id. @@ -74,37 +49,30 @@ def test_positive_deploy_configure_by_id_script( :CaseImportance: High """ - name = form_data['name'] - values = session.virtwho_configure.read(name) - if deploy_type == "id": - command = values['deploy']['command'] - hypervisor_name, guest_name = deploy_configure_by_command( - command, form_data['hypervisor_type'], debug=True, org=default_org.label - ) - elif deploy_type == "script": - script = values['deploy']['script'] - hypervisor_name, guest_name = deploy_configure_by_script( - script, form_data['hypervisor_type'], debug=True, org=default_org.label - ) - assert session.virtwho_configure.search(name)[0]['Status'] == 'ok' - hypervisor_display_name = session.contenthost.search(hypervisor_name)[0]['Name'] + hypervisor_name, guest_name = deploy_type_ui + assert org_session.virtwho_configure.search(form_data_ui['name'])[0]['Status'] == 'ok' + hypervisor_display_name = org_session.contenthost.search(hypervisor_name)[0]['Name'] vdc_physical = f'product_id = {settings.virtwho.sku.vdc_physical} and type=NORMAL' vdc_virtual = f'product_id = {settings.virtwho.sku.vdc_physical} and type=STACK_DERIVED' assert ( - session.contenthost.read_legacy_ui(hypervisor_display_name)['subscriptions']['status'] + org_session.contenthost.read_legacy_ui(hypervisor_display_name)['subscriptions'][ + 'status' + ] == 'Unsubscribed hypervisor' ) - session.contenthost.add_subscription(hypervisor_display_name, vdc_physical) - assert session.contenthost.search(hypervisor_name)[0]['Subscription Status'] == 'green' + org_session.contenthost.add_subscription(hypervisor_display_name, vdc_physical) + assert org_session.contenthost.search(hypervisor_name)[0]['Subscription Status'] == 'green' assert ( - session.contenthost.read_legacy_ui(guest_name)['subscriptions']['status'] + org_session.contenthost.read_legacy_ui(guest_name)['subscriptions']['status'] == 'Unentitled' ) - session.contenthost.add_subscription(guest_name, vdc_virtual) - assert session.contenthost.search(guest_name)[0]['Subscription Status'] == 'green' + org_session.contenthost.add_subscription(guest_name, vdc_virtual) + assert org_session.contenthost.search(guest_name)[0]['Subscription Status'] == 'green' @pytest.mark.tier2 - def test_positive_hypervisor_id_option(self, default_org, virtwho_config, session, form_data): + def test_positive_hypervisor_id_option( + self, default_org, virtwho_config_ui, org_session, form_data_ui + ): """Verify Hypervisor ID dropdown options. :id: 09826cc0-aa49-4355-8980-8097511eb7d7 @@ -117,16 +85,16 @@ def test_positive_hypervisor_id_option(self, default_org, virtwho_config, sessio :CaseImportance: Medium """ - name = form_data['name'] + name = form_data_ui['name'] config_id = get_configure_id(name) config_command = get_configure_command(config_id, default_org.name) config_file = get_configure_file(config_id) values = ['uuid', 'hostname'] for value in values: - session.virtwho_configure.edit(name, {'hypervisor_id': value}) - results = session.virtwho_configure.read(name) + org_session.virtwho_configure.edit(name, {'hypervisor_id': value}) + results = org_session.virtwho_configure.read(name) assert results['overview']['hypervisor_id'] == value deploy_configure_by_command( - config_command, form_data['hypervisor_type'], org=default_org.label + config_command, form_data_ui['hypervisor_type'], org=default_org.label ) assert get_configure_option('hypervisor_id', config_file) == value diff --git a/tests/foreman/virtwho/ui/test_kubevirt_sca.py b/tests/foreman/virtwho/ui/test_kubevirt_sca.py index f90c94dd692..a29aac27e56 100644 --- a/tests/foreman/virtwho/ui/test_kubevirt_sca.py +++ b/tests/foreman/virtwho/ui/test_kubevirt_sca.py @@ -14,13 +14,10 @@ :Upstream: No """ -from fauxfactory import gen_string import pytest -from robottelo.config import settings from robottelo.utils.virtwho import ( deploy_configure_by_command, - deploy_configure_by_script, get_configure_command, get_configure_file, get_configure_id, @@ -28,34 +25,11 @@ ) -@pytest.fixture() -def form_data(): - form = { - 'debug': True, - 'interval': 'Every hour', - 'hypervisor_id': 'hostname', - 'hypervisor_type': settings.virtwho.kubevirt.hypervisor_type, - 'hypervisor_content.kubeconfig': settings.virtwho.kubevirt.hypervisor_config_file, - } - return form - - -@pytest.fixture() -def virtwho_config(form_data, target_sat, session_sca): - name = gen_string('alpha') - form_data['name'] = name - with session_sca: - session_sca.virtwho_configure.create(form_data) - yield virtwho_config - session_sca.virtwho_configure.delete(name) - assert not session_sca.virtwho_configure.search(name) - - class TestVirtwhoConfigforKubevirt: @pytest.mark.tier2 - @pytest.mark.parametrize('deploy_type', ['id', 'script']) + @pytest.mark.parametrize('deploy_type_ui', ['id', 'script'], indirect=True) def test_positive_deploy_configure_by_id_script( - self, module_sca_manifest_org, virtwho_config, session_sca, form_data, deploy_type + self, module_sca_manifest_org, org_session, form_data_ui, deploy_type_ui ): """Verify configure created and deployed with id. @@ -72,29 +46,11 @@ def test_positive_deploy_configure_by_id_script( :CaseImportance: High """ - name = form_data['name'] - values = session_sca.virtwho_configure.read(name) - if deploy_type == "id": - command = values['deploy']['command'] - deploy_configure_by_command( - command, - form_data['hypervisor_type'], - debug=True, - org=module_sca_manifest_org.label, - ) - elif deploy_type == "script": - script = values['deploy']['script'] - deploy_configure_by_script( - script, - form_data['hypervisor_type'], - debug=True, - org=module_sca_manifest_org.label, - ) - assert session_sca.virtwho_configure.search(name)[0]['Status'] == 'ok' + assert org_session.virtwho_configure.search(form_data_ui['name'])[0]['Status'] == 'ok' @pytest.mark.tier2 def test_positive_hypervisor_id_option( - self, module_sca_manifest_org, virtwho_config, session_sca, form_data + self, module_sca_manifest_org, virtwho_config_ui, org_session, form_data_ui ): """Verify Hypervisor ID dropdown options. @@ -108,16 +64,16 @@ def test_positive_hypervisor_id_option( :CaseImportance: Medium """ - name = form_data['name'] + name = form_data_ui['name'] config_id = get_configure_id(name) config_command = get_configure_command(config_id, module_sca_manifest_org.name) config_file = get_configure_file(config_id) values = ['uuid', 'hostname'] for value in values: - session_sca.virtwho_configure.edit(name, {'hypervisor_id': value}) - results = session_sca.virtwho_configure.read(name) + org_session.virtwho_configure.edit(name, {'hypervisor_id': value}) + results = org_session.virtwho_configure.read(name) assert results['overview']['hypervisor_id'] == value deploy_configure_by_command( - config_command, form_data['hypervisor_type'], org=module_sca_manifest_org.label + config_command, form_data_ui['hypervisor_type'], org=module_sca_manifest_org.label ) assert get_configure_option('hypervisor_id', config_file) == value diff --git a/tests/foreman/virtwho/ui/test_libvirt.py b/tests/foreman/virtwho/ui/test_libvirt.py index 6c6b37fdc30..86b3d3e6532 100644 --- a/tests/foreman/virtwho/ui/test_libvirt.py +++ b/tests/foreman/virtwho/ui/test_libvirt.py @@ -16,13 +16,11 @@ :Upstream: No """ -from fauxfactory import gen_string import pytest from robottelo.config import settings from robottelo.utils.virtwho import ( deploy_configure_by_command, - deploy_configure_by_script, get_configure_command, get_configure_file, get_configure_id, @@ -30,35 +28,11 @@ ) -@pytest.fixture() -def form_data(): - form = { - 'debug': True, - 'interval': 'Every hour', - 'hypervisor_id': 'hostname', - 'hypervisor_type': settings.virtwho.libvirt.hypervisor_type, - 'hypervisor_content.server': settings.virtwho.libvirt.hypervisor_server, - 'hypervisor_content.username': settings.virtwho.libvirt.hypervisor_username, - } - return form - - -@pytest.fixture() -def virtwho_config(form_data, target_sat, session): - name = gen_string('alpha') - form_data['name'] = name - with session: - session.virtwho_configure.create(form_data) - yield virtwho_config - session.virtwho_configure.delete(name) - assert not session.virtwho_configure.search(name) - - class TestVirtwhoConfigforLibvirt: @pytest.mark.tier2 - @pytest.mark.parametrize('deploy_type', ['id', 'script']) + @pytest.mark.parametrize('deploy_type_ui', ['id', 'script'], indirect=True) def test_positive_deploy_configure_by_id_script( - self, default_org, virtwho_config, session, form_data, deploy_type + self, default_org, org_session, form_data_ui, deploy_type_ui ): """Verify configure created and deployed with id. @@ -75,37 +49,30 @@ def test_positive_deploy_configure_by_id_script( :CaseImportance: High """ - name = form_data['name'] - values = session.virtwho_configure.read(name) - if deploy_type == "id": - command = values['deploy']['command'] - hypervisor_name, guest_name = deploy_configure_by_command( - command, form_data['hypervisor_type'], debug=True, org=default_org.label - ) - elif deploy_type == "script": - script = values['deploy']['script'] - hypervisor_name, guest_name = deploy_configure_by_script( - script, form_data['hypervisor_type'], debug=True, org=default_org.label - ) - assert session.virtwho_configure.search(name)[0]['Status'] == 'ok' - hypervisor_display_name = session.contenthost.search(hypervisor_name)[0]['Name'] + hypervisor_name, guest_name = deploy_type_ui + assert org_session.virtwho_configure.search(form_data_ui['name'])[0]['Status'] == 'ok' + hypervisor_display_name = org_session.contenthost.search(hypervisor_name)[0]['Name'] vdc_physical = f'product_id = {settings.virtwho.sku.vdc_physical} and type=NORMAL' vdc_virtual = f'product_id = {settings.virtwho.sku.vdc_physical} and type=STACK_DERIVED' assert ( - session.contenthost.read_legacy_ui(hypervisor_display_name)['subscriptions']['status'] + org_session.contenthost.read_legacy_ui(hypervisor_display_name)['subscriptions'][ + 'status' + ] == 'Unsubscribed hypervisor' ) - session.contenthost.add_subscription(hypervisor_display_name, vdc_physical) - assert session.contenthost.search(hypervisor_name)[0]['Subscription Status'] == 'green' + org_session.contenthost.add_subscription(hypervisor_display_name, vdc_physical) + assert org_session.contenthost.search(hypervisor_name)[0]['Subscription Status'] == 'green' assert ( - session.contenthost.read_legacy_ui(guest_name)['subscriptions']['status'] + org_session.contenthost.read_legacy_ui(guest_name)['subscriptions']['status'] == 'Unentitled' ) - session.contenthost.add_subscription(guest_name, vdc_virtual) - assert session.contenthost.search(guest_name)[0]['Subscription Status'] == 'green' + org_session.contenthost.add_subscription(guest_name, vdc_virtual) + assert org_session.contenthost.search(guest_name)[0]['Subscription Status'] == 'green' @pytest.mark.tier2 - def test_positive_hypervisor_id_option(self, default_org, virtwho_config, session, form_data): + def test_positive_hypervisor_id_option( + self, default_org, virtwho_config_ui, org_session, form_data_ui + ): """Verify Hypervisor ID dropdown options. :id: b8b2b272-89f2-45d0-b922-6e988b20808b @@ -118,16 +85,16 @@ def test_positive_hypervisor_id_option(self, default_org, virtwho_config, sessio :CaseImportance: Medium """ - name = form_data['name'] + name = form_data_ui['name'] config_id = get_configure_id(name) config_command = get_configure_command(config_id, default_org.name) config_file = get_configure_file(config_id) values = ['uuid', 'hostname'] for value in values: - session.virtwho_configure.edit(name, {'hypervisor_id': value}) - results = session.virtwho_configure.read(name) + org_session.virtwho_configure.edit(name, {'hypervisor_id': value}) + results = org_session.virtwho_configure.read(name) assert results['overview']['hypervisor_id'] == value deploy_configure_by_command( - config_command, form_data['hypervisor_type'], org=default_org.label + config_command, form_data_ui['hypervisor_type'], org=default_org.label ) assert get_configure_option('hypervisor_id', config_file) == value diff --git a/tests/foreman/virtwho/ui/test_libvirt_sca.py b/tests/foreman/virtwho/ui/test_libvirt_sca.py index 6bd64fabcfc..7ee9d0c881d 100644 --- a/tests/foreman/virtwho/ui/test_libvirt_sca.py +++ b/tests/foreman/virtwho/ui/test_libvirt_sca.py @@ -14,13 +14,10 @@ :Upstream: No """ -from fauxfactory import gen_string import pytest -from robottelo.config import settings from robottelo.utils.virtwho import ( deploy_configure_by_command, - deploy_configure_by_script, get_configure_command, get_configure_file, get_configure_id, @@ -28,35 +25,11 @@ ) -@pytest.fixture() -def form_data(): - form = { - 'debug': True, - 'interval': 'Every hour', - 'hypervisor_id': 'hostname', - 'hypervisor_type': settings.virtwho.libvirt.hypervisor_type, - 'hypervisor_content.server': settings.virtwho.libvirt.hypervisor_server, - 'hypervisor_content.username': settings.virtwho.libvirt.hypervisor_username, - } - return form - - -@pytest.fixture() -def virtwho_config(form_data, target_sat, session_sca): - name = gen_string('alpha') - form_data['name'] = name - with session_sca: - session_sca.virtwho_configure.create(form_data) - yield virtwho_config - session_sca.virtwho_configure.delete(name) - assert not session_sca.virtwho_configure.search(name) - - class TestVirtwhoConfigforLibvirt: @pytest.mark.tier2 - @pytest.mark.parametrize('deploy_type', ['id', 'script']) + @pytest.mark.parametrize('deploy_type_ui', ['id', 'script'], indirect=True) def test_positive_deploy_configure_by_id_script( - self, module_sca_manifest_org, virtwho_config, session_sca, form_data, deploy_type + self, module_sca_manifest_org, org_session, form_data_ui, deploy_type_ui ): """Verify configure created and deployed with id. @@ -73,29 +46,11 @@ def test_positive_deploy_configure_by_id_script( :CaseImportance: High """ - name = form_data['name'] - values = session_sca.virtwho_configure.read(name) - if deploy_type == "id": - command = values['deploy']['command'] - deploy_configure_by_command( - command, - form_data['hypervisor_type'], - debug=True, - org=module_sca_manifest_org.label, - ) - elif deploy_type == "script": - script = values['deploy']['script'] - deploy_configure_by_script( - script, - form_data['hypervisor_type'], - debug=True, - org=module_sca_manifest_org.label, - ) - assert session_sca.virtwho_configure.search(name)[0]['Status'] == 'ok' + assert org_session.virtwho_configure.search(form_data_ui['name'])[0]['Status'] == 'ok' @pytest.mark.tier2 def test_positive_hypervisor_id_option( - self, module_sca_manifest_org, virtwho_config, session_sca, form_data + self, module_sca_manifest_org, virtwho_config_ui, org_session, form_data_ui ): """Verify Hypervisor ID dropdown options. @@ -109,16 +64,16 @@ def test_positive_hypervisor_id_option( :CaseImportance: Medium """ - name = form_data['name'] + name = form_data_ui['name'] config_id = get_configure_id(name) config_command = get_configure_command(config_id, module_sca_manifest_org.name) config_file = get_configure_file(config_id) values = ['uuid', 'hostname'] for value in values: - session_sca.virtwho_configure.edit(name, {'hypervisor_id': value}) - results = session_sca.virtwho_configure.read(name) + org_session.virtwho_configure.edit(name, {'hypervisor_id': value}) + results = org_session.virtwho_configure.read(name) assert results['overview']['hypervisor_id'] == value deploy_configure_by_command( - config_command, form_data['hypervisor_type'], org=module_sca_manifest_org.label + config_command, form_data_ui['hypervisor_type'], org=module_sca_manifest_org.label ) assert get_configure_option('hypervisor_id', config_file) == value diff --git a/tests/foreman/virtwho/ui/test_nutanix.py b/tests/foreman/virtwho/ui/test_nutanix.py index d2a77961918..8bd1a3b23c7 100644 --- a/tests/foreman/virtwho/ui/test_nutanix.py +++ b/tests/foreman/virtwho/ui/test_nutanix.py @@ -32,38 +32,11 @@ ) -@pytest.fixture() -def form_data(): - form = { - 'debug': True, - 'interval': 'Every hour', - 'hypervisor_id': 'hostname', - 'hypervisor_type': settings.virtwho.ahv.hypervisor_type, - 'hypervisor_content.server': settings.virtwho.ahv.hypervisor_server, - 'hypervisor_content.username': settings.virtwho.ahv.hypervisor_username, - 'hypervisor_content.password': settings.virtwho.ahv.hypervisor_password, - 'hypervisor_content.prism_flavor': "Prism Element", - 'ahv_internal_debug': False, - } - return form - - -@pytest.fixture() -def virtwho_config(form_data, target_sat, session): - name = gen_string('alpha') - form_data['name'] = name - with session: - session.virtwho_configure.create(form_data) - yield virtwho_config - session.virtwho_configure.delete(name) - assert not session.virtwho_configure.search(name) - - class TestVirtwhoConfigforNutanix: @pytest.mark.tier2 - @pytest.mark.parametrize('deploy_type', ['id', 'script']) + @pytest.mark.parametrize('deploy_type_ui', ['id', 'script'], indirect=True) def test_positive_deploy_configure_by_id_script( - self, default_org, virtwho_config, session, form_data, deploy_type + self, default_org, org_session, form_data_ui, deploy_type_ui ): """Verify configure created and deployed with id. @@ -80,37 +53,30 @@ def test_positive_deploy_configure_by_id_script( :CaseImportance: High """ - name = form_data['name'] - values = session.virtwho_configure.read(name) - if deploy_type == "id": - command = values['deploy']['command'] - hypervisor_name, guest_name = deploy_configure_by_command( - command, form_data['hypervisor_type'], debug=True, org=default_org.label - ) - elif deploy_type == "script": - script = values['deploy']['script'] - hypervisor_name, guest_name = deploy_configure_by_script( - script, form_data['hypervisor_type'], debug=True, org=default_org.label - ) - assert session.virtwho_configure.search(name)[0]['Status'] == 'ok' - hypervisor_display_name = session.contenthost.search(hypervisor_name)[0]['Name'] + hypervisor_name, guest_name = deploy_type_ui + assert org_session.virtwho_configure.search(form_data_ui['name'])[0]['Status'] == 'ok' + hypervisor_display_name = org_session.contenthost.search(hypervisor_name)[0]['Name'] vdc_physical = f'product_id = {settings.virtwho.sku.vdc_physical} and type=NORMAL' vdc_virtual = f'product_id = {settings.virtwho.sku.vdc_physical} and type=STACK_DERIVED' assert ( - session.contenthost.read_legacy_ui(hypervisor_display_name)['subscriptions']['status'] + org_session.contenthost.read_legacy_ui(hypervisor_display_name)['subscriptions'][ + 'status' + ] == 'Unsubscribed hypervisor' ) - session.contenthost.add_subscription(hypervisor_display_name, vdc_physical) - assert session.contenthost.search(hypervisor_name)[0]['Subscription Status'] == 'green' + org_session.contenthost.add_subscription(hypervisor_display_name, vdc_physical) + assert org_session.contenthost.search(hypervisor_name)[0]['Subscription Status'] == 'green' assert ( - session.contenthost.read_legacy_ui(guest_name)['subscriptions']['status'] + org_session.contenthost.read_legacy_ui(guest_name)['subscriptions']['status'] == 'Unentitled' ) - session.contenthost.add_subscription(guest_name, vdc_virtual) - assert session.contenthost.search(guest_name)[0]['Subscription Status'] == 'green' + org_session.contenthost.add_subscription(guest_name, vdc_virtual) + assert org_session.contenthost.search(guest_name)[0]['Subscription Status'] == 'green' @pytest.mark.tier2 - def test_positive_hypervisor_id_option(self, default_org, virtwho_config, session, form_data): + def test_positive_hypervisor_id_option( + self, default_org, virtwho_config_ui, org_session, form_data_ui + ): """Verify Hypervisor ID dropdown options. :id: e076a305-88f4-42fb-8ef2-cb55e38eb912 @@ -123,25 +89,25 @@ def test_positive_hypervisor_id_option(self, default_org, virtwho_config, sessio :CaseImportance: Medium """ - name = form_data['name'] - values = session.virtwho_configure.read(name) + name = form_data_ui['name'] + values = org_session.virtwho_configure.read(name) config_id = get_configure_id(name) config_command = values['deploy']['command'] config_file = get_configure_file(config_id) values = ['uuid', 'hostname'] for value in values: - session.virtwho_configure.edit(name, {'hypervisor_id': value}) - results = session.virtwho_configure.read(name) + org_session.virtwho_configure.edit(name, {'hypervisor_id': value}) + results = org_session.virtwho_configure.read(name) assert results['overview']['hypervisor_id'] == value deploy_configure_by_command( - config_command, form_data['hypervisor_type'], org=default_org.label + config_command, form_data_ui['hypervisor_type'], org=default_org.label ) assert get_configure_option('hypervisor_id', config_file) == value @pytest.mark.tier2 @pytest.mark.parametrize('deploy_type', ['id', 'script']) def test_positive_prism_central_deploy_configure_by_id_script( - self, default_org, session, form_data, deploy_type + self, default_org, org_session, form_data_ui, deploy_type ): """Verify configure created and deployed with id on nutanix prism central mode @@ -160,49 +126,51 @@ def test_positive_prism_central_deploy_configure_by_id_script( :CaseImportance: High """ name = gen_string('alpha') - form_data['name'] = name - form_data['hypervisor_content.prism_flavor'] = "Prism Central" - with session: - session.virtwho_configure.create(form_data) - values = session.virtwho_configure.read(name) + form_data_ui['name'] = name + form_data_ui['hypervisor_content.prism_flavor'] = "Prism Central" + with org_session: + org_session.virtwho_configure.create(form_data_ui) + values = org_session.virtwho_configure.read(name) if deploy_type == "id": command = values['deploy']['command'] hypervisor_name, guest_name = deploy_configure_by_command( - command, form_data['hypervisor_type'], debug=True, org=default_org.label + command, form_data_ui['hypervisor_type'], debug=True, org=default_org.label ) elif deploy_type == "script": script = values['deploy']['script'] hypervisor_name, guest_name = deploy_configure_by_script( - script, form_data['hypervisor_type'], debug=True, org=default_org.label + script, form_data_ui['hypervisor_type'], debug=True, org=default_org.label ) # Check the option "prism_central=true" should be set in etc/virt-who.d/virt-who.conf config_id = get_configure_id(name) config_file = get_configure_file(config_id) assert get_configure_option("prism_central", config_file) == 'true' - assert session.virtwho_configure.search(name)[0]['Status'] == 'ok' - hypervisor_display_name = session.contenthost.search(hypervisor_name)[0]['Name'] + assert org_session.virtwho_configure.search(name)[0]['Status'] == 'ok' + hypervisor_display_name = org_session.contenthost.search(hypervisor_name)[0]['Name'] vdc_physical = f'product_id = {settings.virtwho.sku.vdc_physical} and type=NORMAL' vdc_virtual = f'product_id = {settings.virtwho.sku.vdc_physical} and type=STACK_DERIVED' assert ( - session.contenthost.read_legacy_ui(hypervisor_display_name)['subscriptions'][ + org_session.contenthost.read_legacy_ui(hypervisor_display_name)['subscriptions'][ 'status' ] == 'Unsubscribed hypervisor' ) - session.contenthost.add_subscription(hypervisor_display_name, vdc_physical) - assert session.contenthost.search(hypervisor_name)[0]['Subscription Status'] == 'green' + org_session.contenthost.add_subscription(hypervisor_display_name, vdc_physical) assert ( - session.contenthost.read_legacy_ui(guest_name)['subscriptions']['status'] + org_session.contenthost.search(hypervisor_name)[0]['Subscription Status'] == 'green' + ) + assert ( + org_session.contenthost.read_legacy_ui(guest_name)['subscriptions']['status'] == 'Unentitled' ) - session.contenthost.add_subscription(guest_name, vdc_virtual) - assert session.contenthost.search(guest_name)[0]['Subscription Status'] == 'green' - session.virtwho_configure.delete(name) - assert not session.virtwho_configure.search(name) + org_session.contenthost.add_subscription(guest_name, vdc_virtual) + assert org_session.contenthost.search(guest_name)[0]['Subscription Status'] == 'green' + org_session.virtwho_configure.delete(name) + assert not org_session.virtwho_configure.search(name) @pytest.mark.tier2 def test_positive_prism_central_prism_flavor_option( - self, default_org, virtwho_config, session, form_data + self, default_org, virtwho_config_ui, org_session, form_data_ui ): """Verify prism_flavor dropdown options. @@ -216,23 +184,25 @@ def test_positive_prism_central_prism_flavor_option( :CaseImportance: Medium """ - name = form_data['name'] - results = session.virtwho_configure.read(name) + name = form_data_ui['name'] + results = org_session.virtwho_configure.read(name) assert results['overview']['prism_flavor'] == "element" config_id = get_configure_id(name) config_command = get_configure_command(config_id, default_org.name) config_file = get_configure_file(config_id) - session.virtwho_configure.edit(name, {'hypervisor_content.prism_flavor': "Prism Central"}) - results = session.virtwho_configure.read(name) + org_session.virtwho_configure.edit( + name, {'hypervisor_content.prism_flavor': "Prism Central"} + ) + results = org_session.virtwho_configure.read(name) assert results['overview']['prism_flavor'] == "central" deploy_configure_by_command( - config_command, form_data['hypervisor_type'], org=default_org.label + config_command, form_data_ui['hypervisor_type'], org=default_org.label ) assert get_configure_option('prism_central', config_file) == 'true' @pytest.mark.tier2 def test_positive_ahv_internal_debug_option( - self, default_org, virtwho_config, session, form_data + self, default_org, virtwho_config_ui, org_session, form_data_ui ): """Verify ahv_internal_debug option by hammer virt-who-config" @@ -253,15 +223,15 @@ def test_positive_ahv_internal_debug_option( :BZ: 2141719 :customerscenario: true """ - name = form_data['name'] + name = form_data_ui['name'] config_id = get_configure_id(name) - values = session.virtwho_configure.read(name) + values = org_session.virtwho_configure.read(name) command = values['deploy']['command'] config_file = get_configure_file(config_id) deploy_configure_by_command( - command, form_data['hypervisor_type'], debug=True, org=default_org.label + command, form_data_ui['hypervisor_type'], debug=True, org=default_org.label ) - results = session.virtwho_configure.read(name) + results = org_session.virtwho_configure.read(name) assert str(results['overview']['ahv_internal_debug']) == 'False' # ahv_internal_debug does not set in virt-who-config-X.conf option = 'ahv_internal_debug' @@ -275,14 +245,16 @@ def test_positive_ahv_internal_debug_option( assert check_message_in_rhsm_log(message) == message # Update ahv_internal_debug option to true - session.virtwho_configure.edit(name, {'ahv_internal_debug': True}) - results = session.virtwho_configure.read(name) + org_session.virtwho_configure.edit(name, {'ahv_internal_debug': True}) + results = org_session.virtwho_configure.read(name) command = results['deploy']['command'] assert str(results['overview']['ahv_internal_debug']) == 'True' deploy_configure_by_command( - command, form_data['hypervisor_type'], debug=True, org=default_org.label + command, form_data_ui['hypervisor_type'], debug=True, org=default_org.label + ) + assert ( + get_hypervisor_ahv_mapping(form_data_ui['hypervisor_type']) == 'Host UUID found for VM' ) - assert get_hypervisor_ahv_mapping(form_data['hypervisor_type']) == 'Host UUID found for VM' # ahv_internal_debug bas been set to true in virt-who-config-X.conf config_file = get_configure_file(config_id) assert get_configure_option("ahv_internal_debug", config_file) == 'true' diff --git a/tests/foreman/virtwho/ui/test_nutanix_sca.py b/tests/foreman/virtwho/ui/test_nutanix_sca.py index 3b53d038d71..42de668055e 100644 --- a/tests/foreman/virtwho/ui/test_nutanix_sca.py +++ b/tests/foreman/virtwho/ui/test_nutanix_sca.py @@ -17,7 +17,6 @@ from fauxfactory import gen_string import pytest -from robottelo.config import settings from robottelo.utils.virtwho import ( check_message_in_rhsm_log, deploy_configure_by_command, @@ -30,37 +29,11 @@ ) -@pytest.fixture() -def form_data(target_sat, module_sca_manifest_org): - form = { - 'debug': True, - 'interval': 'Every hour', - 'hypervisor_id': 'hostname', - 'hypervisor_type': settings.virtwho.ahv.hypervisor_type, - 'hypervisor_content.server': settings.virtwho.ahv.hypervisor_server, - 'hypervisor_content.username': settings.virtwho.ahv.hypervisor_username, - 'hypervisor_content.password': settings.virtwho.ahv.hypervisor_password, - 'hypervisor_content.prism_flavor': "Prism Element", - } - return form - - -@pytest.fixture() -def virtwho_config(form_data, target_sat, session_sca): - name = gen_string('alpha') - form_data['name'] = name - with session_sca: - session_sca.virtwho_configure.create(form_data) - yield virtwho_config - session_sca.virtwho_configure.delete(name) - assert not session_sca.virtwho_configure.search(name) - - class TestVirtwhoConfigforNutanix: @pytest.mark.tier2 - @pytest.mark.parametrize('deploy_type', ['id', 'script']) + @pytest.mark.parametrize('deploy_type_ui', ['id', 'script'], indirect=True) def test_positive_deploy_configure_by_id_script( - self, module_sca_manifest_org, virtwho_config, session_sca, form_data, deploy_type + self, module_sca_manifest_org, org_session, form_data_ui, deploy_type_ui ): """Verify configure created and deployed with id. @@ -76,29 +49,11 @@ def test_positive_deploy_configure_by_id_script( :CaseImportance: High """ - name = form_data['name'] - values = session_sca.virtwho_configure.read(name) - if deploy_type == "id": - command = values['deploy']['command'] - deploy_configure_by_command( - command, - form_data['hypervisor_type'], - debug=True, - org=module_sca_manifest_org.label, - ) - elif deploy_type == "script": - script = values['deploy']['script'] - deploy_configure_by_script( - script, - form_data['hypervisor_type'], - debug=True, - org=module_sca_manifest_org.label, - ) - assert session_sca.virtwho_configure.search(name)[0]['Status'] == 'ok' + assert org_session.virtwho_configure.search(form_data_ui['name'])[0]['Status'] == 'ok' @pytest.mark.tier2 def test_positive_hypervisor_id_option( - self, module_sca_manifest_org, virtwho_config, session_sca, form_data + self, module_sca_manifest_org, virtwho_config_ui, org_session, form_data_ui ): """Verify Hypervisor ID dropdown options. @@ -112,18 +67,18 @@ def test_positive_hypervisor_id_option( :CaseImportance: Medium """ - name = form_data['name'] - values = session_sca.virtwho_configure.read(name) + name = form_data_ui['name'] + values = org_session.virtwho_configure.read(name) config_id = get_configure_id(name) command = values['deploy']['command'] config_file = get_configure_file(config_id) for value in ['uuid', 'hostname']: - session_sca.virtwho_configure.edit(name, {'hypervisor_id': value}) - results = session_sca.virtwho_configure.read(name) + org_session.virtwho_configure.edit(name, {'hypervisor_id': value}) + results = org_session.virtwho_configure.read(name) assert results['overview']['hypervisor_id'] == value deploy_configure_by_command( command, - form_data['hypervisor_type'], + form_data_ui['hypervisor_type'], debug=True, org=module_sca_manifest_org.label, ) @@ -132,7 +87,7 @@ def test_positive_hypervisor_id_option( @pytest.mark.tier2 @pytest.mark.parametrize('deploy_type', ['id', 'script']) def test_positive_prism_central_deploy_configure_by_id_script( - self, module_sca_manifest_org, session_sca, form_data, deploy_type + self, module_sca_manifest_org, org_session, form_data_ui, deploy_type ): """Verify configure created and deployed with id on nutanix prism central mode @@ -151,16 +106,16 @@ def test_positive_prism_central_deploy_configure_by_id_script( :CaseImportance: High """ name = gen_string('alpha') - form_data['name'] = name - form_data['hypervisor_content.prism_flavor'] = "Prism Central" - with session_sca: - session_sca.virtwho_configure.create(form_data) - values = session_sca.virtwho_configure.read(name) + form_data_ui['name'] = name + form_data_ui['hypervisor_content.prism_flavor'] = "Prism Central" + with org_session: + org_session.virtwho_configure.create(form_data_ui) + values = org_session.virtwho_configure.read(name) if deploy_type == "id": command = values['deploy']['command'] deploy_configure_by_command( command, - form_data['hypervisor_type'], + form_data_ui['hypervisor_type'], debug=True, org=module_sca_manifest_org.label, ) @@ -168,7 +123,7 @@ def test_positive_prism_central_deploy_configure_by_id_script( script = values['deploy']['script'] deploy_configure_by_script( script, - form_data['hypervisor_type'], + form_data_ui['hypervisor_type'], debug=True, org=module_sca_manifest_org.label, ) @@ -176,13 +131,13 @@ def test_positive_prism_central_deploy_configure_by_id_script( config_id = get_configure_id(name) config_file = get_configure_file(config_id) assert get_configure_option("prism_central", config_file) == 'true' - assert session_sca.virtwho_configure.search(name)[0]['Status'] == 'ok' - session_sca.virtwho_configure.delete(name) - assert not session_sca.virtwho_configure.search(name) + assert org_session.virtwho_configure.search(name)[0]['Status'] == 'ok' + org_session.virtwho_configure.delete(name) + assert not org_session.virtwho_configure.search(name) @pytest.mark.tier2 def test_positive_prism_central_prism_flavor_option( - self, module_sca_manifest_org, virtwho_config, session_sca, form_data + self, module_sca_manifest_org, virtwho_config_ui, org_session, form_data_ui ): """Verify prism_flavor dropdown options. @@ -196,25 +151,25 @@ def test_positive_prism_central_prism_flavor_option( :CaseImportance: Medium """ - name = form_data['name'] - results = session_sca.virtwho_configure.read(name) + name = form_data_ui['name'] + results = org_session.virtwho_configure.read(name) assert results['overview']['prism_flavor'] == "element" config_id = get_configure_id(name) config_command = get_configure_command(config_id, module_sca_manifest_org.name) config_file = get_configure_file(config_id) - session_sca.virtwho_configure.edit( + org_session.virtwho_configure.edit( name, {'hypervisor_content.prism_flavor': "Prism Central"} ) - results = session_sca.virtwho_configure.read(name) + results = org_session.virtwho_configure.read(name) assert results['overview']['prism_flavor'] == "central" deploy_configure_by_command( - config_command, form_data['hypervisor_type'], org=module_sca_manifest_org.label + config_command, form_data_ui['hypervisor_type'], org=module_sca_manifest_org.label ) assert get_configure_option('prism_central', config_file) == 'true' @pytest.mark.tier2 def test_positive_ahv_internal_debug_option( - self, module_sca_manifest_org, virtwho_config, session_sca, form_data + self, module_sca_manifest_org, virtwho_config_ui, org_session, form_data_ui ): """Verify ahv_internal_debug option by hammer virt-who-config" @@ -237,15 +192,15 @@ def test_positive_ahv_internal_debug_option( :customerscenario: true """ - name = form_data['name'] + name = form_data_ui['name'] config_id = get_configure_id(name) - values = session_sca.virtwho_configure.read(name) + values = org_session.virtwho_configure.read(name) command = values['deploy']['command'] config_file = get_configure_file(config_id) deploy_configure_by_command( - command, form_data['hypervisor_type'], debug=True, org=module_sca_manifest_org.label + command, form_data_ui['hypervisor_type'], debug=True, org=module_sca_manifest_org.label ) - results = session_sca.virtwho_configure.read(name) + results = org_session.virtwho_configure.read(name) assert str(results['overview']['ahv_internal_debug']) == 'False' # ahv_internal_debug does not set in virt-who-config-X.conf option = 'ahv_internal_debug' @@ -259,14 +214,16 @@ def test_positive_ahv_internal_debug_option( assert check_message_in_rhsm_log(message) == message # Update ahv_internal_debug option to true - session_sca.virtwho_configure.edit(name, {'ahv_internal_debug': True}) - results = session_sca.virtwho_configure.read(name) + org_session.virtwho_configure.edit(name, {'ahv_internal_debug': True}) + results = org_session.virtwho_configure.read(name) command = results['deploy']['command'] assert str(results['overview']['ahv_internal_debug']) == 'True' deploy_configure_by_command( - command, form_data['hypervisor_type'], debug=True, org=module_sca_manifest_org.label + command, form_data_ui['hypervisor_type'], debug=True, org=module_sca_manifest_org.label + ) + assert ( + get_hypervisor_ahv_mapping(form_data_ui['hypervisor_type']) == 'Host UUID found for VM' ) - assert get_hypervisor_ahv_mapping(form_data['hypervisor_type']) == 'Host UUID found for VM' # ahv_internal_debug bas been set to true in virt-who-config-X.conf config_file = get_configure_file(config_id) assert get_configure_option("ahv_internal_debug", config_file) == 'true' From 959b5bdf72ce22d583a7a4d44e63657f6c91cf84 Mon Sep 17 00:00:00 2001 From: Jitendra Yejare Date: Tue, 10 Oct 2023 13:26:28 +0530 Subject: [PATCH 08/30] Optional pytest Vault login and code nitpicking (#12822) * Optional pytest Vault login and code formating * Multiple options supported for non-vault pytest session (cherry picked from commit 9e851610c43e50ab8e472c1fd341394c0b16fd3c) --- robottelo/utils/vault.py | 38 ++++++++++++++++++++++++-------------- 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/robottelo/utils/vault.py b/robottelo/utils/vault.py index a4b5d48adb4..b0fc77d861e 100644 --- a/robottelo/utils/vault.py +++ b/robottelo/utils/vault.py @@ -19,25 +19,31 @@ class Vault: def __init__(self, env_file='.env'): self.env_path = robottelo_root_dir.joinpath(env_file) + self.envdata = None + self.vault_enabled = None def setup(self): - self.export_vault_addr() + if self.env_path.exists(): + self.envdata = self.env_path.read_text() + is_enabled = re.findall('\nVAULT_ENABLED_FOR_DYNACONF=(.*)', self.envdata) + if is_enabled: + self.vault_enabled = is_enabled[0] + self.export_vault_addr() def teardown(self): del os.environ['VAULT_ADDR'] def export_vault_addr(self): - envdata = self.env_path.read_text() - vaulturl = re.findall('VAULT_URL_FOR_DYNACONF=(.*)', envdata)[0] + vaulturl = re.findall('VAULT_URL_FOR_DYNACONF=(.*)', self.envdata)[0] # Set Vault CLI Env Var os.environ['VAULT_ADDR'] = vaulturl # Dynaconf Vault Env Vars - if re.findall('VAULT_ENABLED_FOR_DYNACONF=(.*)', envdata)[0] == 'true': + if self.vault_enabled and self.vault_enabled in ['True', 'true']: if 'localhost:8200' in vaulturl: raise InvalidVaultURLForOIDC( - f"{vaulturl} doesnt supports OIDC login," + f"{vaulturl} doesn't support OIDC login," "please change url to corp vault in env file!" ) @@ -63,7 +69,11 @@ def exec_vault_command(self, command: str, **kwargs): return vcommand def login(self, **kwargs): - if 'VAULT_SECRET_ID_FOR_DYNACONF' not in os.environ: + if ( + self.vault_enabled + and self.vault_enabled in ['True', 'true'] + and 'VAULT_SECRET_ID_FOR_DYNACONF' not in os.environ + ): if self.status(**kwargs).returncode != 0: logger.warning( "Warning! The browser is about to open for vault OIDC login, " @@ -81,22 +91,22 @@ def login(self, **kwargs): ).stdout token = json.loads(str(token.decode('UTF-8')))['data']['id'] # Setting new token in env file - envdata = self.env_path.read_text() - envdata = re.sub( - '.*VAULT_TOKEN_FOR_DYNACONF=.*', f"VAULT_TOKEN_FOR_DYNACONF={token}", envdata + _envdata = re.sub( + '.*VAULT_TOKEN_FOR_DYNACONF=.*', + f"VAULT_TOKEN_FOR_DYNACONF={token}", + self.envdata, ) - self.env_path.write_text(envdata) + self.env_path.write_text(_envdata) logger.info( "Success! New OIDC token added to .env file to access secrets from vault!" ) def logout(self): # Teardown - Setting dymmy token in env file - envdata = self.env_path.read_text() - envdata = re.sub( - '.*VAULT_TOKEN_FOR_DYNACONF=.*', "# VAULT_TOKEN_FOR_DYNACONF=myroot", envdata + _envdata = re.sub( + '.*VAULT_TOKEN_FOR_DYNACONF=.*', "# VAULT_TOKEN_FOR_DYNACONF=myroot", self.envdata ) - self.env_path.write_text(envdata) + self.env_path.write_text(_envdata) self.exec_vault_command('vault token revoke -self') logger.info("Success! OIDC token removed from Env file successfully!") From 05fda5760599ecf7c4d8e34632a627c1f2608051 Mon Sep 17 00:00:00 2001 From: Satellite QE <115476073+Satellite-QE@users.noreply.github.com> Date: Wed, 25 Oct 2023 00:09:42 -0400 Subject: [PATCH 09/30] [6.13.z] Bump cryptography from 41.0.4 to 41.0.5 (#12968) --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index ba6fb73a225..e04a537203c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,7 +2,7 @@ betelgeuse==1.10.0 broker[docker]==0.4.1 -cryptography==41.0.4 +cryptography==41.0.5 deepdiff==6.6.1 dynaconf[vault]==3.2.3 fauxfactory==3.1.0 From da8a61958565c1a74c489d66b3643a846f878a93 Mon Sep 17 00:00:00 2001 From: Satellite QE <115476073+Satellite-QE@users.noreply.github.com> Date: Wed, 25 Oct 2023 04:50:14 -0400 Subject: [PATCH 10/30] [6.13.z] Bump pytest from 7.4.2 to 7.4.3 (#12972) Bump pytest from 7.4.2 to 7.4.3 (#12966) (cherry picked from commit 8c8780895b5e86b991d3d441c0473226956a8ad7) Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index e04a537203c..7ae747718ec 100644 --- a/requirements.txt +++ b/requirements.txt @@ -12,7 +12,7 @@ navmazing==1.1.6 productmd==1.37 pyotp==2.9.0 python-box==7.1.1 -pytest==7.4.2 +pytest==7.4.3 pytest-services==2.2.1 pytest-mock==3.12.0 pytest-reportportal==5.3.0 From 43598acc0e87799ed15bcde3d3354e41cff9d083 Mon Sep 17 00:00:00 2001 From: Satellite QE <115476073+Satellite-QE@users.noreply.github.com> Date: Wed, 25 Oct 2023 11:31:41 -0400 Subject: [PATCH 11/30] [6.13.z] Fix vault makescripts with capture output (#12975) Fix vault makescripts with capture output (#12909) * Fix vault makescripts with capture output * Handle topped Vault enablement in .env file (cherry picked from commit 291698f925eb7016ff7d11764b218e2c7cf995d4) Co-authored-by: Jitendra Yejare --- pytest_plugins/auto_vault.py | 3 +-- robottelo/utils/vault.py | 17 ++++++++--------- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/pytest_plugins/auto_vault.py b/pytest_plugins/auto_vault.py index e63fc7f0835..cb9e1f0c10a 100644 --- a/pytest_plugins/auto_vault.py +++ b/pytest_plugins/auto_vault.py @@ -1,5 +1,4 @@ """Plugin enables pytest to notify and update the requirements""" -import subprocess from robottelo.utils.vault import Vault @@ -7,4 +6,4 @@ def pytest_addoption(parser): """Options to allow user to update the requirements""" with Vault() as vclient: - vclient.login(stdout=subprocess.PIPE, stderr=subprocess.PIPE) + vclient.login() diff --git a/robottelo/utils/vault.py b/robottelo/utils/vault.py index b0fc77d861e..d3a40d1a706 100644 --- a/robottelo/utils/vault.py +++ b/robottelo/utils/vault.py @@ -25,7 +25,7 @@ def __init__(self, env_file='.env'): def setup(self): if self.env_path.exists(): self.envdata = self.env_path.read_text() - is_enabled = re.findall('\nVAULT_ENABLED_FOR_DYNACONF=(.*)', self.envdata) + is_enabled = re.findall('^(?:.*\n)*VAULT_ENABLED_FOR_DYNACONF=(.*)', self.envdata) if is_enabled: self.vault_enabled = is_enabled[0] self.export_vault_addr() @@ -53,7 +53,7 @@ def exec_vault_command(self, command: str, **kwargs): :param comamnd str: The vault CLI command :param kwargs dict: Arguments to the subprocess run command to customize the run behavior """ - vcommand = subprocess.run(command, shell=True, **kwargs) # capture_output=True + vcommand = subprocess.run(command, shell=True, capture_output=True, **kwargs) if vcommand.returncode != 0: verror = str(vcommand.stderr) if vcommand.returncode == 127: @@ -63,7 +63,7 @@ def exec_vault_command(self, command: str, **kwargs): if 'Error revoking token' in verror: logger.info("Token is alredy revoked!") elif 'Error looking up token' in verror: - logger.warning("Warning! Vault not logged in!") + logger.info("Vault is not logged in!") else: logger.error(f"Error! {verror}") return vcommand @@ -75,7 +75,7 @@ def login(self, **kwargs): and 'VAULT_SECRET_ID_FOR_DYNACONF' not in os.environ ): if self.status(**kwargs).returncode != 0: - logger.warning( + logger.info( "Warning! The browser is about to open for vault OIDC login, " "close the tab once the sign-in is done!" ) @@ -86,9 +86,7 @@ def login(self, **kwargs): self.exec_vault_command(command="vault token renew -i 10h", **kwargs) logger.info("Success! Vault OIDC Logged-In and extended for 10 hours!") # Fetching tokens - token = self.exec_vault_command( - "vault token lookup --format json", capture_output=True - ).stdout + token = self.exec_vault_command("vault token lookup --format json").stdout token = json.loads(str(token.decode('UTF-8')))['data']['id'] # Setting new token in env file _envdata = re.sub( @@ -107,8 +105,9 @@ def logout(self): '.*VAULT_TOKEN_FOR_DYNACONF=.*', "# VAULT_TOKEN_FOR_DYNACONF=myroot", self.envdata ) self.env_path.write_text(_envdata) - self.exec_vault_command('vault token revoke -self') - logger.info("Success! OIDC token removed from Env file successfully!") + vstatus = self.exec_vault_command('vault token revoke -self') + if vstatus.returncode == 0: + logger.info("Success! OIDC token removed from Env file successfully!") def status(self, **kwargs): vstatus = self.exec_vault_command('vault token lookup', **kwargs) From 8be896ac30f23cca560bc829f4756c89779d0c5f Mon Sep 17 00:00:00 2001 From: Satellite QE <115476073+Satellite-QE@users.noreply.github.com> Date: Thu, 26 Oct 2023 05:20:22 -0400 Subject: [PATCH 12/30] [6.13.z] Fixture collection splitting restructured (#12980) Fixture collection splitting restructured (#12923) Fixture collection spliting restructured (cherry picked from commit 33f4b323fdbf26a83af37ff1aac635f287b082b2) Co-authored-by: Jitendra Yejare --- pytest_plugins/fixture_collection.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pytest_plugins/fixture_collection.py b/pytest_plugins/fixture_collection.py index 934efa5f56d..6f61f2b3360 100644 --- a/pytest_plugins/fixture_collection.py +++ b/pytest_plugins/fixture_collection.py @@ -13,7 +13,7 @@ def pytest_addoption(parser): example: pytest tests/foreman --uses-fixtures target_sat module_target_sat ''' - parser.addoption("--uses-fixtures", nargs='+', help=help_text) + parser.addoption("--uses-fixtures", nargs='?', help=help_text) def pytest_collection_modifyitems(items, config): @@ -22,17 +22,18 @@ def pytest_collection_modifyitems(items, config): return filter_fixtures = config.getvalue('uses_fixtures') + fixtures_list = filter_fixtures.split(',') if ',' in filter_fixtures else [filter_fixtures] selected = [] deselected = [] for item in items: - if set(item.fixturenames).intersection(set(filter_fixtures)): + if set(item.fixturenames).intersection(set(fixtures_list)): selected.append(item) else: deselected.append(item) logger.debug( f'Selected {len(selected)} and deselected {len(deselected)} ' - f'tests based on given fixtures {filter_fixtures} used by tests' + f'tests based on given fixtures {fixtures_list} used by tests' ) config.hook.pytest_deselected(items=deselected) items[:] = selected From c4753d0264b03e56316c2d01d77678f87355100c Mon Sep 17 00:00:00 2001 From: Satellite QE <115476073+Satellite-QE@users.noreply.github.com> Date: Thu, 26 Oct 2023 05:27:06 -0400 Subject: [PATCH 13/30] [6.13.z] [Upgrades] Add upgrade tests for ProvisioningTemplates (#12955) [Upgrades] Add upgrade tests for ProvisioningTemplates (#12897) Add upgrade tests for ProvisioningTemplates Signed-off-by: Gaurav Talreja (cherry picked from commit f9cec5efe795129617cfe6ae2f1ff0a2343e01e0) Co-authored-by: Gaurav Talreja --- pytest_fixtures/component/domain.py | 10 +- tests/upgrades/test_provisioningtemplate.py | 141 ++++++++++++++++++++ 2 files changed, 146 insertions(+), 5 deletions(-) create mode 100644 tests/upgrades/test_provisioningtemplate.py diff --git a/pytest_fixtures/component/domain.py b/pytest_fixtures/component/domain.py index c62b45f54d5..57a1c265b30 100644 --- a/pytest_fixtures/component/domain.py +++ b/pytest_fixtures/component/domain.py @@ -1,15 +1,15 @@ # Domain Fixtures -from nailgun import entities import pytest @pytest.fixture(scope='session') def default_domain(session_target_sat, default_smart_proxy): domain_name = session_target_sat.hostname.partition('.')[-1] - dom = entities.Domain().search(query={'search': f'name={domain_name}'})[0] - dom.dns = default_smart_proxy - dom.update(['dns']) - return entities.Domain(id=dom.id).read() + dom = session_target_sat.api.Domain().search(query={'search': f'name={domain_name}'})[0] + if 'dns' in session_target_sat.get_features(): + dom.dns = default_smart_proxy + dom.update(['dns']) + return session_target_sat.api.Domain(id=dom.id).read() @pytest.fixture(scope='module') diff --git a/tests/upgrades/test_provisioningtemplate.py b/tests/upgrades/test_provisioningtemplate.py new file mode 100644 index 00000000000..b5bc11af363 --- /dev/null +++ b/tests/upgrades/test_provisioningtemplate.py @@ -0,0 +1,141 @@ +"""Test for ProvisioningTemplates related Upgrade Scenario's + +:Requirement: UpgradedSatellite + +:CaseAutomation: Automated + +:CaseComponent: ProvisioningTemplates + +:Team: Rocket + +:TestType: Functional + +:CaseLevel: Integration + +:CaseImportance: High + +:Upstream: No +""" +from fauxfactory import gen_string +import pytest + +from robottelo.config import settings + +provisioning_template_kinds = ['provision', 'PXEGrub', 'PXEGrub2', 'PXELinux', 'iPXE'] + + +class TestScenarioPositiveProvisioningTemplates: + """Provisioning Templates can be rendered correctly on host created in previous and upgraded versions + + :steps: + 1. Create host on Satellite and trying rendering provisioning templates + 2. Upgrade the Satellite to the next or latest version. + 3. After the upgrade, verify provisioning templates can be rendered on existing host + 4. Create host on upgraded Satellite and trying rendering provisioning templates. + + :expectedresults: + 1. Provisioning templates for host are able to render in previous and upgraded versions + """ + + @pytest.mark.pre_upgrade + @pytest.mark.parametrize('pxe_loader', ['bios', 'uefi'], indirect=True) + def test_pre_scenario_provisioning_templates( + self, + module_target_sat, + module_org, + module_location, + default_os, + default_domain, + default_architecture, + default_partitiontable, + pxe_loader, + save_test_data, + ): + """Verify Host created Read the Provision template + + :id: preupgrade-3f338475-fa69-43ef-ac86-f00f4d324b21 + + :steps: + 1. Create host on Satellite and trying rendering provisioning templates + + :expectedresults: + 1. Provisioning templates for host are able to render in before upgrading to new version + + :parametrized: yes + """ + host = module_target_sat.api.Host( + organization=module_org, + location=module_location, + name=gen_string('alpha'), + operatingsystem=default_os, + architecture=default_architecture, + domain=default_domain, + root_pass=settings.provisioning.host_root_password, + ptable=default_partitiontable, + pxe_loader=pxe_loader.pxe_loader, + ).create() + + for kind in provisioning_template_kinds: + assert host.read_template(data={'template_kind': kind}) + + save_test_data( + { + 'provision_host_id': host.id, + 'pxe_loader': pxe_loader.pxe_loader, + } + ) + + @pytest.mark.post_upgrade(depend_on=test_pre_scenario_provisioning_templates) + @pytest.mark.parametrize('pre_upgrade_data', ['bios', 'uefi'], indirect=True) + def test_post_scenario_provisioning_templates( + self, + request, + pre_upgrade_data, + module_target_sat, + ): + """Host provisioned using pre-upgrade GCE CR + + :id: postupgrade-ef82143d-efef-49b2-9702-93d67ef6805e + + :steps: + 1. Postupgrade, verify provisioning templates rendering for host + 2. Create a new host on Satellite and try rendering provisioning templates + + :expectedresults: + 1. Provisioning templates for existing and new host are able to render. + + :parametrized: yes + """ + pxe_loader = pre_upgrade_data.pxe_loader + pre_upgrade_host = module_target_sat.api.Host().search( + query={'search': f'id={pre_upgrade_data.provision_host_id}'} + )[0] + org = module_target_sat.api.Organization(id=pre_upgrade_host.organization.id).read() + loc = module_target_sat.api.Location(id=pre_upgrade_host.location.id).read() + domain = module_target_sat.api.Domain(id=pre_upgrade_host.domain.id).read() + architecture = module_target_sat.api.Architecture( + id=pre_upgrade_host.architecture.id + ).read() + os = module_target_sat.api.OperatingSystem(id=pre_upgrade_host.operatingsystem.id).read() + ptable = module_target_sat.api.PartitionTable(id=pre_upgrade_host.ptable.id).read() + + for kind in provisioning_template_kinds: + assert pre_upgrade_host.read_template(data={'template_kind': kind}) + + new_host_name = gen_string('alpha') + new_host = module_target_sat.api.Host( + name=new_host_name, + organization=org, + location=loc, + architecture=architecture, + domain=domain, + operatingsystem=os, + ptable=ptable, + root_pass=settings.provisioning.host_root_password, + pxe_loader=pxe_loader, + ).create() + request.addfinalizer(pre_upgrade_host.delete) + request.addfinalizer(new_host.delete) + + for kind in provisioning_template_kinds: + assert new_host.read_template(data={'template_kind': kind}) From 4bc5fdf1986dac6048eafecb522003e245521368 Mon Sep 17 00:00:00 2001 From: Satellite QE <115476073+Satellite-QE@users.noreply.github.com> Date: Thu, 26 Oct 2023 06:18:41 -0400 Subject: [PATCH 14/30] [6.13.z] Add workaround for cpu_mode for EL9 Libvirt tests (#12986) --- tests/foreman/cli/test_computeresource_libvirt.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tests/foreman/cli/test_computeresource_libvirt.py b/tests/foreman/cli/test_computeresource_libvirt.py index e5e1997fa3b..c1144c88733 100644 --- a/tests/foreman/cli/test_computeresource_libvirt.py +++ b/tests/foreman/cli/test_computeresource_libvirt.py @@ -45,6 +45,7 @@ from robottelo.config import settings from robottelo.constants import FOREMAN_PROVIDERS, LIBVIRT_RESOURCE_URL from robottelo.utils.datafactory import parametrized +from robottelo.utils.issue_handlers import is_open LIBVIRT_URL = LIBVIRT_RESOURCE_URL % settings.libvirt.libvirt_hostname @@ -436,6 +437,7 @@ def test_positive_provision_end_to_end( module_sca_manifest_org, module_location, provisioning_hostgroup, + module_provisioning_rhel_content, ): """Provision a host on Libvirt compute resource with the help of hostgroup. @@ -453,10 +455,14 @@ def test_positive_provision_end_to_end( :expectedresults: Host should be provisioned with hostgroup :parametrized: yes + + :BZ: 2236693 """ sat = module_libvirt_provisioning_sat.sat cr_name = gen_string('alpha') hostname = gen_string('alpha').lower() + os_major_ver = module_provisioning_rhel_content.os.major + cpu_mode = 'host-passthrough' if is_open('BZ:2236693') and os_major_ver == '9' else 'default' libvirt_cr = sat.cli.ComputeResource.create( { 'name': cr_name, @@ -476,7 +482,7 @@ def test_positive_provision_end_to_end( 'compute-resource-id': libvirt_cr['id'], 'ip': None, 'mac': None, - 'compute-attributes': 'cpus=1, memory=6442450944, cpu_mode=default, start=1', + 'compute-attributes': f'cpus=1, memory=6442450944, cpu_mode={cpu_mode}, start=1', 'interface': f'compute_type=bridge,compute_bridge=br-{settings.provisioning.vlan_id}', 'volume': 'capacity=10', 'provision-method': 'build', From 00df797abc36aa29345c75870cb2234f0d79953f Mon Sep 17 00:00:00 2001 From: Satellite QE <115476073+Satellite-QE@users.noreply.github.com> Date: Thu, 26 Oct 2023 07:11:00 -0400 Subject: [PATCH 15/30] [6.13.z] Remove test_positive_backup_restore_snapshot stub (#12982) Remove test_positive_backup_restore_snapshot stub (#12974) (cherry picked from commit 8b0eca51c1384eb75b514fedd15bdc68bf3dabe5) Co-authored-by: Lukas Pramuk --- tests/foreman/maintain/test_backup_restore.py | 27 ------------------- 1 file changed, 27 deletions(-) diff --git a/tests/foreman/maintain/test_backup_restore.py b/tests/foreman/maintain/test_backup_restore.py index 473f768fa74..6f6817730b1 100644 --- a/tests/foreman/maintain/test_backup_restore.py +++ b/tests/foreman/maintain/test_backup_restore.py @@ -675,30 +675,3 @@ def test_positive_backup_restore_incremental( query={'search': f'name="{secondary_repo.name}"'} )[0] assert repo.id == secondary_repo.id - - -@pytest.mark.stubbed -def test_positive_backup_restore_snapshot(): - """Take the snapshot backup of a server, restore it, check for content - - :id: dcf3b815-97ed-4c2e-9f2d-5eedd8591c98 - - :setup: - 1. satellite installed on an LVM-based storage with sufficient free extents - - :steps: - 1. create the snapshot backup (with/without pulp) - 2. check that appropriate files are created - 3. restore the backup (installer --reset-data is run in this step) - 4. check system health - 5. check the content was restored - - :expectedresults: - 1. backup succeeds - 2. expected files are present in the backup - 3. restore succeeds - 4. system health check succeeds - 5. content is present after restore - - :CaseAutomation: NotAutomated - """ From 148e827f7c1040b584b265f5a0922b7a8ad5d65e Mon Sep 17 00:00:00 2001 From: Satellite QE <115476073+Satellite-QE@users.noreply.github.com> Date: Fri, 27 Oct 2023 01:42:07 -0400 Subject: [PATCH 16/30] [6.13.z] Bump wrapanapi from 3.5.18 to 3.6.0 (#12993) --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 7ae747718ec..e358db72504 100644 --- a/requirements.txt +++ b/requirements.txt @@ -23,7 +23,7 @@ requests==2.31.0 tenacity==8.2.3 testimony==2.3.0 wait-for==1.2.0 -wrapanapi==3.5.18 +wrapanapi==3.6.0 # Get airgun, nailgun and upgrade from 6.13.z git+https://github.com/SatelliteQE/airgun.git@6.13.z#egg=airgun From cb0e2c907b6171fdc4ec8c0355f1810e0c1709cd Mon Sep 17 00:00:00 2001 From: Satellite QE <115476073+Satellite-QE@users.noreply.github.com> Date: Sat, 28 Oct 2023 05:52:53 -0400 Subject: [PATCH 17/30] [6.13.z] Add workaround for cpu_mode for EL9 Libvirt UI tests (#12998) --- tests/foreman/ui/test_computeresource_libvirt.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/foreman/ui/test_computeresource_libvirt.py b/tests/foreman/ui/test_computeresource_libvirt.py index 1cb250d2346..2d05fa45bf3 100644 --- a/tests/foreman/ui/test_computeresource_libvirt.py +++ b/tests/foreman/ui/test_computeresource_libvirt.py @@ -28,6 +28,7 @@ FOREMAN_PROVIDERS, LIBVIRT_RESOURCE_URL, ) +from robottelo.utils.issue_handlers import is_open pytestmark = [pytest.mark.skip_if_not_set('libvirt')] @@ -135,6 +136,7 @@ def test_positive_provision_end_to_end( module_location, provisioning_hostgroup, module_libvirt_provisioning_sat, + module_provisioning_rhel_content, ): """Provision Host on libvirt compute resource, and delete it afterwards @@ -146,12 +148,14 @@ def test_positive_provision_end_to_end( :customerscenario: true - :BZ: 1243223 + :BZ: 1243223, 2236693 :parametrized: yes """ sat = module_libvirt_provisioning_sat.sat hostname = gen_string('alpha').lower() + os_major_ver = module_provisioning_rhel_content.os.major + cpu_mode = 'host-passthrough' if is_open('BZ:2236693') and os_major_ver == '9' else 'default' cr = sat.api.LibvirtComputeResource( provider=FOREMAN_PROVIDERS['libvirt'], url=LIBVIRT_URL, @@ -169,6 +173,7 @@ def test_positive_provision_end_to_end( 'host.inherit_deploy_option': False, 'host.deploy': f'{cr.name} (Libvirt)', 'provider_content.virtual_machine.memory': '6144', + 'provider_content.virtual_machine.cpu_mode': cpu_mode, 'interfaces.interface.network_type': 'Physical (Bridge)', 'interfaces.interface.network': f'br-{settings.provisioning.vlan_id}', 'additional_information.comment': 'Libvirt provision using valid data', From f07dc87e0ab650f0b609d9ac3fce5bb13bc7dd17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maty=C3=A1=C5=A1=20Strelec?= Date: Fri, 27 Oct 2023 18:41:46 +0200 Subject: [PATCH 18/30] Update `test_positive_all_packages_update` (#12342) * add test_positive_fm_packages_check_update * add capsule marker * add regex to find packages to update * remove duplicate test * update regex to match if there's multiple packages (cherry picked from commit b2d4f9832ac250848a17959f47c2736a648b15e5) --- tests/foreman/destructive/test_packages.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/foreman/destructive/test_packages.py b/tests/foreman/destructive/test_packages.py index 3a31e354e46..05c44bf1501 100644 --- a/tests/foreman/destructive/test_packages.py +++ b/tests/foreman/destructive/test_packages.py @@ -16,11 +16,14 @@ :Upstream: No """ +import re + import pytest pytestmark = pytest.mark.destructive +@pytest.mark.include_capsule def test_positive_all_packages_update(target_sat): """Verify update and check-update work as expected. @@ -48,5 +51,10 @@ def test_positive_all_packages_update(target_sat): target_sat.power_control(state='reboot') # Run check-update again to verify there are no more packages available to update result = target_sat.cli.Packages.check_update() + # Regex to match if there are packages available to update + # Matches lines like '\n\nwalrus.noarch 5.21-1 custom_repo\n' + pattern = '(\\n){1,2}(\\S+)(\\s+)(\\S+)(\\s+)(\\S+)(\\n)' + matches = re.search(pattern, result.stdout) + assert matches is None # No packages available to update assert 'FAIL' not in result.stdout assert result.status == 0 From 1342ce97fed151444d3c1b5995cee02cc6e3997e Mon Sep 17 00:00:00 2001 From: Satellite QE <115476073+Satellite-QE@users.noreply.github.com> Date: Tue, 31 Oct 2023 06:01:11 -0400 Subject: [PATCH 19/30] [6.13.z] Fix Client repos in constants (#13009) Fix Client repos in constants (#13008) (cherry picked from commit c7d24e8540b7d9feced3480f387a613a2def7946) Co-authored-by: vsedmik <46570670+vsedmik@users.noreply.github.com> --- robottelo/constants/__init__.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/robottelo/constants/__init__.py b/robottelo/constants/__init__.py index 919017c16f5..a51263410c3 100644 --- a/robottelo/constants/__init__.py +++ b/robottelo/constants/__init__.py @@ -287,9 +287,9 @@ class Colored(Box): 'rhsc7': 'Red Hat Satellite Capsule 6.11 (for RHEL 7 Server) (RPMs)', 'rhsc8': 'Red Hat Satellite Capsule 6.13 for RHEL 8 x86_64 (RPMs)', 'rhsc7_iso': 'Red Hat Satellite Capsule 6.4 (for RHEL 7 Server) (ISOs)', - 'rhsclient7': 'Red Hat Satellite Client 6 for RHEL 7 Server RPMs x86_64', - 'rhsclient8': 'Red Hat Satellite Client 6 for RHEL 8 x86_64 RPMs', - 'rhsclient9': 'Red Hat Satellite Client 6 for RHEL 9 x86_64 RPMs', + 'rhsclient7': 'Red Hat Satellite Client 6 (for RHEL 7 Server) (RPMs)', + 'rhsclient8': 'Red Hat Satellite Client 6 for RHEL 8 x86_64 (RPMs)', + 'rhsclient9': 'Red Hat Satellite Client 6 for RHEL 9 x86_64 (RPMs)', 'rhst7': 'Red Hat Satellite Tools 6.9 (for RHEL 7 Server) (RPMs)', 'rhst7_610': 'Red Hat Satellite Tools 6.10 (for RHEL 7 Server) (RPMs)', 'rhst6': 'Red Hat Satellite Tools 6.9 (for RHEL 6 Server) (RPMs)', @@ -406,7 +406,7 @@ class Colored(Box): 'name': ('Red Hat Satellite Client 6 for RHEL 8 x86_64 RPMs'), 'version': '6', 'reposet': REPOSET['rhsclient8'], - 'product': PRDS['rhel'], + 'product': PRDS['rhel8'], 'distro': 'rhel8', 'key': PRODUCT_KEY_SAT_CLIENT, }, @@ -415,7 +415,7 @@ class Colored(Box): 'name': ('Red Hat Satellite Client 6 for RHEL 9 x86_64 RPMs'), 'version': '6', 'reposet': REPOSET['rhsclient9'], - 'product': PRDS['rhel'], + 'product': PRDS['rhel9'], 'distro': 'rhel9', 'key': PRODUCT_KEY_SAT_CLIENT, }, From 7cd620bd3818bc42631c1820f1bd9786595cacf1 Mon Sep 17 00:00:00 2001 From: Satellite QE <115476073+Satellite-QE@users.noreply.github.com> Date: Tue, 31 Oct 2023 06:47:53 -0400 Subject: [PATCH 20/30] [6.13.z] sync RHOSP repos to capsule (#13006) sync RHOSP repos to capsule (#12990) (cherry picked from commit ad951328f74cb3a6af418a3292212a346c1b3348) Co-authored-by: vijay sawant --- tests/foreman/api/test_capsulecontent.py | 69 ++++++++++++++++++++++++ 1 file changed, 69 insertions(+) diff --git a/tests/foreman/api/test_capsulecontent.py b/tests/foreman/api/test_capsulecontent.py index bced65e6853..ed436479831 100644 --- a/tests/foreman/api/test_capsulecontent.py +++ b/tests/foreman/api/test_capsulecontent.py @@ -1355,3 +1355,72 @@ def test_positive_remove_capsule_orphans( 'ls /var/lib/pulp/media/artifact/*/* | xargs file | grep RPM' ) assert result.status, 'RPM artifacts are still present. They should be gone.' + + @pytest.mark.skip_if_not_set('capsule') + def test_positive_capsule_sync_openstack_container_repos( + self, + module_target_sat, + module_capsule_configured, + function_org, + function_product, + function_lce, + ): + """Synchronize openstack container repositories to capsule + + :id: 23e64385-7f34-4ab9-bd63-72306e5a4de0 + + :setup: + 1. A blank external capsule that has not been synced yet. + + :steps: + 1. Enable and sync openstack container repos. + + :expectedresults: + 1. container repos should sync on capsule. + + :customerscenario: true + + :BZ: 2154734 + + """ + upstream_names = [ + 'rhosp13/openstack-cinder-api', + 'rhosp13/openstack-neutron-server', + 'rhosp13/openstack-neutron-dhcp-agent', + 'rhosp13/openstack-nova-api', + ] + repos = [] + + for ups_name in upstream_names: + repo = module_target_sat.api.Repository( + content_type='docker', + docker_upstream_name=ups_name, + product=function_product, + url=constants.RH_CONTAINER_REGISTRY_HUB, + upstream_username=settings.subscription.rhn_username, + upstream_password=settings.subscription.rhn_password, + ).create() + repo.sync(timeout=1800) + repos.append(repo) + + # Associate LCE with the capsule + module_capsule_configured.nailgun_capsule.content_add_lifecycle_environment( + data={'environment_id': function_lce.id} + ) + result = module_capsule_configured.nailgun_capsule.content_lifecycle_environments() + assert len(result['results']) + assert function_lce.id in [capsule_lce['id'] for capsule_lce in result['results']] + + # Create and publish a content view with all repositories + cv = module_target_sat.api.ContentView(organization=function_org, repository=repos).create() + cv.publish() + cv = cv.read() + assert len(cv.version) == 1 + + # Promote the latest CV version into capsule's LCE + cvv = cv.version[-1].read() + cvv.promote(data={'environment_ids': function_lce.id}) + cvv = cvv.read() + assert len(cvv.environment) == 2 + + module_capsule_configured.wait_for_sync() From e0941b89db87301b16fe1242fa6a3f4cb7acc963 Mon Sep 17 00:00:00 2001 From: Satellite QE <115476073+Satellite-QE@users.noreply.github.com> Date: Tue, 31 Oct 2023 06:56:33 -0400 Subject: [PATCH 21/30] [6.13.z] Discovery coverage for rule priority/limit/provisioning (#13011) Discovery coverage for rule priority/limit/provisioning (#12962) * Discovery coverage for rule priority/limit/provisioning * Adding parametrization for broker workflow (cherry picked from commit 176f5abe3caac419370d5a66539e55b1c6bc4dd0) Co-authored-by: Adarsh dubey --- pytest_fixtures/component/provision_pxe.py | 27 +++++ tests/foreman/api/test_discoveredhost.py | 45 ++++++-- tests/foreman/api/test_discoveryrule.py | 122 ++++++++++----------- 3 files changed, 118 insertions(+), 76 deletions(-) diff --git a/pytest_fixtures/component/provision_pxe.py b/pytest_fixtures/component/provision_pxe.py index d4f835a60a9..0b800778eb8 100644 --- a/pytest_fixtures/component/provision_pxe.py +++ b/pytest_fixtures/component/provision_pxe.py @@ -231,6 +231,33 @@ def provisioning_host(module_ssh_key_file, pxe_loader): prov_host.blank = getattr(prov_host, 'blank', False) +@pytest.fixture +def provision_multiple_hosts(module_ssh_key_file, pxe_loader, request): + """Fixture to check out two blank VMs""" + vlan_id = settings.provisioning.vlan_id + cd_iso = ( + "" # TODO: Make this an optional fixture parameter (update vm_firmware when adding this) + ) + # Keeping the default value to 2 + count = request.param if request.param is not None else 2 + + with Broker( + workflow="deploy-configure-pxe-provisioning-host-rhv", + host_class=ContentHost, + _count=count, + target_vlan_id=vlan_id, + target_vm_firmware=pxe_loader.vm_firmware, + target_vm_cd_iso=cd_iso, + blank=True, + target_memory='6GiB', + auth=module_ssh_key_file, + ) as hosts: + yield hosts + + for prov_host in hosts: + prov_host.blank = getattr(prov_host, 'blank', False) + + @pytest.fixture def provisioning_hostgroup( module_provisioning_sat, diff --git a/tests/foreman/api/test_discoveredhost.py b/tests/foreman/api/test_discoveredhost.py index 773175812cf..895bc252d1c 100644 --- a/tests/foreman/api/test_discoveredhost.py +++ b/tests/foreman/api/test_discoveredhost.py @@ -339,7 +339,7 @@ def test_positive_auto_provision_all( @pytest.mark.stubbed @pytest.mark.tier3 - def test_positive_refresh_facts_pxe_host(self): + def test_positive_refresh_facts_pxe_host(self, module_target_sat): """Refresh the facts of pxe based discovered hosts by adding a new NIC :id: 413fb608-cd5c-441d-af86-fd2d40346d96 @@ -354,14 +354,12 @@ def test_positive_refresh_facts_pxe_host(self): :expectedresults: Added Fact should be displayed on refreshing the facts - :CaseAutomation: NotAutomated - :CaseImportance: High """ @pytest.mark.on_premises_provisioning @pytest.mark.parametrize('module_provisioning_sat', ['discovery'], indirect=True) - @pytest.mark.parametrize('pxe_loader', ['bios', 'uefi'], indirect=True) + @pytest.mark.parametrize('pxe_loader', ['uefi'], indirect=True) @pytest.mark.rhel_ver_match('9') @pytest.mark.tier3 def test_positive_reboot_pxe_host( @@ -394,6 +392,7 @@ def test_positive_reboot_pxe_host( timeout=240, delay=20, ) + discovered_host = sat.api.DiscoveredHost().search(query={'mac': mac})[0] discovered_host.hostgroup = provisioning_hostgroup discovered_host.location = provisioning_hostgroup.location[0] @@ -402,25 +401,51 @@ def test_positive_reboot_pxe_host( result = sat.api.DiscoveredHost(id=discovered_host.id).reboot() assert 'Unable to perform reboot' not in result - @pytest.mark.stubbed + @pytest.mark.on_premises_provisioning + @pytest.mark.parametrize('module_provisioning_sat', ['discovery'], indirect=True) + @pytest.mark.parametrize('pxe_loader', ['bios'], indirect=True) + @pytest.mark.rhel_ver_match('9') + @pytest.mark.parametrize('provision_multiple_hosts', [2]) @pytest.mark.tier3 - def test_positive_reboot_all_pxe_hosts(self): + def test_positive_reboot_all_pxe_hosts( + self, + module_provisioning_rhel_content, + module_discovery_sat, + provision_multiple_hosts, + provisioning_hostgroup, + pxe_loader, + count, + ): """Rebooting all pxe-based discovered hosts :id: 69c807f8-5646-4aa6-8b3c-5ecdb69560ed :parametrized: yes - :Setup: Provisioning should be configured and a hosts should be discovered via PXE boot. + :Setup: Provisioning should be configured and hosts should be discovered via PXE boot. :Steps: PUT /api/v2/discovered_hosts/reboot_all - :expectedresults: All disdcovered host should be rebooted successfully - - :CaseAutomation: Automated + :expectedresults: All discovered hosst should be rebooted successfully :CaseImportance: Medium """ + sat = module_discovery_sat.sat + for host in provision_multiple_hosts: + host.power_control(ensure=False) + mac = host._broker_args['provisioning_nic_mac_addr'] + wait_for( + lambda: sat.api.DiscoveredHost().search(query={'mac': mac}) != [], + timeout=240, + delay=20, + ) + discovered_host = sat.api.DiscoveredHost().search(query={'mac': mac})[0] + discovered_host.hostgroup = provisioning_hostgroup + discovered_host.location = provisioning_hostgroup.location[0] + discovered_host.organization = provisioning_hostgroup.organization[0] + discovered_host.build = True + result = sat.api.DiscoveredHost().reboot_all() + assert 'Discovered hosts are rebooting now' in result['message'] class TestFakeDiscoveryTests: diff --git a/tests/foreman/api/test_discoveryrule.py b/tests/foreman/api/test_discoveryrule.py index f55a287d675..51ac5fec162 100644 --- a/tests/foreman/api/test_discoveryrule.py +++ b/tests/foreman/api/test_discoveryrule.py @@ -16,36 +16,16 @@ :Upstream: No """ -from fauxfactory import gen_choice, gen_integer, gen_string -from nailgun import entities +from fauxfactory import gen_choice, gen_integer import pytest from requests.exceptions import HTTPError from robottelo.utils.datafactory import valid_data_list -@pytest.fixture(scope="module") -def module_hostgroup(module_org): - module_hostgroup = entities.HostGroup(organization=[module_org]).create() - yield module_hostgroup - module_hostgroup.delete() - - -@pytest.fixture(scope="module") -def module_location(module_location): - yield module_location - module_location.delete() - - -@pytest.fixture(scope="module") -def module_org(module_org): - yield module_org - module_org.delete() - - @pytest.mark.tier1 @pytest.mark.e2e -def test_positive_end_to_end_crud(module_org, module_location, module_hostgroup): +def test_positive_end_to_end_crud(module_org, module_location, module_hostgroup, target_sat): """Create a new discovery rule with several attributes, update them and delete the rule itself. @@ -67,7 +47,7 @@ def test_positive_end_to_end_crud(module_org, module_location, module_hostgroup) name = gen_choice(list(valid_data_list().values())) search = gen_choice(searches) hostname = 'myhost-<%= rand(99999) %>' - discovery_rule = entities.DiscoveryRule( + discovery_rule = target_sat.api.DiscoveryRule( name=name, search_=search, hostname=hostname, @@ -103,23 +83,10 @@ def test_positive_end_to_end_crud(module_org, module_location, module_hostgroup) discovery_rule.read() -@pytest.mark.tier1 -def test_negative_create_with_invalid_host_limit_and_priority(): - """Create a discovery rule with invalid host limit and priority - - :id: e3c7acb1-ac56-496b-ac04-2a83f66ec290 - - :expectedresults: Validation error should be raised - """ - with pytest.raises(HTTPError): - entities.DiscoveryRule(max_count=gen_string('alpha')).create() - with pytest.raises(HTTPError): - entities.DiscoveryRule(priority=gen_string('alpha')).create() - - -@pytest.mark.stubbed @pytest.mark.tier3 -def test_positive_provision_with_rule_priority(): +def test_positive_update_and_provision_with_rule_priority( + module_target_sat, module_discovery_hostgroup, discovery_location, discovery_org +): """Create multiple discovery rules with different priority and check rule with highest priority executed first @@ -130,44 +97,67 @@ def test_positive_provision_with_rule_priority(): :expectedresults: Host with lower count have higher priority and that rule should be executed first - :CaseAutomation: NotAutomated - :CaseImportance: High """ + discovered_host = module_target_sat.api_factory.create_discovered_host() + + prio_rule = module_target_sat.api.DiscoveryRule( + max_count=5, + hostgroup=module_discovery_hostgroup, + search_=f'name = {discovered_host["name"]}', + location=[discovery_location], + organization=[discovery_org], + priority=1, + ).create() + rule = module_target_sat.api.DiscoveryRule( + max_count=5, + hostgroup=module_discovery_hostgroup, + search_=f'name = {discovered_host["name"]}', + location=[discovery_location], + organization=[discovery_org], + priority=10, + ).create() -@pytest.mark.stubbed -@pytest.mark.tier3 -def test_positive_multi_provision_with_rule_limit(): - """Create a discovery rule (CPU_COUNT = 2) with host limit 1 and - provision more than 2 hosts with same rule - - :id: 553c8ebf-d1c1-4ac2-7948-d3664a5b450b - - :Setup: Hosts with two CPUs should already be discovered - - :expectedresults: Rule should only be applied to 2 discovered hosts - and the rule should already be skipped for the 3rd one. - - :CaseAutomation: NotAutomated + result = module_target_sat.api.DiscoveredHost(id=discovered_host['id']).auto_provision() + assert f'provisioned with rule {prio_rule.name}' in result['message'] - :CaseImportance: High - """ + # Delete discovery rule + for _ in rule, prio_rule: + _.delete() + with pytest.raises(HTTPError): + _.read() -@pytest.mark.stubbed @pytest.mark.tier3 -def test_positive_provision_with_updated_discovery_rule(): - """Update an existing rule and provision a host with it. +def test_positive_multi_provision_with_rule_limit( + module_target_sat, module_discovery_hostgroup, discovery_location, discovery_org +): + """Create a discovery rule with certain host limit and try to provision more than the passed limit - :id: 3fb20f0f-02e9-4158-9744-f583308c4e89 - - :Setup: Host should already be discovered + :id: 553c8ebf-d1c1-4ac2-7948-d3664a5b450b - :expectedresults: User should be able to update the rule and it should - be applied on discovered host + :Setup: Hosts should already be discovered - :CaseAutomation: NotAutomated + :expectedresults: Rule should only be applied to the number of the hosts passed as limit in the rule :CaseImportance: High """ + for _ in range(2): + discovered_host = module_target_sat.api_factory.create_discovered_host() + + rule = module_target_sat.api.DiscoveryRule( + max_count=1, + hostgroup=module_discovery_hostgroup, + search_=f'name = {discovered_host["name"]}', + location=[discovery_location], + organization=[discovery_org], + priority=1000, + ).create() + result = module_target_sat.api.DiscoveredHost().auto_provision_all() + assert '1 discovered hosts were provisioned' in result['message'] + + # Delete discovery rule + rule.delete() + with pytest.raises(HTTPError): + rule.read() From 7216f6f8195caa1b2eb4d7770450087b7d868d9a Mon Sep 17 00:00:00 2001 From: Satellite QE <115476073+Satellite-QE@users.noreply.github.com> Date: Tue, 31 Oct 2023 06:58:18 -0400 Subject: [PATCH 22/30] [6.13.z] Remove skip marker from test (#13014) --- tests/foreman/api/test_registration.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/foreman/api/test_registration.py b/tests/foreman/api/test_registration.py index 9d184f029f5..d9267bb5d2f 100644 --- a/tests/foreman/api/test_registration.py +++ b/tests/foreman/api/test_registration.py @@ -89,7 +89,6 @@ def test_host_registration_end_to_end( @pytest.mark.tier3 @pytest.mark.rhel_ver_match('[^6]') -@pytest.mark.skip_if_open("BZ:2229112") def test_positive_allow_reregistration_when_dmi_uuid_changed( module_org, rhel_contenthost, target_sat, module_ak_with_synced_repo, module_location ): From 7329c9d62f04f2a03735d735cc99cb2287a85a3d Mon Sep 17 00:00:00 2001 From: Satellite QE <115476073+Satellite-QE@users.noreply.github.com> Date: Tue, 31 Oct 2023 19:42:59 -0400 Subject: [PATCH 23/30] [6.13.z] ISS refactor - batch 3 (#13019) --- tests/foreman/cli/test_satellitesync.py | 240 ++++++++++++++++++++---- 1 file changed, 199 insertions(+), 41 deletions(-) diff --git a/tests/foreman/cli/test_satellitesync.py b/tests/foreman/cli/test_satellitesync.py index d5a5cfdf9f6..a4c71f13d80 100644 --- a/tests/foreman/cli/test_satellitesync.py +++ b/tests/foreman/cli/test_satellitesync.py @@ -17,10 +17,12 @@ :Upstream: No """ import os +from time import sleep from fauxfactory import gen_string from manifester import Manifester import pytest +from wait_for import wait_for from robottelo.cli.base import CLIReturnCodeError from robottelo.cli.content_export import ContentExport @@ -46,6 +48,7 @@ PULP_IMPORT_DIR, REPO_TYPE, REPOS, + DataFile, ) from robottelo.constants.repos import ANSIBLE_GALAXY @@ -486,41 +489,6 @@ def _create_cv(cv_name, repo, module_org, publish=True): return content_view, cvv_id -def _import_entities(product, repo, cv, mos='no'): - """Sets same CV, product and repository in importing organization as - exporting organization - - :param str product: The product name same as exporting product - :param str repo: The repo name same as exporting repo - :param str cv: The cv name same as exporting cv - :param str mos: Mirror on Sync repo, by default 'no' can override to 'yes' - :returns dictionary with CLI entities created in this function - """ - importing_org = make_org() - importing_prod = make_product({'organization-id': importing_org['id'], 'name': product}) - importing_repo = make_repository( - { - 'name': repo, - 'mirror-on-sync': mos, - 'download-policy': 'immediate', - 'product-id': importing_prod['id'], - } - ) - importing_cv = make_content_view({'name': cv, 'organization-id': importing_org['id']}) - ContentView.add_repository( - { - 'id': importing_cv['id'], - 'organization-id': importing_org['id'], - 'repository-id': importing_repo['id'], - } - ) - return { - 'importing_org': importing_org, - 'importing_repo': importing_repo, - 'importing_cv': importing_cv, - } - - class TestContentViewSync: """Implements Content View Export Import tests in CLI""" @@ -1333,6 +1301,107 @@ def test_postive_export_import_cv_with_file_content( assert len(imported_files) assert len(exported_files) == len(imported_files) + @pytest.mark.tier2 + @pytest.mark.parametrize( + 'function_synced_rhel_repo', + ['rhae2'], + indirect=True, + ) + def test_positive_export_rerun_failed_import( + self, + target_sat, + config_export_import_settings, + export_import_cleanup_function, + function_synced_rhel_repo, + function_sca_manifest_org, + function_import_org_with_manifest, + ): + """Verify that import can be rerun successfully after failed import. + + :id: 73e7cece-9a93-4203-9c2c-813d5a8d7700 + + :parametrized: yes + + :setup: + 1. Enabled and synced RH repository. + + :steps: + 1. Create CV, add repo from the setup, publish it and run export. + 2. Start import of the CV into another organization and kill it before it's done. + 3. Rerun the import again, let it finish and check the CVV was imported. + + :expectedresults: + 1. First import should fail, no CVV should be added. + 2. Second import should succeed without errors and should contain the CVV. + + :CaseImportance: Medium + + :BZ: 2058905 + + :customerscenario: true + """ + # Create CV and publish + cv_name = gen_string('alpha') + cv = target_sat.cli_factory.make_content_view( + {'name': cv_name, 'organization-id': function_sca_manifest_org.id} + ) + target_sat.cli.ContentView.add_repository( + { + 'id': cv['id'], + 'organization-id': function_sca_manifest_org.id, + 'repository-id': function_synced_rhel_repo['id'], + } + ) + target_sat.cli.ContentView.publish({'id': cv['id']}) + cv = target_sat.cli.ContentView.info({'id': cv['id']}) + assert len(cv['versions']) == 1 + cvv = cv['versions'][0] + # Verify export directory is empty + assert target_sat.validate_pulp_filepath(function_sca_manifest_org, PULP_EXPORT_DIR) == '' + # Export the CV + export = target_sat.cli.ContentExport.completeVersion( + {'id': cvv['id'], 'organization-id': function_sca_manifest_org.id} + ) + import_path = target_sat.move_pulp_archive(function_sca_manifest_org, export['message']) + assert target_sat.execute(f'ls {import_path}').stdout != '' + # Run the import asynchronously + task_id = target_sat.cli.ContentImport.version( + { + 'organization-id': function_import_org_with_manifest.id, + 'path': import_path, + 'async': True, + } + )['id'] + # Wait for the CV creation on import and make the import fail + wait_for( + lambda: target_sat.cli.ContentView.info( + {'name': cv_name, 'organization-id': function_import_org_with_manifest.id} + ) + ) + target_sat.cli.Service.restart() + sleep(30) + # Assert that the initial import task did not succeed and CVV was removed + assert ( + target_sat.api.ForemanTask() + .search( + query={'search': f'Actions::Katello::ContentViewVersion::Import and id = {task_id}'} + )[0] + .result + != 'success' + ) + importing_cvv = target_sat.cli.ContentView.info( + {'name': cv_name, 'organization-id': function_import_org_with_manifest.id} + )['versions'] + assert len(importing_cvv) == 0 + # Rerun the import and let it finish + target_sat.cli.ContentImport.version( + {'organization-id': function_import_org_with_manifest.id, 'path': import_path} + ) + importing_cvv = target_sat.cli.ContentView.info( + {'name': cv_name, 'organization-id': function_import_org_with_manifest.id} + )['versions'] + assert len(importing_cvv) == 1 + @pytest.mark.tier3 def test_postive_export_import_ansible_collection_repo( self, @@ -1390,6 +1459,73 @@ def test_postive_export_import_ansible_collection_repo( assert len(import_product['content']) == 1 assert import_product['content'][0]['content-type'] == "ansible_collection" + @pytest.mark.tier3 + def test_postive_export_import_repo_with_GPG( + self, + target_sat, + config_export_import_settings, + export_import_cleanup_function, + function_org, + function_synced_custom_repo, + function_import_org, + ): + """Test export and import of a repository with GPG key + + :id: a5b455aa-e87e-4ae5-a1c7-4c8e6c7f7af5 + + :setup: + 1. Product with synced custom repository. + + :steps: + 1. Create a GPG key and add it to the setup repository. + 2. Export the repository and import it into another organization. + + :expectedresults: + 1. Export and import succeeds without any errors. + 2. GPG key is imported to the importing org too. + + :CaseImportance: Medium + + :BZ: 2178645, 2090390 + + :customerscenario: true + """ + # Create a GPG key and add it to the setup repository. + gpg_key = target_sat.api.GPGKey( + organization=function_org, + content=DataFile.VALID_GPG_KEY_FILE.read_text(), + ).create() + target_sat.cli.Repository.update( + {'id': function_synced_custom_repo.id, 'gpg-key-id': gpg_key.id} + ) + # Export the repository and import it into another organization. + export = target_sat.cli.ContentExport.completeRepository( + {'id': function_synced_custom_repo.id} + ) + import_path = target_sat.move_pulp_archive(function_org, export['message']) + target_sat.cli.ContentImport.repository( + { + 'organization-id': function_import_org.id, + 'path': import_path, + } + ) + # Check the imported repo has the GPG key assigned. + imported_repo = target_sat.cli.Repository.info( + { + 'name': function_synced_custom_repo.name, + 'product': function_synced_custom_repo.product.name, + 'organization-id': function_import_org.id, + } + ) + assert int(imported_repo['content-counts']['packages']) + assert imported_repo['gpg-key']['name'] == gpg_key.name + # Check the GPG key is imported to the importing org too. + imported_gpg = target_sat.cli.ContentCredential.info( + {'organization-id': function_import_org.id, 'name': gpg_key.name} + ) + assert imported_gpg + assert imported_gpg['content'] == gpg_key.content + @pytest.mark.tier3 @pytest.mark.parametrize( 'function_synced_rhel_repo', @@ -1480,13 +1616,15 @@ def test_positive_import_content_for_disconnected_sat_with_existing_content( 1. Product with synced custom repository, published in a CV. :steps: - 1. Run complete export of the CV. - 2. On Disconnected satellite, create a cv with same name as cv on 2 and with - 'import-only' selected. - 3. Run the import command. + 1. Run complete export of the CV from setup. + 2. On Disconnected satellite, create a CV with the same name as setup CV and with + 'import-only' set to False and run the import command. + 3. On Disconnected satellite, create a CV with the same name as setup CV and with + 'import-only' set to True and run the import command. :expectedresults: - 1. Import should run successfully + 1. Import should fail with correct message when existing CV has 'import-only' set False. + 2. Import should succeed when existing CV has 'import-only' set True. :bz: 2030101 @@ -1505,7 +1643,27 @@ def test_positive_import_content_for_disconnected_sat_with_existing_content( result = target_sat.execute(f'ls {import_path}') assert result.stdout != '' # Import section - # Create cv with 'import-only' set to true + # Create cv with 'import-only' set to False + cv = target_sat.cli_factory.make_content_view( + { + 'name': export_cv_name, + 'import-only': False, + 'organization-id': function_import_org.id, + } + ) + with pytest.raises(CLIReturnCodeError) as error: + target_sat.cli.ContentImport.version( + {'organization-id': function_import_org.id, 'path': import_path} + ) + assert ( + f"Unable to import in to Content View specified in the metadata - '{export_cv_name}'. " + "The 'import_only' attribute for the content view is set to false. To mark this " + "Content View as importable, have your system administrator run the following command " + f"on the server. \n foreman-rake katello:set_content_view_import_only ID={cv.id}" + ) in error.value.message + target_sat.cli.ContentView.remove({'id': cv.id, 'destroy-content-view': 'yes'}) + + # Create cv with 'import-only' set to True target_sat.cli_factory.make_content_view( {'name': export_cv_name, 'import-only': True, 'organization-id': function_import_org.id} ) From c7c515185f37f1ab521bf4e308025d699f652cae Mon Sep 17 00:00:00 2001 From: Satellite QE <115476073+Satellite-QE@users.noreply.github.com> Date: Tue, 31 Oct 2023 23:40:57 -0400 Subject: [PATCH 24/30] [6.13.z] Bump dynaconf[vault] from 3.2.3 to 3.2.4 (#13024) --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index e358db72504..aa4168050a1 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,7 +4,7 @@ betelgeuse==1.10.0 broker[docker]==0.4.1 cryptography==41.0.5 deepdiff==6.6.1 -dynaconf[vault]==3.2.3 +dynaconf[vault]==3.2.4 fauxfactory==3.1.0 jinja2==3.1.2 manifester==0.0.14 From 55856d82ae4563d7f43d49da57022a2542ad1ef2 Mon Sep 17 00:00:00 2001 From: Satellite QE <115476073+Satellite-QE@users.noreply.github.com> Date: Wed, 1 Nov 2023 04:57:43 -0400 Subject: [PATCH 25/30] [6.13.z] Convert2Rhel test fixes (#12522) Convert2Rhel test fixes (#10840) (cherry picked from commit 55b0800effd67331753d74aa423d20f749f2b630) Co-authored-by: Shweta Singh --- tests/foreman/api/test_convert2rhel.py | 150 ++++++++++++++++--------- 1 file changed, 94 insertions(+), 56 deletions(-) diff --git a/tests/foreman/api/test_convert2rhel.py b/tests/foreman/api/test_convert2rhel.py index a8a450b3809..ce2e78d85b2 100644 --- a/tests/foreman/api/test_convert2rhel.py +++ b/tests/foreman/api/test_convert2rhel.py @@ -47,6 +47,12 @@ def create_activation_key(sat, org, lce, cv, subscription_id): environment=lce, ).create() act_key.add_subscriptions(data={'subscription_id': subscription_id}) + content = sat.cli.ActivationKey.product_content({'id': act_key.id, 'organization-id': org.id}) + act_key.content_override( + data={'content_overrides': [{'content_label': content[0]['label'], 'value': '1'}]} + ) + ak_subscriptions = act_key.product_content()['results'] + ak_subscriptions[0]['enabled'] = True return act_key @@ -59,11 +65,11 @@ def update_cv(sat, cv, lce, repos): return cv -def register_host(sat, act_key, module_org, module_loc, host, ubi=None): +def register_host(sat, act_key, org, module_loc, host, ubi=None): """Register host to satellite""" # generate registration command command = sat.api.RegistrationCommand( - organization=module_org, + organization=org, activation_keys=[act_key.name], location=module_loc, insecure=True, @@ -83,13 +89,21 @@ def ssl_cert(module_target_sat, module_org): @pytest.fixture -def activation_key_rhel(target_sat, module_org, module_lce, module_promoted_cv, version): +def activation_key_rhel( + module_target_sat, module_entitlement_manifest_org, module_lce, module_promoted_cv, version +): """Create activation key that will be used after conversion for registration""" - subs = target_sat.api.Subscription(organization=module_org).search( - query={'search': f'{DEFAULT_SUBSCRIPTION_NAME}'} - ) + subs = module_target_sat.api.Subscription( + organization=module_entitlement_manifest_org.id + ).search(query={'search': f'{DEFAULT_SUBSCRIPTION_NAME}'}) assert subs - return create_activation_key(target_sat, module_org, module_lce, module_promoted_cv, subs[0].id) + return create_activation_key( + module_target_sat, + module_entitlement_manifest_org, + module_lce, + module_promoted_cv, + subs[0].id, + ) @pytest.fixture(scope='module') @@ -123,6 +137,8 @@ def enable_rhel_subscriptions(module_target_sat, module_entitlement_manifest_org module_target_sat.wait_for_tasks( search_query=(f'id = {task["id"]}'), poll_timeout=2500, + search_rate=20, + max_tries=10, ) task_status = module_target_sat.api.ForemanTask(id=task['id']).poll() assert task_status['result'] == 'success' @@ -131,9 +147,9 @@ def enable_rhel_subscriptions(module_target_sat, module_entitlement_manifest_org @pytest.fixture def centos( - target_sat, + module_target_sat, centos_host, - module_org, + module_entitlement_manifest_org, smart_proxy_location, module_promoted_cv, module_lce, @@ -144,15 +160,28 @@ def centos( # updating centos packages on CentOS 8 is necessary for conversion major = version.split('.')[0] if major == '8': - centos_host.execute("yum update -y centos-*") + centos_host.execute('yum -y update centos-*') repo_url = settings.repos.convert2rhel.convert_to_rhel_repo.format(major) - repo = create_repo(target_sat, module_org, repo_url) - cv = update_cv(target_sat, module_promoted_cv, module_lce, enable_rhel_subscriptions + [repo]) - c2r_sub = target_sat.api.Subscription(organization=module_org, name=repo.product.name).search()[ - 0 - ] - act_key = create_activation_key(target_sat, module_org, module_lce, cv, c2r_sub.id) - register_host(target_sat, act_key, module_org, smart_proxy_location, centos_host) + repo = create_repo(module_target_sat, module_entitlement_manifest_org, repo_url) + cv = update_cv( + module_target_sat, module_promoted_cv, module_lce, enable_rhel_subscriptions + [repo] + ) + c2r_sub = module_target_sat.api.Subscription( + organization=module_entitlement_manifest_org.id, name=repo.product.name + ).search()[0] + act_key = create_activation_key( + module_target_sat, module_entitlement_manifest_org, module_lce, cv, c2r_sub.id + ) + register_host( + module_target_sat, + act_key, + module_entitlement_manifest_org, + smart_proxy_location, + centos_host, + ) + centos_host.execute('yum -y update kernel*') + if centos_host.execute('needs-restarting -r').status == 1: + centos_host.power_control(state='reboot') yield centos_host # close ssh session before teardown, because of reboot in conversion it may cause problems centos_host.close() @@ -160,9 +189,9 @@ def centos( @pytest.fixture def oracle( - target_sat, + module_target_sat, oracle_host, - module_org, + module_entitlement_manifest_org, smart_proxy_location, module_promoted_cv, module_lce, @@ -183,16 +212,27 @@ def oracle( oracle_host.power_control(state='reboot') major = version.split('.')[0] repo_url = settings.repos.convert2rhel.convert_to_rhel_repo.format(major) - repo = create_repo(target_sat, module_org, repo_url, ssl_cert) - cv = update_cv(target_sat, module_promoted_cv, module_lce, enable_rhel_subscriptions + [repo]) - c2r_sub = target_sat.api.Subscription(organization=module_org, name=repo.product.name).search()[ - 0 - ] - act_key = create_activation_key(target_sat, module_org, module_lce, cv, c2r_sub.id) + repo = create_repo(module_target_sat, module_entitlement_manifest_org, repo_url, ssl_cert) + cv = update_cv( + module_target_sat, module_promoted_cv, module_lce, enable_rhel_subscriptions + [repo] + ) + c2r_sub = module_target_sat.api.Subscription( + organization=module_entitlement_manifest_org, name=repo.product.name + ).search()[0] + act_key = create_activation_key( + module_target_sat, module_entitlement_manifest_org, module_lce, cv, c2r_sub.id + ) ubi_url = settings.repos.convert2rhel.ubi7 if major == '7' else settings.repos.convert2rhel.ubi8 - ubi = create_repo(target_sat, module_org, ubi_url) + ubi = create_repo(module_target_sat, module_entitlement_manifest_org, ubi_url) ubi_repo = ubi.full_path.replace('https', 'http') - register_host(target_sat, act_key, module_org, smart_proxy_location, oracle_host, ubi_repo) + register_host( + module_target_sat, + act_key, + module_entitlement_manifest_org, + smart_proxy_location, + oracle_host, + ubi_repo, + ) yield oracle_host # close ssh session before teardown, because of reboot in conversion it may cause problems oracle_host.close() @@ -201,7 +241,7 @@ def oracle( @pytest.fixture(scope='module') def version(request): """Version of converted OS""" - return settings.content_host.get(request.param).vm.release + return settings.content_host.get(request.param).vm.deploy_rhel_version @pytest.mark.e2e @@ -210,7 +250,7 @@ def version(request): ['oracle7', 'oracle8'], indirect=True, ) -def test_convert2rhel_oracle(target_sat, oracle, activation_key_rhel, version): +def test_convert2rhel_oracle(module_target_sat, oracle, activation_key_rhel, version): """Convert Oracle linux to RHEL :id: 7fd393f0-551a-4de0-acdd-7f026b485f79 @@ -227,46 +267,42 @@ def test_convert2rhel_oracle(target_sat, oracle, activation_key_rhel, version): :CaseImportance: Medium """ - host_content = target_sat.api.Host(id=oracle.hostname).read_json() + host_content = module_target_sat.api.Host(id=oracle.hostname).read_json() assert host_content['operatingsystem_name'] == f"OracleLinux {version}" # execute job 'Convert 2 RHEL' on host template_id = ( - target_sat.api.JobTemplate().search(query={'search': 'name="Convert to RHEL"'})[0].id + module_target_sat.api.JobTemplate().search(query={'search': 'name="Convert to RHEL"'})[0].id ) - job = target_sat.api.JobInvocation().run( + job = module_target_sat.api.JobInvocation().run( synchronous=False, data={ 'job_template_id': template_id, 'inputs': { 'Activation Key': activation_key_rhel.id, 'Restart': 'yes', + 'Data telemetry': 'yes', }, 'targeting_type': 'static_query', 'search_query': f'name = {oracle.hostname}', }, ) # wait for job to complete - target_sat.wait_for_tasks( - f'resource_type = JobInvocation and resource_id = {job["id"]}', poll_timeout=1000 + module_target_sat.wait_for_tasks( + f'resource_type = JobInvocation and resource_id = {job["id"]}', poll_timeout=2500 ) - result = target_sat.api.JobInvocation(id=job['id']).read() + result = module_target_sat.api.JobInvocation(id=job['id']).read() assert result.succeeded == 1 # check facts: correct os and valid subscription status - host_content = target_sat.api.Host(id=oracle.hostname).read_json() - # workaround for BZ 2080347 - assert ( - host_content['operatingsystem_name'].startswith(f"RHEL Server {version}") - or host_content['operatingsystem_name'].startswith(f"RedHat {version}") - or host_content['operatingsystem_name'].startswith(f"RHEL {version}") - ) + host_content = module_target_sat.api.Host(id=oracle.hostname).read_json() + assert host_content['subscription_status'] == 0 @pytest.mark.e2e -@pytest.mark.parametrize("version", ['centos7', 'centos8'], indirect=True) -def test_convert2rhel_centos(target_sat, centos, activation_key_rhel, version): +@pytest.mark.parametrize('version', ['centos7', 'centos8'], indirect=True) +def test_convert2rhel_centos(module_target_sat, centos, activation_key_rhel, version): """Convert Centos linux to RHEL :id: 6f698440-7d85-4deb-8dd9-363ea9003b92 @@ -283,39 +319,41 @@ def test_convert2rhel_centos(target_sat, centos, activation_key_rhel, version): :CaseImportance: Medium """ - host_content = target_sat.api.Host(id=centos.hostname).read_json() + host_content = module_target_sat.api.Host(id=centos.hostname).read_json() major = version.split('.')[0] - assert host_content['operatingsystem_name'] == f"CentOS {major}" - + assert host_content['operatingsystem_name'] == f'CentOS {major}' # execute job 'Convert 2 RHEL' on host template_id = ( - target_sat.api.JobTemplate().search(query={'search': 'name="Convert to RHEL"'})[0].id + module_target_sat.api.JobTemplate().search(query={'search': 'name="Convert to RHEL"'})[0].id ) - job = target_sat.api.JobInvocation().run( + job = module_target_sat.api.JobInvocation().run( synchronous=False, data={ 'job_template_id': template_id, 'inputs': { 'Activation Key': activation_key_rhel.id, 'Restart': 'yes', + 'Data telemetry': 'yes', }, 'targeting_type': 'static_query', 'search_query': f'name = {centos.hostname}', }, ) # wait for job to complete - target_sat.wait_for_tasks( - f'resource_type = JobInvocation and resource_id = {job["id"]}', poll_timeout=1000 + module_target_sat.wait_for_tasks( + f'resource_type = JobInvocation and resource_id = {job["id"]}', + poll_timeout=2500, + search_rate=20, ) - result = target_sat.api.JobInvocation(id=job['id']).read() + result = module_target_sat.api.JobInvocation(id=job['id']).read() assert result.succeeded == 1 # check facts: correct os and valid subscription status - host_content = target_sat.api.Host(id=centos.hostname).read_json() + host_content = module_target_sat.api.Host(id=centos.hostname).read_json() # workaround for BZ 2080347 assert ( - host_content['operatingsystem_name'].startswith(f"RHEL Server {version}") - or host_content['operatingsystem_name'].startswith(f"RedHat {version}") - or host_content['operatingsystem_name'].startswith(f"RHEL {version}") + host_content['operatingsystem_name'].startswith(f'RHEL Server {version}') + or host_content['operatingsystem_name'].startswith(f'RedHat {version}') + or host_content['operatingsystem_name'].startswith(f'RHEL {version}') ) assert host_content['subscription_status'] == 0 From 8702a93fcfc282ce74f4e78d6960406fc9cf2beb Mon Sep 17 00:00:00 2001 From: Peter Ondrejka Date: Wed, 1 Nov 2023 13:47:15 +0100 Subject: [PATCH 26/30] remove accidentally cherry-picked file (#13025) remove accidentaly cherry-picked file --- tests/foreman/api/test_notifications.py | 227 ------------------------ 1 file changed, 227 deletions(-) delete mode 100644 tests/foreman/api/test_notifications.py diff --git a/tests/foreman/api/test_notifications.py b/tests/foreman/api/test_notifications.py deleted file mode 100644 index a8b4c24ebf8..00000000000 --- a/tests/foreman/api/test_notifications.py +++ /dev/null @@ -1,227 +0,0 @@ -"""Test class for Notifications API - -:Requirement: Notifications - -:CaseAutomation: Automated - -:CaseLevel: Acceptance - -:CaseComponent: Notifications - -:Team: Endeavour - -:TestType: Functional - -:CaseImportance: High - -:Upstream: No -""" -from mailbox import mbox -from re import findall -from tempfile import mkstemp - -from fauxfactory import gen_string -import pytest -from wait_for import TimedOutError, wait_for - -from robottelo.config import settings -from robottelo.constants import DEFAULT_LOC, DEFAULT_ORG -from robottelo.utils.issue_handlers import is_open - - -@pytest.fixture -def admin_user_with_localhost_email(target_sat): - """Admin user with e-mail set to `root@localhost`.""" - user = target_sat.api.User( - admin=True, - default_organization=DEFAULT_ORG, - default_location=DEFAULT_LOC, - description='created by nailgun', - login=gen_string("alphanumeric"), - password=gen_string("alphanumeric"), - mail='root@localhost', - ).create() - user.mail_enabled = True - user.update() - - yield user - - user.delete() - - -@pytest.fixture -def reschedule_long_running_tasks_notification(target_sat): - """Reschedule long-running tasks checker from midnight (default) to every minute. - Reset it back after the test. - """ - default_cron_schedule = '0 0 * * *' - every_minute_cron_schedule = '* * * * *' - - assert ( - target_sat.execute( - f"FOREMAN_TASKS_CHECK_LONG_RUNNING_TASKS_CRONLINE='{every_minute_cron_schedule}' " - "foreman-rake foreman_tasks:reschedule_long_running_tasks_checker" - ).status - == 0 - ) - - yield - - assert ( - target_sat.execute( - f"FOREMAN_TASKS_CHECK_LONG_RUNNING_TASKS_CRONLINE='{default_cron_schedule}' " - "foreman-rake foreman_tasks:reschedule_long_running_tasks_checker" - ).status - == 0 - ) - - -@pytest.fixture -def start_postfix_service(target_sat): - """Start postfix service (disabled by default).""" - assert target_sat.execute('systemctl start postfix').status == 0 - - -@pytest.fixture -def clean_root_mailbox(target_sat): - """Backup & purge local mailbox of the Satellite's root@localhost user. - Restore it afterwards. - """ - root_mailbox = '/var/spool/mail/root' - root_mailbox_backup = f'{root_mailbox}-{gen_string("alphanumeric")}.bak' - target_sat.execute(f'cp -f {root_mailbox} {root_mailbox_backup}') - target_sat.execute(f'truncate -s 0 {root_mailbox}') - - yield root_mailbox - - target_sat.execute(f'mv -f {root_mailbox_backup} {root_mailbox}') - - -@pytest.fixture -def wait_for_long_running_task_mail(target_sat, clean_root_mailbox, long_running_task): - """Wait until the long-running task ID is found in the Satellite's mbox file.""" - timeout = 300 - try: - wait_for( - func=target_sat.execute, - func_args=[f'grep --quiet {long_running_task["task"]["id"]} {clean_root_mailbox}'], - fail_condition=lambda res: res.status == 0, - timeout=timeout, - delay=5, - ) - except TimedOutError: - raise AssertionError( - f'No notification e-mail with long-running task ID {long_running_task["task"]["id"]} ' - f'has arrived to {clean_root_mailbox} after {timeout} seconds.' - ) - return True - - -@pytest.fixture -def root_mailbox_copy(target_sat, clean_root_mailbox, wait_for_long_running_task_mail): - """Parsed local system copy of the Satellite's root user mailbox. - - :returns: :class:`mailbox.mbox` instance - """ - assert wait_for_long_running_task_mail - result = target_sat.execute(f'cat {clean_root_mailbox}') - assert result.status == 0, f'Could not read mailbox {clean_root_mailbox} on Satellite host.' - mbox_content = result.stdout - _, local_mbox_file = mkstemp() - with open(local_mbox_file, 'w') as fh: - fh.writelines(mbox_content) - return mbox(path=local_mbox_file) - - -@pytest.fixture -def long_running_task(target_sat): - """Create an async task and set its start time and last report time to two days ago. - After the test finishes, the task is cancelled. - """ - template_id = ( - target_sat.api.JobTemplate() - .search(query={'search': 'name="Run Command - Script Default"'})[0] - .id - ) - job = target_sat.api.JobInvocation().run( - synchronous=False, - data={ - 'job_template_id': template_id, - 'organization': DEFAULT_ORG, - 'location': DEFAULT_LOC, - 'inputs': { - 'command': 'sleep 300', - }, - 'targeting_type': 'static_query', - 'search_query': f'name = {target_sat.hostname}', - 'password': settings.server.ssh_password, - }, - ) - sql_date_2_days_ago = "now() - INTERVAL \'2 days\'" - result = target_sat.execute( - "su - postgres -c \"psql foreman postgres < Date: Wed, 1 Nov 2023 16:53:23 -0400 Subject: [PATCH 27/30] [6.13.z] ISS refactor - batch 4 (#13030) --- tests/foreman/cli/test_satellitesync.py | 258 ++++++++++++------------ 1 file changed, 134 insertions(+), 124 deletions(-) diff --git a/tests/foreman/cli/test_satellitesync.py b/tests/foreman/cli/test_satellitesync.py index a4c71f13d80..19e3b8a178a 100644 --- a/tests/foreman/cli/test_satellitesync.py +++ b/tests/foreman/cli/test_satellitesync.py @@ -41,6 +41,7 @@ from robottelo.config import settings from robottelo.constants import ( CONTAINER_REGISTRY_HUB, + CONTAINER_UPSTREAM_NAME, DEFAULT_ARCHITECTURE, DEFAULT_CV, EXPORT_LIBRARY_NAME, @@ -70,9 +71,8 @@ def config_export_import_settings(): def export_import_cleanup_function(target_sat, function_org): """Deletes export/import dirs of function org""" yield - # Deletes directories created for export/import test target_sat.execute( - f'rm -rf {PULP_EXPORT_DIR}/{function_org.name} {PULP_IMPORT_DIR}/{function_org.name}', + f'rm -rf {PULP_EXPORT_DIR}/{function_org.name} {PULP_IMPORT_DIR}/{function_org.name}' ) @@ -80,7 +80,6 @@ def export_import_cleanup_function(target_sat, function_org): def export_import_cleanup_module(target_sat, module_org): """Deletes export/import dirs of module_org""" yield - # Deletes directories created for export/import test target_sat.execute( f'rm -rf {PULP_EXPORT_DIR}/{module_org.name} {PULP_IMPORT_DIR}/{module_org.name}' ) @@ -101,23 +100,6 @@ def function_import_org_with_manifest(target_sat, function_import_org): yield function_import_org -@pytest.fixture(scope='class') -def docker_repo(module_target_sat, module_org): - product = make_product({'organization-id': module_org.id}) - repo = make_repository( - { - 'organization-id': module_org.id, - 'product-id': product['id'], - 'content-type': REPO_TYPE['docker'], - 'download-policy': 'immediate', - 'url': 'https://quay.io', - 'docker-upstream-name': 'quay/busybox', - } - ) - Repository.synchronize({'id': repo['id']}) - yield repo - - @pytest.fixture(scope='module') def module_synced_custom_repo(module_target_sat, module_org, module_product): repo = module_target_sat.cli_factory.make_repository( @@ -183,6 +165,54 @@ def function_synced_rhel_repo(request, target_sat, function_sca_manifest_org): return repo +@pytest.fixture(scope='function') +def function_synced_file_repo(target_sat, function_org, function_product): + repo = target_sat.cli_factory.make_repository( + { + 'organization-id': function_org.id, + 'product-id': function_product.id, + 'content-type': 'file', + 'url': settings.repos.file_type_repo.url, + } + ) + target_sat.cli.Repository.synchronize({'id': repo['id']}) + yield repo + + +@pytest.fixture(scope='function') +def function_synced_docker_repo(target_sat, function_org): + product = target_sat.cli_factory.make_product({'organization-id': function_org.id}) + repo = target_sat.cli_factory.make_repository( + { + 'organization-id': function_org.id, + 'product-id': product['id'], + 'content-type': REPO_TYPE['docker'], + 'download-policy': 'immediate', + 'url': CONTAINER_REGISTRY_HUB, + 'docker-upstream-name': CONTAINER_UPSTREAM_NAME, + } + ) + target_sat.cli.Repository.synchronize({'id': repo['id']}) + yield repo + + +@pytest.fixture(scope='function') +def function_synced_AC_repo(target_sat, function_org, function_product): + repo = target_sat.cli_factory.make_repository( + { + 'organization-id': function_org.id, + 'product-id': function_product.id, + 'content-type': 'ansible_collection', + 'url': ANSIBLE_GALAXY, + 'ansible-collection-requirements': '{collections: [ \ + { name: theforeman.foreman, version: "2.1.0" }, \ + { name: theforeman.operations, version: "0.1.0"} ]}', + } + ) + target_sat.cli.Repository.synchronize({'id': repo['id']}) + yield repo + + @pytest.mark.run_in_one_thread class TestRepositoryExport: """Tests for exporting a repository via CLI""" @@ -241,7 +271,7 @@ def test_positive_export_version_custom_repo( target_sat.cli.ContentView.publish({'id': cv['id']}) cv = target_sat.cli.ContentView.info({'id': cv['id']}) assert len(cv['versions']) == 2 - cvv = cv['versions'][1] + cvv = max(cv['versions'], key=lambda x: int(x['id'])) target_sat.cli.ContentExport.incrementalVersion( {'id': cvv['id'], 'organization-id': module_org.id} ) @@ -344,7 +374,7 @@ def test_positive_export_complete_library_rh_repo( @pytest.mark.tier3 @pytest.mark.upgrade def test_positive_export_repository_docker( - self, target_sat, export_import_cleanup_module, module_org, docker_repo + self, target_sat, export_import_cleanup_function, function_org, function_synced_docker_repo ): """Export docker repo via complete and incremental repository. @@ -366,18 +396,20 @@ def test_positive_export_repository_docker( :customerscenario: true """ # Verify export directory is empty - assert target_sat.validate_pulp_filepath(module_org, PULP_EXPORT_DIR) == '' + assert target_sat.validate_pulp_filepath(function_org, PULP_EXPORT_DIR) == '' # Export complete and check the export directory - target_sat.cli.ContentExport.completeRepository({'id': docker_repo['id']}) - assert '1.0' in target_sat.validate_pulp_filepath(module_org, PULP_EXPORT_DIR) + target_sat.cli.ContentExport.completeRepository({'id': function_synced_docker_repo['id']}) + assert '1.0' in target_sat.validate_pulp_filepath(function_org, PULP_EXPORT_DIR) # Export incremental and check the export directory - target_sat.cli.ContentExport.incrementalRepository({'id': docker_repo['id']}) - assert '2.0' in target_sat.validate_pulp_filepath(module_org, PULP_EXPORT_DIR) + target_sat.cli.ContentExport.incrementalRepository( + {'id': function_synced_docker_repo['id']} + ) + assert '2.0' in target_sat.validate_pulp_filepath(function_org, PULP_EXPORT_DIR) @pytest.mark.tier3 @pytest.mark.upgrade def test_positive_export_version_docker( - self, target_sat, export_import_cleanup_module, module_org, docker_repo + self, target_sat, export_import_cleanup_function, function_org, function_synced_docker_repo ): """Export CV with docker repo via complete and incremental version. @@ -402,12 +434,12 @@ def test_positive_export_version_docker( """ # Create CV and publish cv_name = gen_string('alpha') - cv = make_content_view({'name': cv_name, 'organization-id': module_org.id}) + cv = make_content_view({'name': cv_name, 'organization-id': function_org.id}) target_sat.cli.ContentView.add_repository( { 'id': cv['id'], - 'organization-id': module_org.id, - 'repository-id': docker_repo['id'], + 'organization-id': function_org.id, + 'repository-id': function_synced_docker_repo['id'], } ) target_sat.cli.ContentView.publish({'id': cv['id']}) @@ -415,21 +447,21 @@ def test_positive_export_version_docker( assert len(cv['versions']) == 1 cvv = cv['versions'][0] # Verify export directory is empty - assert target_sat.validate_pulp_filepath(module_org, PULP_EXPORT_DIR) == '' + assert target_sat.validate_pulp_filepath(function_org, PULP_EXPORT_DIR) == '' # Export complete and check the export directory target_sat.cli.ContentExport.completeVersion( - {'id': cvv['id'], 'organization-id': module_org.id} + {'id': cvv['id'], 'organization-id': function_org.id} ) - assert '1.0' in target_sat.validate_pulp_filepath(module_org, PULP_EXPORT_DIR) + assert '1.0' in target_sat.validate_pulp_filepath(function_org, PULP_EXPORT_DIR) # Publish new CVV, export incremental and check the export directory target_sat.cli.ContentView.publish({'id': cv['id']}) cv = target_sat.cli.ContentView.info({'id': cv['id']}) assert len(cv['versions']) == 2 - cvv = cv['versions'][1] + cvv = max(cv['versions'], key=lambda x: int(x['id'])) target_sat.cli.ContentExport.incrementalVersion( - {'id': cvv['id'], 'organization-id': module_org.id} + {'id': cvv['id'], 'organization-id': function_org.id} ) - assert '2.0' in target_sat.validate_pulp_filepath(module_org, PULP_EXPORT_DIR) + assert '2.0' in target_sat.validate_pulp_filepath(function_org, PULP_EXPORT_DIR) @pytest.fixture(scope='class') @@ -1141,149 +1173,127 @@ def test_negative_import_invalid_path(self, module_org): @pytest.mark.tier3 def test_postive_export_cv_with_mixed_content_repos( - self, class_export_entities, export_import_cleanup_module, target_sat, module_org + self, + export_import_cleanup_function, + target_sat, + function_org, + function_synced_custom_repo, + function_synced_file_repo, + function_synced_docker_repo, + function_synced_AC_repo, ): """Exporting CV version having yum and non-yum(docker) is successful :id: ffcdbbc6-f787-4978-80a7-4b44c389bf49 - :steps: + :setup: + 1. Synced repositories of each content type: yum, file, docker, AC - 1. Create product with yum and non-yum(docker) repos - 2. Sync the repositories - 3. Create CV with above product and publish - 4. Export CV version contents to a directory + :steps: + 1. Create CV, add all setup repos and publish. + 2. Export CV version contents to a directory. :expectedresults: - 1. Export will succeed, however the export wont contain non-yum repo. - No warning is printed (see BZ 1775383) + 1. Export succeeds and content is exported. :BZ: 1726457 :customerscenario: true """ - product = make_product( - { - 'organization-id': module_org.id, - 'name': gen_string('alpha'), - } - ) - nonyum_repo = make_repository( - { - 'content-type': 'docker', - 'docker-upstream-name': 'quay/busybox', - 'organization-id': module_org.id, - 'product-id': product['id'], - 'url': CONTAINER_REGISTRY_HUB, - }, - ) - Repository.synchronize({'id': nonyum_repo['id']}) - yum_repo = make_repository( - { - 'name': gen_string('alpha'), - 'download-policy': 'immediate', - 'mirror-on-sync': 'no', - 'product-id': product['id'], - } - ) - Repository.synchronize({'id': yum_repo['id']}) - content_view = make_content_view({'organization-id': module_org.id}) - # Add docker and yum repo - ContentView.add_repository( - { - 'id': content_view['id'], - 'organization-id': module_org.id, - 'repository-id': nonyum_repo['id'], - } - ) - ContentView.add_repository( - { - 'id': content_view['id'], - 'organization-id': module_org.id, - 'repository-id': yum_repo['id'], - } + content_view = target_sat.cli_factory.make_content_view( + {'organization-id': function_org.id} + ) + repos = [ + function_synced_custom_repo, + function_synced_file_repo, + function_synced_docker_repo, + function_synced_AC_repo, + ] + for repo in repos: + target_sat.cli.ContentView.add_repository( + { + 'id': content_view['id'], + 'organization-id': function_org.id, + 'repository-id': repo['id'], + } + ) + target_sat.cli.ContentView.publish({'id': content_view['id']}) + exporting_cv = target_sat.cli.ContentView.info({'id': content_view['id']}) + assert len(exporting_cv['versions']) == 1 + exporting_cvv = target_sat.cli.ContentView.version_info( + {'id': exporting_cv['versions'][0]['id']} ) - ContentView.publish({'id': content_view['id']}) - exporting_cv_id = ContentView.info({'id': content_view['id']}) - assert len(exporting_cv_id['versions']) == 1 - exporting_cvv_id = exporting_cv_id['versions'][0] + assert len(exporting_cvv['repositories']) == len(repos) # check packages - exported_packages = Package.list({'content-view-version-id': exporting_cvv_id['id']}) + exported_packages = target_sat.cli.Package.list( + {'content-view-version-id': exporting_cvv['id']} + ) assert len(exported_packages) # Verify export directory is empty - assert target_sat.validate_pulp_filepath(module_org, PULP_EXPORT_DIR) == '' + assert target_sat.validate_pulp_filepath(function_org, PULP_EXPORT_DIR) == '' # Export cv - ContentExport.completeVersion( - {'id': exporting_cvv_id['id'], 'organization-id': module_org.id} + target_sat.cli.ContentExport.completeVersion( + {'id': exporting_cvv['id'], 'organization-id': function_org.id} ) # Verify export directory is not empty - assert target_sat.validate_pulp_filepath(module_org, PULP_EXPORT_DIR) != '' + assert target_sat.validate_pulp_filepath(function_org, PULP_EXPORT_DIR) != '' @pytest.mark.tier3 def test_postive_export_import_cv_with_file_content( self, target_sat, config_export_import_settings, - export_import_cleanup_module, - module_org, + export_import_cleanup_function, + function_org, + function_synced_file_repo, function_import_org, ): """Exporting and Importing cv with file content :id: d00739f0-dedf-4303-8929-889dc23260a4 + :setup: + 1. Product with synced file-type repository. + :steps: - 1. Create custom product and custom repo with file type - 2. Sync repo - 3. Create cv and add file repo created in step 1 and publish - 4. Export cv and import cv into another satellite. - 5. Check imported cv has files in it. + 3. Create CV, add the file repo and publish. + 4. Export the CV and import it into another organization. + 5. Check the imported CV has files in it. :expectedresults: - 1. Imported cv should have the files present in the cv of the imported system. + 1. Imported CV should have the files present. :BZ: 1995827 :customerscenario: true """ - # setup custom repo + # Create CV, add the file repo and publish. cv_name = import_cv_name = gen_string('alpha') - product = target_sat.cli_factory.make_product({'organization-id': module_org.id}) - file_repo = target_sat.cli_factory.make_repository( - { - 'organization-id': module_org.id, - 'product-id': product['id'], - 'content-type': 'file', - 'url': settings.repos.file_type_repo.url, - } - ) - target_sat.cli.Repository.synchronize({'id': file_repo['id']}) - # create cv and publish cv = target_sat.cli_factory.make_content_view( - {'name': cv_name, 'organization-id': module_org.id} + {'name': cv_name, 'organization-id': function_org.id} ) target_sat.cli.ContentView.add_repository( { 'id': cv['id'], - 'organization-id': module_org.id, - 'repository-id': file_repo['id'], + 'organization-id': function_org.id, + 'repository-id': function_synced_file_repo['id'], } ) target_sat.cli.ContentView.publish({'id': cv['id']}) - exporting_cv_id = target_sat.cli.ContentView.info({'id': cv['id']}) - assert len(exporting_cv_id['versions']) == 1 - exporting_cvv_id = exporting_cv_id['versions'][0]['id'] + exporting_cv = target_sat.cli.ContentView.info({'id': cv['id']}) + assert len(exporting_cv['versions']) == 1 + exporting_cvv_id = exporting_cv['versions'][0]['id'] # check files exported_files = target_sat.cli.File.list({'content-view-version-id': exporting_cvv_id}) assert len(exported_files) # Verify export directory is empty - assert target_sat.validate_pulp_filepath(module_org, PULP_EXPORT_DIR) == '' - # Export cv + assert target_sat.validate_pulp_filepath(function_org, PULP_EXPORT_DIR) == '' + # Export the CV export = target_sat.cli.ContentExport.completeVersion( - {'id': exporting_cvv_id, 'organization-id': module_org.id} + {'id': exporting_cvv_id, 'organization-id': function_org.id} ) - import_path = target_sat.move_pulp_archive(module_org, export['message']) + import_path = target_sat.move_pulp_archive(function_org, export['message']) # Check that files are present in import_path result = target_sat.execute(f'ls {import_path}') assert result.stdout != '' From 8e47d5a9a21795593311a74b76c8cb878600239a Mon Sep 17 00:00:00 2001 From: Peter Ondrejka Date: Thu, 2 Nov 2023 07:10:54 +0100 Subject: [PATCH 28/30] added custom-cdn-auth-enabled hammer option (#13026) --- tests/foreman/data/hammer_commands.json | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/foreman/data/hammer_commands.json b/tests/foreman/data/hammer_commands.json index 2517e8fafd6..b596f1b922e 100644 --- a/tests/foreman/data/hammer_commands.json +++ b/tests/foreman/data/hammer_commands.json @@ -33284,6 +33284,12 @@ "description": "Update the CDN configuration", "name": "configure-cdn", "options": [ + { + "help": "If product certificates should be used to authenticate to a custom CDN.", + "name": "custom-cdn-auth-enabled", + "shortname": null, + "value": "BOOLEAN" + }, { "help": "Id of the Organization", "name": "id", From 00bcbe5be4f30b40444fa10bfd797bb3dfe0dc7e Mon Sep 17 00:00:00 2001 From: Satellite QE <115476073+Satellite-QE@users.noreply.github.com> Date: Thu, 2 Nov 2023 18:32:44 -0400 Subject: [PATCH 29/30] [6.13.z] Check if VAULT_ADDR env var exists before deleting it (#13033) Check if VAULT_ADDR env var exists before deleting it (#13016) Co-authored-by: dosas (cherry picked from commit c1d7b42971f61d831e4afd635ebf0c7a27bd643a) Co-authored-by: dosas --- robottelo/utils/vault.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/robottelo/utils/vault.py b/robottelo/utils/vault.py index d3a40d1a706..d447331ac15 100644 --- a/robottelo/utils/vault.py +++ b/robottelo/utils/vault.py @@ -31,7 +31,8 @@ def setup(self): self.export_vault_addr() def teardown(self): - del os.environ['VAULT_ADDR'] + if os.environ.get('VAULT_ADDR') is not None: + del os.environ['VAULT_ADDR'] def export_vault_addr(self): vaulturl = re.findall('VAULT_URL_FOR_DYNACONF=(.*)', self.envdata)[0] From 03511f37f19f42659f1402a07413d5f8db988d69 Mon Sep 17 00:00:00 2001 From: Satellite QE <115476073+Satellite-QE@users.noreply.github.com> Date: Fri, 3 Nov 2023 16:51:30 -0400 Subject: [PATCH 30/30] [6.13.z] Adding the image config details in the docker config (#13042) Adding the image config details in the docker config (#12958) (cherry picked from commit ee1ee6a3e56bcc7a3e30083b2760c916438a2bca) Co-authored-by: Devendra --- conf/docker.yaml.template | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/conf/docker.yaml.template b/conf/docker.yaml.template index 81fc6a84dd0..4176b38ee8a 100644 --- a/conf/docker.yaml.template +++ b/conf/docker.yaml.template @@ -9,3 +9,23 @@ DOCKER: PRIVATE_REGISTRY_USERNAME: # Private docker registry password PRIVATE_REGISTRY_PASSWORD: + # Image Pass Registry + IMAGE_REGISTRY: + # image repository URL + URL: + # Pull a non-namespace image using the image pass registry proxy + NON_NAMESPACE: + # Proxy for the non-namespace image + PROXY: + # Username for the non-namespace image pass registry proxy + USERNAME: + # Password for the non-namespace image pass registry proxy + PASSWORD: + # Pull a namespace image using the image pass registry proxy + NAMESPACE: + # proxy for the namespace image + PROXY: + # Username for the namespace image pass registry proxy + USERNAME: + # Password for the namespace image pass registry proxy + PASSWORD: