Skip to content

Commit

Permalink
[6.15.z] Add a test case for pulp tasks purge (#15638)
Browse files Browse the repository at this point in the history
Add a test case for pulp tasks purge
  • Loading branch information
vsedmik committed Jul 11, 2024
1 parent d3e6bec commit 5e7acef
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 0 deletions.
16 changes: 16 additions & 0 deletions robottelo/hosts.py
Original file line number Diff line number Diff line change
Expand Up @@ -2418,6 +2418,22 @@ def register_contenthost(
org=org, lce=lce, username=username, password=password, enable_proxy=enable_proxy
)

def run_orphan_cleanup(self, smart_proxy_id=None):
"""Run orphan cleanup task for all or given smart proxy."""
timestamp = datetime.utcnow().replace(microsecond=0)
rake_command = 'foreman-rake katello:delete_orphaned_content RAILS_ENV=production'
if smart_proxy_id:
rake_command = f'{rake_command} SMART_PROXY_ID={smart_proxy_id}'
self.execute(rake_command)
self.wait_for_tasks(
search_query=(
'label = Actions::Katello::OrphanCleanup::RemoveOrphans'
f' and started_at >= "{timestamp}"'
),
search_rate=5,
max_tries=10,
)


class SSOHost(Host):
"""Class for RHSSO functions and setup"""
Expand Down
43 changes: 43 additions & 0 deletions tests/foreman/cli/test_repositories.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,3 +125,46 @@ def test_positive_disable_rh_repo_with_basearch(module_target_sat, module_entitl
}
)
assert 'Repository disabled' in disabled_repo[0]['message']


@pytest.mark.parametrize('setting_update', ['completed_pulp_task_protection_days'], indirect=True)
def test_purge_pulp_tasks(module_target_sat, module_org, module_repository, setting_update):
"""Verify that orphan cleanup purges the pulp tasks too.
:id: c605b42c-9547-4444-bdca-06e7138299b5
:parametrized: yes
:setup:
1. Enabled and synced custom repository to ensure we have some pulp tasks buffered.
:steps:
1. Read the current pulp tasks count, run orphan cleanup and read the tasks count again.
2. Set completed_pulp_task_protection_days to zero.
3. Read the current pulp tasks count, run orphan cleanup and read the tasks count again.
:expectedresults:
1. For the default protection time the tasks count should increase since the purge task
is a pulp task too and no previous task should have been purged.
2. For zero protection time the tasks count should decrease since all successfully
completed tasks should have been purged.
:CaseImportance: Medium
:Verifies: SAT-25155
:customerscenario: true
"""
original_ptc = int(module_target_sat.execute('pulp task list | jq length').stdout)
module_target_sat.run_orphan_cleanup(smart_proxy_id=1)
new_ptc = int(module_target_sat.execute('pulp task list | jq length').stdout)
assert new_ptc > original_ptc, 'Pulp tasks were unexpectedly purged'

setting_update.value = 0
setting_update.update({'value'})

original_ptc = int(module_target_sat.execute('pulp task list | jq length').stdout)
module_target_sat.run_orphan_cleanup(smart_proxy_id=1)
new_ptc = int(module_target_sat.execute('pulp task list | jq length').stdout)
assert new_ptc < original_ptc, 'Pulp tasks were not purged'

0 comments on commit 5e7acef

Please sign in to comment.