From 17e5183bc44404c04645b8be941654edfb2d3992 Mon Sep 17 00:00:00 2001 From: David Moore Date: Thu, 30 May 2024 11:34:55 -0400 Subject: [PATCH] no docstrings --- robottelo/host_helpers/api_factory.py | 78 +-------------------------- tests/foreman/ui/test_errata.py | 77 ++++++++++++++++++++------ 2 files changed, 61 insertions(+), 94 deletions(-) diff --git a/robottelo/host_helpers/api_factory.py b/robottelo/host_helpers/api_factory.py index fcc455c4bc7..2776280c81f 100644 --- a/robottelo/host_helpers/api_factory.py +++ b/robottelo/host_helpers/api_factory.py @@ -466,83 +466,7 @@ def register_host_and_needed_setup( force=False, loc=None, ): - """ - Helper will setup desired entities to host content. Then, register the - host client to the entities, using associated activation-key. - - Attempt to make needed associations between detached entities. - - Add desired repos to the content-view prior to calling this helper. - Or, add them to content-view after calling, then publish/promote. - - The host will be registered to location: None (visible to all locations). - - Parameters: - client : instance - An instance of a RHEL content host to register. - enable_repos : bool, optional - Enable all available repos on the client after registration? Default is False. - Be sure to enable any repo(s) for the client after calling this method. - rex_key : bool, optional - Add a Remote Execution Key to the client for satellite? Default is False. - force : bool, optional - Force registration of the client to bypass? Default is False. - A reused fixture content host will fail if already registered. - loc : object, optional - Pass a location object to limit host visibility. Default is None, - making the client available to all locations. - - The following arguments can be any of the following types: - - int: pass the id of the entity to be read - - str: pass the name of the entity to be searched - - entity: pass an entity instance - - organization : int, str, or entity - Pass an Organization instance, name, or id to use. - activation_key : int, str, or entity - Pass an Activation-Key instance, name, or id. - environment : int, str, or entity - Pass a Lifecycle-Environment instance, name, or id. - Example: can pass string name 'Library'. - content_view : int, str, or entity - Pass a Content-View instance, name, or id. - Example: can pass string name 'Default Organization View'. - - Notes: - 1. Will fail if passed entities do not exist in the same organization and satellite. - 2. Use param `enable_repos` to try enabling any repositories on the client - that were added to the content-view prior. But if there are no - repositories added/made available, this will fail. - 3. The 'Default Organization View' cannot be published, promoted, edited, or deleted, - but you can register the client to it. - - Steps: - 1. Get needed entities from arguments (id, name, or instance). Read all as instance. - 2. Publish the content-view if no versions exist or needs_publish. - 3. Promote the newest content-view-version if not in the environment already. Skip for 'Library'. - 4. Assign environment and content-view to the activation-key if not associated. - 5. If desired, enable all repositories from content-view for activation-key. - 6. Register the host using the activation-key associated with the content. - 7. Add a rex_key to the client if desired. - - Returns: dict - If succeeded: - { - 'result': 'success', - 'client': client, - 'organization': entities['Organization'], - 'activation_key': entities['ActivationKey'], - 'environment': entities['LifecycleEnvironment'], - 'content_view': entities['ContentView'], - } - - If failed: - { - 'result': 'error', - 'client': None, unless registration was successful, - 'message': Details of the failure encountered, - } - """ + # docstrings will be written in a future commit method_error = { 'result': 'error', diff --git a/tests/foreman/ui/test_errata.py b/tests/foreman/ui/test_errata.py index b48a0c56d38..740ff11cd5c 100644 --- a/tests/foreman/ui/test_errata.py +++ b/tests/foreman/ui/test_errata.py @@ -49,6 +49,7 @@ REPOSET, ) from robottelo.hosts import ContentHost +from robottelo.utils.issue_handlers import is_open CUSTOM_REPO_URL = settings.repos.yum_9.url CUSTOM_REPO_ERRATA = settings.repos.yum_9.errata @@ -372,9 +373,10 @@ def test_end_to_end( # BZ 2265095: Check default columns in table of applicable host: # from ContentTypes > Errata > Details > Content Hosts tab assert results[0]['Name'] == hostname - # assert str(client.deploy_rhel_version) in results[0]['OS'] - # assert results[0]['Environment'] == module_lce.name - # assert results[0]['Content View'] == module_cv.name + if not is_open('SAT-23414'): + assert str(client.deploy_rhel_version) in results[0]['OS'] + assert results[0]['Environment'] == module_lce.name + assert results[0]['Content View'] == module_cv.name # Check errata details errata = session.errata.read(CUSTOM_REPO_ERRATA_ID) assert errata['repositories']['table'], ( @@ -839,7 +841,8 @@ def test_positive_list_permission( assert not session.errata.search(CUSTOM_REPO_ERRATA_ID, applicable=False) -@pytest.mark.tier3 +@pytest.mark.e2e +@pytest.mark.tier2 @pytest.mark.upgrade @pytest.mark.no_containers def test_positive_apply_for_all_hosts( @@ -899,13 +902,63 @@ def test_positive_apply_for_all_hosts( assert setup['result'] != 'error', f'{setup["message"]}' assert (client := setup['client']) assert client.subscribed + # install all outdated packages pkgs = ' '.join(FAKE_9_YUM_OUTDATED_PACKAGES) assert client.execute(f'yum install -y {pkgs}').status == 0 + # update and check applicability assert client.execute('subscription-manager repos').status == 0 + assert client.applicable_errata_count > 0 + assert client.applicable_package_count > 0 with session: + timestamp = datetime.utcnow().replace(microsecond=0) - timedelta(seconds=1) session.location.select(loc_name=DEFAULT_LOC) - # for first errata, install in each chost and check, one at a time. + # for first errata, apply to all chosts at once, + # from ContentTypes > Errata > info > ContentHosts tab + errata_id = settings.repos.yum_9.errata[4] # RHBA-2012:1030 + result = session.errata.install( + entity_name=errata_id, + host_names='All', + ) + assert result['overview']['job_status'] == 'Success' + # find single host job + host_job = target_sat.wait_for_tasks( + search_query=( + f'Run hosts job: Install errata {errata_id}' f' and started_at >= {timestamp}' + ), + search_rate=2, + max_tries=60, + ) + assert len(host_job) == 1 + # find multiple install tasks, one for each host + install_tasks = target_sat.wait_for_tasks( + search_query=( + f'Remote action: Install errata {errata_id} on' + f' and started_at >= {timestamp}' + ), + search_rate=2, + max_tries=60, + ) + assert len(install_tasks) == num_hosts + # find single bulk applicability task for hosts + applicability_task = target_sat.wait_for_tasks( + search_query=( + 'Bulk generate applicability for hosts' f' and started_at >= {timestamp}' + ), + search_rate=2, + max_tries=60, + ) + assert len(applicability_task) == 1 + # found updated kangaroo package in each host + updated_version = '0.2-1.noarch' + for client in hosts: + updated_pkg = session.host_new.get_packages( + entity_name=client.hostname, search='kangaroo' + ) + assert len(updated_pkg['table']) == 1 + assert updated_pkg['table'][0]['Installed version'] == updated_version + + # for second errata, install in each chost and check, one at a time. # from Legacy Chost UI > details > Errata tab for client in hosts: status = session.contenthost.install_errata( @@ -918,19 +971,9 @@ def test_positive_apply_for_all_hosts( packages_rows = session.contenthost.search_package( client.hostname, FAKE_2_CUSTOM_PACKAGE ) + # updated walrus package found for each host assert packages_rows[0]['Installed Package'] == FAKE_2_CUSTOM_PACKAGE - # for second errata, apply to all chosts at once - # from Content > Errata > info > ContentHosts tab - errata_id = settings.repos.yum_9.errata[4] # RHBA-2012:1030 - session.errata.install( - entity_name=errata_id, - host_names="All", - ) - # bulk action task for expected hosts - # Actions::RemoteExecution::RunHostsJob - # check each task's status, and each chost's package version - @pytest.mark.tier2 @pytest.mark.upgrade @@ -1066,7 +1109,7 @@ def test_positive_filter_by_environment( indirect=True, ) @pytest.mark.rhel_ver_match('8') -@pytest.mark.skip_if_open('BZ:2280882') +@pytest.mark.skip_if_open('SAT-25213') def test_positive_content_host_previous_env( session, module_cv,