Skip to content

Commit

Permalink
[6.13.z] Fix waiting for upgrade capsule sync (#13883)
Browse files Browse the repository at this point in the history
  • Loading branch information
Satellite-QE authored Jan 23, 2024
1 parent cf01b5c commit a6530f7
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 12 deletions.
4 changes: 2 additions & 2 deletions robottelo/host_helpers/capsule_mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,14 @@ def wait_for_sync(self, timeout=600, start_time=None):
# Assert that a task to sync lifecycle environment to the capsule
# is started (or finished already)
if start_time is None:
start_time = datetime.utcnow()
start_time = datetime.utcnow().replace(microsecond=0)
logger.info(f"Waiting for capsule {self.hostname} sync to finish ...")
sync_status = self.nailgun_capsule.content_get_sync()
logger.info(f"Active tasks {sync_status['active_sync_tasks']}")
assert (
len(sync_status['active_sync_tasks'])
or datetime.strptime(sync_status['last_sync_time'], '%Y-%m-%d %H:%M:%S UTC')
> start_time
>= start_time
)

# Wait till capsule sync finishes and assert the sync task succeeded
Expand Down
28 changes: 18 additions & 10 deletions tests/upgrades/test_capsule.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,7 @@ def test_post_user_scenario_capsule_sync(
ak_env = ak.environment.read()
org = ak.organization.read()
content_view = target_sat.api.ContentView(id=pre_upgrade_data.get('content_view_id')).read()
pre_configured_capsule.nailgun_capsule.content_sync(timeout=3600)
pre_configured_capsule.wait_for_sync(timeout=9000)
pre_configured_capsule.nailgun_capsule.content_sync(timeout=7200)

sat_repo_url = target_sat.get_published_repo_url(
org=org.label,
Expand All @@ -125,19 +124,24 @@ def test_post_user_scenario_capsule_sync(
)
sat_files_urls = get_repo_files_urls_by_url(sat_repo_url)
cap_files_urls = get_repo_files_urls_by_url(cap_repo_url)
assert len(sat_files_urls) == len(cap_files_urls) == constants.FAKE_1_YUM_REPOS_COUNT
assert (
len(sat_files_urls) == constants.FAKE_1_YUM_REPOS_COUNT
), 'upstream and satellite repo rpm counts are differrent'
assert len(sat_files_urls) == len(
cap_files_urls
), 'satellite and capsule repo rpm counts are differrent'

sat_files = {os.path.basename(f) for f in sat_files_urls}
cap_files = {os.path.basename(f) for f in cap_files_urls}
assert sat_files == cap_files
assert sat_files == cap_files, 'satellite and capsule rpm basenames are differrent'

for pkg in constants.FAKE_1_YUM_REPO_RPMS:
assert pkg in sat_files, f'{pkg=} is not in the {repo=} on satellite'
assert pkg in cap_files, f'{pkg=} is not in the {repo=} on capsule'

sat_files_md5 = [target_sat.md5_by_url(url) for url in sat_files_urls]
cap_files_md5 = [target_sat.md5_by_url(url) for url in cap_files_urls]
assert sat_files_md5 == cap_files_md5
assert sat_files_md5 == cap_files_md5, 'satellite and capsule rpm md5sums are differrent'


class TestCapsuleSyncNewRepo:
Expand Down Expand Up @@ -182,8 +186,7 @@ def test_post_user_scenario_capsule_sync_yum_repo(
content_view.read().version[0].promote(data={'environment_ids': ak_env.id})
content_view_env = [env.id for env in content_view.read().environment]
assert ak_env.id in content_view_env
pre_configured_capsule.nailgun_capsule.content_sync()
pre_configured_capsule.wait_for_sync(timeout=9000)
pre_configured_capsule.nailgun_capsule.content_sync(timeout=7200)

sat_repo_url = target_sat.get_published_repo_url(
org=default_org.label,
Expand All @@ -202,16 +205,21 @@ def test_post_user_scenario_capsule_sync_yum_repo(

sat_files_urls = get_repo_files_urls_by_url(sat_repo_url)
cap_files_urls = get_repo_files_urls_by_url(cap_repo_url)
assert len(sat_files_urls) == len(cap_files_urls) == constants.FAKE_1_YUM_REPOS_COUNT
assert (
len(sat_files_urls) == constants.FAKE_1_YUM_REPOS_COUNT
), 'upstream and satellite repo rpm counts are differrent'
assert len(sat_files_urls) == len(
cap_files_urls
), 'satellite and capsule repo rpm counts are differrent'

sat_files = {os.path.basename(f) for f in sat_files_urls}
cap_files = {os.path.basename(f) for f in cap_files_urls}
assert sat_files == cap_files
assert sat_files == cap_files, 'satellite and capsule rpm basenames are differrent'

for pkg in constants.FAKE_1_YUM_REPO_RPMS:
assert pkg in sat_files, f'{pkg=} is not in the {repo=} on satellite'
assert pkg in cap_files, f'{pkg=} is not in the {repo=} on capsule'

sat_files_md5 = [target_sat.md5_by_url(url) for url in sat_files_urls]
cap_files_md5 = [target_sat.md5_by_url(url) for url in cap_files_urls]
assert sat_files_md5 == cap_files_md5
assert sat_files_md5 == cap_files_md5, 'satellite and capsule rpm md5sums are differrent'

0 comments on commit a6530f7

Please sign in to comment.