From dcfe7526f73d19c219fdb05a2de40f3f490d9840 Mon Sep 17 00:00:00 2001 From: Tasos Papaioannou Date: Wed, 18 Dec 2024 13:59:12 -0500 Subject: [PATCH] Local Insights advisor testing --- conf/rh_cloud.yaml.template | 2 + pytest_fixtures/component/rh_cloud.py | 116 +++++++++--- robottelo/hosts.py | 7 +- tests/foreman/ui/test_rhcloud_insights.py | 198 ++++++++++++--------- tests/foreman/ui/test_rhcloud_inventory.py | 35 +++- 5 files changed, 237 insertions(+), 121 deletions(-) diff --git a/conf/rh_cloud.yaml.template b/conf/rh_cloud.yaml.template index 36a65f58dd3..7b790892d94 100644 --- a/conf/rh_cloud.yaml.template +++ b/conf/rh_cloud.yaml.template @@ -4,3 +4,5 @@ RH_CLOUD: ORGANIZATION: ACTIVATION_KEY: ak_name CRC_ENV: prod + IOP_ADVISOR_IMAGE: '' + IOP_SETUP_SCRIPT: '' diff --git a/pytest_fixtures/component/rh_cloud.py b/pytest_fixtures/component/rh_cloud.py index 9116716d6ff..83e86cf52f6 100644 --- a/pytest_fixtures/component/rh_cloud.py +++ b/pytest_fixtures/component/rh_cloud.py @@ -1,23 +1,70 @@ +from broker import Broker import pytest +from robottelo.config import settings from robottelo.constants import CAPSULE_REGISTRATION_OPTS +from robottelo.hosts import SatelliteHostError @pytest.fixture(scope='module') -def rhcloud_manifest_org(module_target_sat, module_sca_manifest): +def module_target_sat_insights(request, module_target_sat, satellite_factory): + """A module-level fixture to provide a Satellite configured for Insights. + By default, it returns the existing Satellite provided by module_target_sat. + + If parametrized with a false value, then it will deploy and return a Satellite with + iop-advisor-engine (local Insights advisor) configured. + """ + hosted_insights = getattr(request, 'param', True) + satellite = module_target_sat if hosted_insights else satellite_factory() + + if not hosted_insights: + image_url = getattr(settings.rh_cloud, 'iop_advisor_image', '') + script = getattr(settings.rh_cloud, 'iop_setup_script', '').splitlines() + + # Configure installer to use downstream image. + if image_url: + satellite.execute( + f'echo "iop_advisor_engine::image: {image_url!r}" >> /etc/foreman-installer/custom-hiera.yaml' + ) + + cmd_result = satellite.execute( + 'satellite-installer --foreman-plugin-rh-cloud-enable-iop-advisor-engine true' + ) + if cmd_result.status != 0: + raise SatelliteHostError(f'Error installing advisor engine: {cmd_result.stdout}') + + # Perform post-steps, such as generate custom rule content. + for cmd in script: + cmd_result = satellite.execute(cmd) + if cmd_result.status != 0: + raise SatelliteHostError( + f'Error during post-install of advisor engine: {cmd_result.stdout}' + ) + + yield satellite + + if not hosted_insights: + satellite.teardown() + Broker(hosts=[satellite]).checkin() + + +@pytest.fixture(scope='module') +def rhcloud_manifest_org(module_target_sat_insights, module_sca_manifest): """A module level fixture to get organization with manifest.""" - org = module_target_sat.api.Organization().create() - module_target_sat.upload_manifest(org.id, module_sca_manifest.content) + org = module_target_sat_insights.api.Organization().create() + module_target_sat_insights.upload_manifest(org.id, module_sca_manifest.content) return org @pytest.fixture(scope='module') -def rhcloud_activation_key(module_target_sat, rhcloud_manifest_org): +def rhcloud_activation_key(module_target_sat_insights, rhcloud_manifest_org): """A module-level fixture to create an Activation key in module_org""" - return module_target_sat.api.ActivationKey( + return module_target_sat_insights.api.ActivationKey( content_view=rhcloud_manifest_org.default_content_view, organization=rhcloud_manifest_org, - environment=module_target_sat.api.LifecycleEnvironment(id=rhcloud_manifest_org.library.id), + environment=module_target_sat_insights.api.LifecycleEnvironment( + id=rhcloud_manifest_org.library.id + ), service_level='Self-Support', purpose_usage='test-usage', purpose_role='test-role', @@ -27,12 +74,12 @@ def rhcloud_activation_key(module_target_sat, rhcloud_manifest_org): @pytest.fixture(scope='module') def rhcloud_registered_hosts( - rhcloud_activation_key, rhcloud_manifest_org, mod_content_hosts, module_target_sat + rhcloud_activation_key, rhcloud_manifest_org, mod_content_hosts, module_target_sat_insights ): """Fixture that registers content hosts to Satellite and Insights.""" for vm in mod_content_hosts: vm.configure_insights_client( - satellite=module_target_sat, + satellite=module_target_sat_insights, activation_key=rhcloud_activation_key, org=rhcloud_manifest_org, rhel_distro=f"rhel{vm.os_version.major}", @@ -43,44 +90,59 @@ def rhcloud_registered_hosts( @pytest.fixture def rhel_insights_vm( - module_target_sat, rhcloud_activation_key, rhcloud_manifest_org, rhel_contenthost + module_target_sat_insights, + rhcloud_activation_key, + rhcloud_manifest_org, + rhel_contenthost, ): """A function-level fixture to create rhel content host registered with insights.""" rhel_contenthost.configure_rex( - satellite=module_target_sat, org=rhcloud_manifest_org, register=False + satellite=module_target_sat_insights, org=rhcloud_manifest_org, register=False ) rhel_contenthost.configure_insights_client( - satellite=module_target_sat, + satellite=module_target_sat_insights, activation_key=rhcloud_activation_key, org=rhcloud_manifest_org, rhel_distro=f"rhel{rhel_contenthost.os_version.major}", ) - # Generate report - module_target_sat.generate_inventory_report(rhcloud_manifest_org) - # Sync inventory status - module_target_sat.sync_inventory_status(rhcloud_manifest_org) + # Sync inventory if using hosted Insights + if not module_target_sat_insights.local_advisor_enabled: + module_target_sat_insights.generate_inventory_report(rhcloud_manifest_org) + module_target_sat_insights.sync_inventory_status(rhcloud_manifest_org) return rhel_contenthost @pytest.fixture -def inventory_settings(module_target_sat): - hostnames_setting = module_target_sat.update_setting('obfuscate_inventory_hostnames', False) - ip_setting = module_target_sat.update_setting('obfuscate_inventory_ips', False) - packages_setting = module_target_sat.update_setting('exclude_installed_packages', False) - parameter_tags_setting = module_target_sat.update_setting('include_parameter_tags', False) +def inventory_settings(module_target_sat_insights): + hostnames_setting = module_target_sat_insights.update_setting( + 'obfuscate_inventory_hostnames', False + ) + ip_setting = module_target_sat_insights.update_setting('obfuscate_inventory_ips', False) + packages_setting = module_target_sat_insights.update_setting( + 'exclude_installed_packages', False + ) + parameter_tags_setting = module_target_sat_insights.update_setting( + 'include_parameter_tags', False + ) + yield - module_target_sat.update_setting('obfuscate_inventory_hostnames', hostnames_setting) - module_target_sat.update_setting('obfuscate_inventory_ips', ip_setting) - module_target_sat.update_setting('exclude_installed_packages', packages_setting) - module_target_sat.update_setting('include_parameter_tags', parameter_tags_setting) + + module_target_sat_insights.update_setting('obfuscate_inventory_hostnames', hostnames_setting) + module_target_sat_insights.update_setting('obfuscate_inventory_ips', ip_setting) + module_target_sat_insights.update_setting('exclude_installed_packages', packages_setting) + module_target_sat_insights.update_setting('include_parameter_tags', parameter_tags_setting) @pytest.fixture(scope='module') -def rhcloud_capsule(module_capsule_host, module_target_sat, rhcloud_manifest_org, default_location): +def rhcloud_capsule( + module_capsule_host, module_target_sat_insights, rhcloud_manifest_org, default_location +): """Configure the capsule instance with the satellite from settings.server.hostname""" org = rhcloud_manifest_org - module_capsule_host.capsule_setup(sat_host=module_target_sat, **CAPSULE_REGISTRATION_OPTS) - module_target_sat.cli.Capsule.update( + module_capsule_host.capsule_setup( + sat_host=module_target_sat_insights, **CAPSULE_REGISTRATION_OPTS + ) + module_target_sat_insights.cli.Capsule.update( { 'name': module_capsule_host.hostname, 'organization-ids': org.id, diff --git a/robottelo/hosts.py b/robottelo/hosts.py index 70789cf6bb0..eb91cac700e 100644 --- a/robottelo/hosts.py +++ b/robottelo/hosts.py @@ -2401,7 +2401,7 @@ def enroll_ad_and_configure_external_auth(self, ad_data): def generate_inventory_report(self, org, disconnected='false'): """Function to perform inventory upload.""" - generate_report_task = 'ForemanInventoryUpload::Async::UploadReportJob' + generate_report_task = 'ForemanInventoryUpload::Async::GenerateReportJob' timestamp = datetime.utcnow().strftime('%Y-%m-%d %H:%M') self.api.Organization(id=org.id).rh_cloud_generate_report( data={'disconnected': disconnected} @@ -2448,6 +2448,11 @@ def run_orphan_cleanup(self, smart_proxy_id=None): max_tries=10, ) + @property + def local_advisor_enabled(self): + """Return boolean indicating whether local Insights advisor engine is enabled.""" + return self.api.RHCloud().advisor_engine_config()['use_local_advisor_engine'] + class SSOHost(Host): """Class for SSO functions and setup""" diff --git a/tests/foreman/ui/test_rhcloud_insights.py b/tests/foreman/ui/test_rhcloud_insights.py index 662f841d22e..f170e0450c6 100644 --- a/tests/foreman/ui/test_rhcloud_insights.py +++ b/tests/foreman/ui/test_rhcloud_insights.py @@ -18,14 +18,37 @@ from wait_for import wait_for from robottelo.config import settings -from robottelo.constants import DEFAULT_LOC, DNF_RECOMMENDATION, OPENSSH_RECOMMENDATION +from robottelo.constants import DEFAULT_LOC, DEFAULT_ORG, DNF_RECOMMENDATION, OPENSSH_RECOMMENDATION def create_insights_vulnerability(insights_vm): """Function to create vulnerabilities that can be remediated.""" + + # Add vulnerabilities for OPENSSH_RECOMMENDATION and DNS_RECOMMENDATION, then upload Insights data. insights_vm.run( - 'chmod 777 /etc/ssh/sshd_config;dnf update -y dnf;' - 'sed -i -e "/^best/d" /etc/dnf/dnf.conf;insights-client' + 'chmod 777 /etc/ssh/sshd_config;' + 'dnf update -y dnf;sed -i -e "/^best/d" /etc/dnf/dnf.conf;' + 'insights-client' + ) + + +def sync_recommendations(satellite, org_name=DEFAULT_ORG, loc_name=DEFAULT_LOC): + with satellite.ui_session() as session: + session.organization.select(org_name=org_name) + session.location.select(loc_name=DEFAULT_LOC) + + timestamp = datetime.utcnow().strftime('%Y-%m-%d %H:%M') + session.cloudinsights.sync_hits() + + wait_for( + lambda: satellite.api.ForemanTask() + .search(query={'search': f'Insights full sync and started_at >= "{timestamp}"'})[0] + .result + == 'success', + timeout=400, + delay=15, + silent_failure=True, + handle_exception=True, ) @@ -35,21 +58,24 @@ def create_insights_vulnerability(insights_vm): @pytest.mark.tier3 @pytest.mark.no_containers @pytest.mark.rhel_ver_list(r'^[\d]+$') +@pytest.mark.parametrize( + "module_target_sat_insights", [True, False], ids=["hosted", "local"], indirect=True +) def test_rhcloud_insights_e2e( rhel_insights_vm, rhcloud_manifest_org, - module_target_sat, + module_target_sat_insights, ): - """Synchronize hits data from cloud, verify it is displayed in Satellite and run remediation. + """Synchronize hits data from hosted or local Insights Advisor, verify results are displayed in Satellite, and run remediation. :id: d952e83c-3faf-4299-a048-2eb6ccb8c9c2 :steps: 1. Prepare misconfigured machine and upload its data to Insights. - 2. In Satellite UI, go to Configure -> Insights -> Sync recommendations. + 2. In Satellite UI, go to Insights > Recommendations. 3. Run remediation for "OpenSSH config permissions" recommendation against host. 4. Verify that the remediation job completed successfully. - 5. Sync Insights recommendations. + 5. Refresh Insights recommendations (re-sync if using hosted Insights). 6. Search for previously remediated issue. :expectedresults: @@ -71,63 +97,52 @@ def test_rhcloud_insights_e2e( job_query = ( f'Remote action: Insights remediations for selected issues on {rhel_insights_vm.hostname}' ) - org = rhcloud_manifest_org + org_name = rhcloud_manifest_org.name + # Prepare misconfigured machine and upload data to Insights create_insights_vulnerability(rhel_insights_vm) - with module_target_sat.ui_session() as session: - session.organization.select(org_name=org.name) + # Sync the recommendations (hosted Insights only). + local_advisor_enabled = module_target_sat_insights.local_advisor_enabled + if not local_advisor_enabled: + sync_recommendations(module_target_sat_insights, org_name=org_name, loc_name=DEFAULT_LOC) + + with module_target_sat_insights.ui_session() as session: + session.organization.select(org_name=org_name) session.location.select(loc_name=DEFAULT_LOC) - timestamp = datetime.utcnow().strftime('%Y-%m-%d %H:%M') - # Sync Insights recommendations - session.cloudinsights.sync_hits() - wait_for( - lambda: module_target_sat.api.ForemanTask() - .search(query={'search': f'Insights full sync and started_at >= "{timestamp}"'})[0] - .result - == 'success', - timeout=400, - delay=15, - silent_failure=True, - handle_exception=True, - ) - # Workaround for alert message causing search to fail. See airgun issue 584. - session.browser.refresh() - # Search for Insights recommendation. + + # Search for the recommendation. result = session.cloudinsights.search( f'hostname= "{rhel_insights_vm.hostname}" and title = "{OPENSSH_RECOMMENDATION}"' )[0] assert result['Hostname'] == rhel_insights_vm.hostname assert result['Recommendation'] == OPENSSH_RECOMMENDATION - # Run remediation and verify job completion. + + # Run the remediation. timestamp = datetime.utcnow().strftime('%Y-%m-%d %H:%M') session.cloudinsights.remediate(OPENSSH_RECOMMENDATION) - wait_for( - lambda: module_target_sat.api.ForemanTask() - .search(query={'search': f'{job_query} and started_at >= "{timestamp}"'})[0] - .result - == 'success', - timeout=400, - delay=15, - silent_failure=True, - handle_exception=True, - ) - # Search for Insights recommendations again. - timestamp = datetime.utcnow().strftime('%Y-%m-%d %H:%M') - session.cloudinsights.sync_hits() - wait_for( - lambda: module_target_sat.api.ForemanTask() - .search(query={'search': f'Insights full sync and started_at >= "{timestamp}"'})[0] - .result - == 'success', - timeout=400, - delay=15, - silent_failure=True, - handle_exception=True, - ) - # Workaround for alert message causing search to fail. See airgun issue 584. - session.browser.refresh() - # Verify that the insights recommendation is not listed anymore. + + # Wait for the remediation task to complete. + wait_for( + lambda: module_target_sat_insights.api.ForemanTask() + .search(query={'search': f'{job_query} and started_at >= "{timestamp}"'})[0] + .result + == 'success', + timeout=400, + delay=15, + silent_failure=True, + handle_exception=True, + ) + + # Re-sync the recommendations (hosted Insights only). + if not local_advisor_enabled: + sync_recommendations(module_target_sat_insights, org_name=org_name, loc_name=DEFAULT_LOC) + + with module_target_sat_insights.ui_session() as session: + session.organization.select(org_name=org_name) + session.location.select(loc_name=DEFAULT_LOC) + + # Verify that the recommendation is not listed anymore. assert not session.cloudinsights.search( f'hostname= "{rhel_insights_vm.hostname}" and title = "{OPENSSH_RECOMMENDATION}"' ) @@ -168,7 +183,7 @@ def test_recommendation_sync_for_satellite(): :steps: 1. Register Satellite with insights.(satellite-installer --register-with-insights) 2. Add RH cloud token in settings. - 3. Go to Configure > Insights > Click on Sync recommendations button. + 3. Go to Insights > Recommendations > Click on Sync recommendations button. 4. Click on notification icon. 5. Select recommendation and try remediating it. @@ -195,7 +210,7 @@ def test_host_sorting_based_on_recommendation_count(): :steps: 1. Register few satellite content host with insights. 2. Sync Insights recommendations. - 3. Go to Hosts > All Host + 3. Go to Hosts > All Hosts. 4. Click on "Recommendations" column. 5. Use insights_recommendations_count keyword to filter hosts. @@ -214,10 +229,13 @@ def test_host_sorting_based_on_recommendation_count(): @pytest.mark.tier2 @pytest.mark.no_containers @pytest.mark.rhel_ver_list([7, 8, 9]) +@pytest.mark.parametrize( + "module_target_sat_insights", [True, False], ids=["hosted", "local"], indirect=True +) def test_host_details_page( rhel_insights_vm, rhcloud_manifest_org, - module_target_sat, + module_target_sat_insights, ): """Test host details page for host having insights recommendations. @@ -227,10 +245,10 @@ def test_host_details_page( :steps: 1. Prepare misconfigured machine and upload its data to Insights. - 2. Sync insights recommendations. - 3. Sync RH Cloud inventory status. + 2. Sync Insights recommendations (hosted Insights only). + 3. Sync Insights inventory status (hosted Insights only). 4. Go to Hosts -> All Hosts - 5. Verify there is a "Recommendations" column containing insights recommendation count. + 5. Verify there is a "Recommendations" column containing Insights recommendation count. 6. Check popover status of host. 7. Verify that host properties shows "reporting" inventory upload status. 8. Read the recommendations listed in Insights tab present on host details page. @@ -243,9 +261,9 @@ def test_host_details_page( 3. Insights registration status is displayed in popover status of host. 4. Inventory upload status is present in host properties table. 5. Verify the contents of Insights tab. - 6. Clicking on "Recommendations" tab takes user to Insights page with insights + 6. Clicking on "Recommendations" tab takes user to Insights page with recommendations selected for that host. - 7. Host having insights recommendations is deleted from Satellite. + 7. Host having Insights recommendations is deleted from Satellite. :BZ: 1974578, 1860422, 1928652, 1865876, 1879448 @@ -253,52 +271,56 @@ def test_host_details_page( :CaseAutomation: Automated """ - org = rhcloud_manifest_org - # Prepare misconfigured machine and upload data to Insights + org_name = rhcloud_manifest_org.name + + # Prepare misconfigured machine and upload data to Insights. create_insights_vulnerability(rhel_insights_vm) - with module_target_sat.ui_session() as session: - session.organization.select(org_name=org.name) + + local_advisor_enabled = module_target_sat_insights.local_advisor_enabled + if not local_advisor_enabled: + # Sync insights recommendations. + sync_recommendations(module_target_sat_insights, org_name=org_name, loc_name=DEFAULT_LOC) + + with module_target_sat_insights.ui_session() as session: + session.organization.select(org_name=org_name) session.location.select(loc_name=DEFAULT_LOC) - # Sync insights recommendations - timestamp = datetime.utcnow().strftime('%Y-%m-%d %H:%M') - session.cloudinsights.sync_hits() - wait_for( - lambda: module_target_sat.api.ForemanTask() - .search(query={'search': f'Insights full sync and started_at >= "{timestamp}"'})[0] - .result - == 'success', - timeout=400, - delay=15, - silent_failure=True, - handle_exception=True, - ) + # Verify Insights status of host. result = session.host_new.get_host_statuses(rhel_insights_vm.hostname) assert result['Insights']['Status'] == 'Reporting' - assert result['Inventory']['Status'] == 'Successfully uploaded to your RH cloud inventory' + assert ( + result['Inventory']['Status'] == 'Successfully uploaded to your RH cloud inventory' + if not local_advisor_enabled + else 'N/A' + ) + + # Verify recommendations exist for host. result = session.host_new.search(rhel_insights_vm.hostname)[0] assert result['Name'] == rhel_insights_vm.hostname assert int(result['Recommendations']) > 0 - values = session.host_new.get_host_statuses(rhel_insights_vm.hostname) - assert values['Inventory']['Status'] == 'Successfully uploaded to your RH cloud inventory' - # Read the recommendations listed in Insights tab present on host details page + + # Read the recommendations in Insights tab on host details page. insights_recommendations = session.host_new.get_insights(rhel_insights_vm.hostname)[ 'recommendations_table' ] + + # Verify for recommendation in insights_recommendations: if recommendation['Recommendation'] == DNF_RECOMMENDATION: assert recommendation['Total risk'] == 'Moderate' assert DNF_RECOMMENDATION in recommendation['Recommendation'] assert len(insights_recommendations) == int(result['Recommendations']) + # Test Recommendation button present on host details page recommendations = session.host_new.get_insights(rhel_insights_vm.hostname)[ 'recommendations_table' ] assert len(recommendations), 'No recommendations were found' assert int(result['Recommendations']) == len(recommendations) - # Delete host - rhel_insights_vm.nailgun_host.delete() - assert not rhel_insights_vm.nailgun_host + + # Delete host + rhel_insights_vm.nailgun_host.delete() + assert not rhel_insights_vm.nailgun_host @pytest.mark.e2e @@ -309,7 +331,7 @@ def test_insights_registration_with_capsule( rhcloud_capsule, rhcloud_activation_key, rhcloud_manifest_org, - module_target_sat, + module_target_sat_insights, rhel_contenthost, default_os, ): @@ -348,7 +370,7 @@ def test_insights_registration_with_capsule( rhel_contenthost.create_custom_repos( **{f'rhel{rhelver}_os': settings.repos[f'rhel{rhelver}_os']} ) - with module_target_sat.ui_session() as session: + with module_target_sat_insights.ui_session() as session: session.organization.select(org_name=org.name) session.location.select(loc_name=DEFAULT_LOC) # Generate host registration command @@ -370,7 +392,7 @@ def test_insights_registration_with_capsule( values = session.host_new.get_host_statuses(rhel_contenthost.hostname) assert values['Insights']['Status'] == 'Reporting' # Clean insights status - result = module_target_sat.run( + result = module_target_sat_insights.run( f'foreman-rake rh_cloud_insights:clean_statuses SEARCH="{rhel_contenthost.hostname}"' ) assert 'Deleted 1 insights statuses' in result.stdout diff --git a/tests/foreman/ui/test_rhcloud_inventory.py b/tests/foreman/ui/test_rhcloud_inventory.py index 97bb661bf7b..2aac063ba93 100644 --- a/tests/foreman/ui/test_rhcloud_inventory.py +++ b/tests/foreman/ui/test_rhcloud_inventory.py @@ -151,9 +151,9 @@ def test_rh_cloud_inventory_settings( :steps: 1. Prepare machine and upload its data to Insights. - 2. Go to Configure > Inventory upload > enable “Obfuscate host names” setting. - 3. Go to Configure > Inventory upload > enable “Obfuscate host ipv4 addresses” setting. - 4. Go to Configure > Inventory upload > enable “Exclude Packages” setting. + 2. Go to Insights > Inventory upload > enable “Obfuscate host names” setting. + 3. Go to Insights > Inventory upload > enable “Obfuscate host ipv4 addresses” setting. + 4. Go to Insights > Inventory upload > enable “Exclude Packages” setting. 5. Generate report after enabling the settings. 6. Check if host names are obfuscated in generated reports. 7. Check if hosts ipv4 addresses are obfuscated in generated reports. @@ -296,7 +296,7 @@ def test_failed_inventory_upload(): 1. Register a satellite content host with insights. 2. Change 'DEST' from /var/lib/foreman/red_hat_inventory/uploads/uploader.sh to an invalid url. - 3. Go to Configure > Inventory upload > Click on restart button. + 3. Go to Insights > Inventory upload > Click on restart button. :expectedresults: 1. Inventory report upload failed. @@ -318,7 +318,7 @@ def test_rhcloud_inventory_without_manifest(session, module_org, target_sat): :steps: 1. Don't import manifest to satellite. - 3. Go to Configure > Inventory upload > Click on restart button. + 3. Go to Insights > Inventory upload > Click on restart button. :expectedresults: 1. No stacktrace in production.log @@ -354,3 +354,28 @@ def test_rhcloud_inventory_without_manifest(session, module_org, target_sat): f'Skipping organization {module_org.name}, no candlepin certificate defined.' in inventory_data['uploading']['terminal'] ) + + +@pytest.mark.parametrize("module_target_sat_insights", [False], ids=["local"], indirect=True) +def test_rhcloud_inventory_disabled_local_insights(module_target_sat_insights): + """Verify that the 'Insights > Inventory Upload' navigation item is not available + when the Satellite is configured to use a local advisor engine. + + :id: 84023ae9-7bc4-4332-9aaf-749d6c48c2d2 + + :steps: + 1. Configure Satellite to use local Insights advisor engine. + 2. Navigate to the Insights Recommendations page. + 3. Select Insights > Inventory Upload from the navigation menu. + + :expectedresults: + 1. "Inventory Upload" is not visible under "Insights". + + :CaseImportance: Medium + + :CaseAutomation: Automated + """ + with module_target_sat_insights.ui_session() as session: + insights_view = session.cloudinsights.navigate_to(session.cloudinsights, 'All') + with pytest.raises(Exception, match='not found in navigation tree'): + insights_view.menu.select('Insights', 'Inventory Upload')