From 87edf527458a972fa9321128646233d3dd3cc8dc Mon Sep 17 00:00:00 2001 From: David Moore Date: Thu, 11 Apr 2024 13:56:52 -0400 Subject: [PATCH] Test incremental update time --- tests/foreman/longrun/test_inc_updates.py | 117 ++++++++++++++++++++++ 1 file changed, 117 insertions(+) diff --git a/tests/foreman/longrun/test_inc_updates.py b/tests/foreman/longrun/test_inc_updates.py index bc44be316ae..a3391043cee 100644 --- a/tests/foreman/longrun/test_inc_updates.py +++ b/tests/foreman/longrun/test_inc_updates.py @@ -22,9 +22,11 @@ ENVIRONMENT, FAKE_4_CUSTOM_PACKAGE, PRDS, + REAL_RHEL8_1_ERRATA_ID, REPOS, REPOSET, ) +from robottelo.logging import logger pytestmark = [pytest.mark.run_in_one_thread] @@ -212,3 +214,118 @@ def test_positive_noapply_api( outval['action'] == 'Incremental Update of 1 Content View Version(s) with 1 Package(s), and 1 Errata' ) + + +@pytest.mark.tier3 +def test_positive_incremental_update_time(module_target_sat, module_sca_manifest_org): + """Incremental update should not take a long time. + + :id: a9cdcc58-2d10-42cf-8e24-f7bec3b79d6b + + :steps: + 1. Setup larger rh repositories; rhel8 baseOS, rhst8, rhsc8. + 2. Create content view and add repos, sync and wait. + 3. Publish a content view version with all content. + 4. Using hammer, perform incremental update with errata, on that new version. + 5. Publish the full content-view, with incremental version. + + :expectedresults: + 1. Incremental update takes a short amount of time. + 2. Incremental update takes less time than full content-view publish. + + :BZ: 2117760, 1829266 + + """ + # rhel8 base os + rhel8_repo_id = module_target_sat.api_factory.enable_rhrepo_and_fetchid( + basearch=DEFAULT_ARCHITECTURE, + org_id=module_sca_manifest_org.id, + product=PRDS['rhel8'], + repo=REPOS['rhel8_bos']['name'], + reposet=REPOSET['rhel8_bos'], + releasever=REPOS['rhel8_bos']['releasever'], + ) + # rh sat tools + rhst8_repo_id = module_target_sat.api_factory.enable_rhrepo_and_fetchid( + basearch=DEFAULT_ARCHITECTURE, + org_id=module_sca_manifest_org.id, + product=PRDS['rhel8'], + repo=REPOS['rhst8']['name'], + reposet=REPOSET['rhst8'], + releasever=None, + ) + # rh sat client + rhsc8_repo_id = module_target_sat.api_factory.enable_rhrepo_and_fetchid( + basearch=DEFAULT_ARCHITECTURE, + org_id=module_sca_manifest_org.id, + product=PRDS['rhel8'], + repo=REPOS['rhsclient8']['name'], + reposet=REPOSET['rhsclient8'], + releasever=None, + ) + # create content view, add all repos, begin sync + cv = module_target_sat.cli_factory.make_content_view( + {'organization-id': module_sca_manifest_org.id} + ) + rhel_repos = [rhst8_repo_id, rhsc8_repo_id, rhel8_repo_id] + repo_sync_timestamp = ( + datetime.utcnow().replace(microsecond=0) - timedelta(seconds=1) + ).strftime('%Y-%m-%d %H:%M') + for repo_id in rhel_repos: + module_target_sat.cli.ContentView.add_repository( + { + 'id': cv['id'], + 'organization-id': module_sca_manifest_org.id, + 'repository-id': repo_id, + } + ) + module_target_sat.api.Repository(id=repo_id).sync(synchronous=False) + # wait for all repo sync tasks + sync_tasks = module_target_sat.wait_for_tasks( + search_query=( + 'label = Actions::Katello::Repository::Sync' + f' and started_at >= "{repo_sync_timestamp}"' + ), + search_rate=10, + max_tries=200, + ) + assert all(task.poll()['result'] == 'success' for task in sync_tasks) + # publish and fetch new CVV + module_target_sat.cli.ContentView.publish({'id': cv['id']}) + content_view = module_target_sat.cli.ContentView.info({'id': cv['id']}) + cvv = content_view['versions'][0] + + # update incremental version of the CVV via hammer, using one errata. + # expect: incremental "version-1.1" is created + update_start_time = datetime.utcnow() + result = module_target_sat.cli.ContentView.version_incremental_update( + {'content-view-version-id': cvv['id'], 'errata-ids': REAL_RHEL8_1_ERRATA_ID} + ) + assert 'version-1.1' in str(result[0].keys()) + update_duration = (datetime.utcnow() - update_start_time).total_seconds() + logger.info( + f'Update of incremental version-1.1, for CV id: {content_view["id"]},' + f' took {update_duration} seconds.' + ) + + # publish the full CV, containing the new version-1.1 + publish_start_time = datetime.utcnow() + result = module_target_sat.cli.ContentView.publish({'id': cv['id']}) + publish_duration = (datetime.utcnow() - publish_start_time).total_seconds() + logger.info(f'Publish for CV id: {content_view["id"]}, took {publish_duration} seconds.') + # some arbritrary timeouts, given amount of content in CV from repos. + assert update_duration <= 60 + assert publish_duration <= 240 + + # Per BZs: expect update duration was quicker than publish duration, + # if instead, update took longer, check that they were close, + # that update did not take ~significantly more time. + if update_duration >= publish_duration: + # unexpected: perhaps both tasks were very quick, took a handful of seconds, + # assert the difference was not significant (within 20%). + assert (update_duration - publish_duration) / publish_duration <= 0.2, ( + f'Incremental update took longer than publish of entire content-view id: {content_view["id"]}:' + f' Update took significantly more time, 20% or longer, than publish.' + f' update duration: {update_duration} \n publish duration: {publish_duration}' + ) + # else: base expected condition: update duration was quicker than publish.