Skip to content
This repository has been archived by the owner on Dec 7, 2022. It is now read-only.
/ pulp Public archive

adding task status reaper #929

Merged
merged 4 commits into from May 12, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 4 additions & 2 deletions server/etc/pulp/server.conf
Expand Up @@ -138,7 +138,8 @@
# repo_group_publish_history: float; time in days to store repository group
# publish history events
#
# task_history: float; time in days to store task results history
# task_status_history: float; time in days to store task status history in the db
# task_result_history: float; time in days to store task results history

[data_reaping]
# reaper_interval: 0.25
Expand All @@ -147,7 +148,8 @@
# repo_sync_history: 60
# repo_publish_history: 60
# repo_group_publish_history: 60
# task_history: 3
# task_status_history: 7
# task_result_history: 3


# = LDAP =
Expand Down
3 changes: 2 additions & 1 deletion server/pulp/server/config.py
Expand Up @@ -34,7 +34,8 @@
'repo_sync_history': '60',
'repo_publish_history': '60',
'repo_group_publish_history': '60',
'task_history': '3',
'task_status_history': '7',
'task_result_history': '3',
},
'database': {
'name': 'pulp_database',
Expand Down
3 changes: 2 additions & 1 deletion server/pulp/server/db/model/dispatch.py
Expand Up @@ -473,9 +473,10 @@ def __init__(self, call_request, call_report):
self.serialized_call_report = call_report.serialize()


class TaskStatus(Model):
class TaskStatus(Model, ReaperMixin):
"""
Represents current state of a task.
The documents in this collection may be reaped, so it inherits from ReaperMixin.

:ivar task_id: identity of the task this status corresponds to
:type task_id: basestring
Expand Down
3 changes: 2 additions & 1 deletion server/pulp/server/db/reaper.py
Expand Up @@ -27,11 +27,12 @@
# Task to determine how old documents should be (in days) before they are removed.
_COLLECTION_TIMEDELTAS = {
dispatch.ArchivedCall: 'archived_calls',
dispatch.TaskStatus: 'task_status_history',
consumer.ConsumerHistoryEvent: 'consumer_history',
repository.RepoSyncResult: 'repo_sync_history',
repository.RepoPublishResult: 'repo_publish_history',
repo_group.RepoGroupPublishResult: 'repo_group_publish_history',
celery_result.CeleryResult: 'task_history',
celery_result.CeleryResult: 'task_result_history',
}


Expand Down
30 changes: 30 additions & 0 deletions server/test/unit/server/db/test_reaper.py
Expand Up @@ -21,10 +21,40 @@
from ... import base
from pulp.server.compat import ObjectId
from pulp.server.db import reaper
from pulp.server.db.model import celery_result, consumer, dispatch, repo_group, repository
from pulp.server.db.model.consumer import ConsumerHistoryEvent
from pulp.server.db.model.reaper_base import _create_expired_object_id, ReaperMixin


class TestReaperCollectionConfig(unittest.TestCase):
"""
Test for expected items in the reaper configuration.
"""
def test_reaper_collections(self):
"""
Test that the expected key-value pairs exist in the reaper collection to timedelta mapping.
"""
collections_to_reap = [dispatch.ArchivedCall,
dispatch.TaskStatus,
consumer.ConsumerHistoryEvent,
repository.RepoSyncResult,
repository.RepoPublishResult,
repo_group.RepoGroupPublishResult,
celery_result.CeleryResult]
for key in collections_to_reap:
self.assertTrue(key in reaper._COLLECTION_TIMEDELTAS)
# Also check the values.
self.assertEqual(reaper._COLLECTION_TIMEDELTAS[dispatch.ArchivedCall], 'archived_calls')
self.assertEqual(reaper._COLLECTION_TIMEDELTAS[dispatch.TaskStatus], 'task_status_history')
self.assertEqual(reaper._COLLECTION_TIMEDELTAS[consumer.ConsumerHistoryEvent], 'consumer_history')
self.assertEqual(reaper._COLLECTION_TIMEDELTAS[repository.RepoSyncResult], 'repo_sync_history')
self.assertEqual(reaper._COLLECTION_TIMEDELTAS[repository.RepoPublishResult],
'repo_publish_history')
self.assertEqual(reaper._COLLECTION_TIMEDELTAS[repo_group.RepoGroupPublishResult],
'repo_group_publish_history')
self.assertEqual(reaper._COLLECTION_TIMEDELTAS[celery_result.CeleryResult],
'task_result_history')

class TestCreateExpiredObjectId(unittest.TestCase):
"""
Assert correct behavior from _create_expired_object_id().
Expand Down