Skip to content

Commit

Permalink
Test incremental update time
Browse files Browse the repository at this point in the history
  • Loading branch information
damoore044 committed Apr 16, 2024
1 parent e021d3c commit 1985aad
Show file tree
Hide file tree
Showing 2 changed files with 102 additions and 0 deletions.
2 changes: 2 additions & 0 deletions robottelo/constants/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,7 @@ class Colored(Box):
'name': ('Red Hat Satellite Client 6 for RHEL 8 x86_64 RPMs'),
'version': '6',
'reposet': REPOSET['rhsclient8'],
'releasever': None,
'product': PRDS['rhel8'],
'distro': 'rhel8',
'key': PRODUCT_KEY_SAT_CLIENT,
Expand Down Expand Up @@ -513,6 +514,7 @@ class Colored(Box):
'name': 'Red Hat Satellite Tools 6.9 for RHEL 8 x86_64 RPMs',
'version': '6.9',
'reposet': REPOSET['rhst8'],
'releasever': None,
'product': PRDS['rhel8'],
'distro': 'rhel8',
'key': 'rhst',
Expand Down
100 changes: 100 additions & 0 deletions tests/foreman/longrun/test_inc_updates.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]

Expand Down Expand Up @@ -212,3 +214,101 @@ 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.
- Log the duration of the incremental update
5. Publish the full content-view, with added incremental version.
- Log the duration of the content-view publish
:expectedresults:
1. Incremental update takes a short amount of time.
2. Incremental update takes less time than full content-view publish,
or the time taken for both was close (within 20%).
:BZ: 2117760, 1829266
"""
# create content view
cv = module_target_sat.cli_factory.make_content_view(
{'organization-id': module_sca_manifest_org.id}
)
repo_sync_timestamp = (
datetime.utcnow().replace(microsecond=0) - timedelta(seconds=1)
).strftime('%Y-%m-%d %H:%M')
# setup rh repositories, add to cv, begin sync
for _repo in ['rhel8_bos', 'rhst8', 'rhsclient8']:
rh_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[_repo]['name'],
reposet=REPOSET[_repo],
releasever=REPOS[_repo]['releasever'],
)
module_target_sat.cli.ContentView.add_repository(
{
'id': cv['id'],
'organization-id': module_sca_manifest_org.id,
'repository-id': rh_repo_id,
}
)
module_target_sat.api.Repository(id=rh_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 via hammer, using one errata.
# expect: incr. "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 added 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} s.\n publish duration: {publish_duration} s.'
)
# else: base expected condition: update duration was quicker than publish.

0 comments on commit 1985aad

Please sign in to comment.