Skip to content
Snippets Groups Projects
Commit d6fce0d5 authored by Antoine Lambert's avatar Antoine Lambert
Browse files

swh-scheduler: Use new task names

Related T1508
parent d6dc50ff
No related branches found
No related tags found
1 merge request!100Use scheduler task names to new ones
......@@ -235,10 +235,10 @@ def schedule_task(ctx, type, options, policy, priority, next_run):
Usage sample:
swh-scheduler --database 'service=swh-scheduler' \
task add swh-lister-pypi
task add list-pypi
swh-scheduler --database 'service=swh-scheduler' \
task add swh-lister-debian --policy=oneshot distribution=stretch
task add list-debian-distribution --policy=oneshot distribution=stretch
Note: if the priority is not given, the task won't have the priority set,
which is considered as the lowest priority level.
......@@ -303,7 +303,7 @@ def schedule_origin_metadata_index(
Usage sample:
swh-scheduler --database 'service=swh-scheduler' \
task schedule_origins indexer_origin_metadata
task schedule_origins index-origin-metadata
"""
from swh.storage import get_storage
from swh.storage.algos.origin import iter_origins
......
......@@ -32,7 +32,7 @@ insert into task_type(
num_retries,
max_queue_length)
values (
'load-deposit-from-archive',
'load-deposit',
'Loading deposit archive into swh through swh-loader-tar',
'swh.deposit.loader.tasks.LoadDepositArchiveTsk',
'1 day', '1 day', '1 day', 1, 3, 1000);
......@@ -44,7 +44,7 @@ insert into task_type(
default_interval, min_interval, max_interval, backoff_factor,
num_retries, max_queue_length)
values (
'check-deposit-archive',
'check-deposit',
'Pre-checking deposit step before loading into swh archive',
'swh.deposit.loader.tasks.ChecksDepositTsk',
'1 day', '1 day', '1 day', 1, 3, 1000);
......@@ -379,10 +379,10 @@ select swh_add_backward_compatible_task_name('origin-update-svn',
'load-svn');
select swh_add_backward_compatible_task_name('swh-deposit-archive-loading',
'load-deposit-from-archive');
'load-deposit');
select swh_add_backward_compatible_task_name('swh-deposit-archive-checks',
'check-deposit-archive');
'check-deposit');
select swh_add_backward_compatible_task_name('swh-vault-cooking',
'cook-vault-bundle');
......
......@@ -89,8 +89,7 @@ class UpdaterWriterTest(UpdaterTestUtil, CommonSchedulerTest,
data = list(self.scheduler_updater_backend.cache_read())
self.assertEqual(len(data), expected_length)
r = self.scheduler_backend.peek_ready_tasks(
'origin-update-git')
r = self.scheduler_backend.peek_ready_tasks('load-git')
# first read on an empty scheduling db results with nothing in it
self.assertEqual(len(r), 0)
......@@ -98,8 +97,7 @@ class UpdaterWriterTest(UpdaterTestUtil, CommonSchedulerTest,
# Read from cache to scheduler db
self.writer.run()
r = self.scheduler_backend.peek_ready_tasks(
'origin-update-git')
r = self.scheduler_backend.peek_ready_tasks('load-git')
# other reads after writes are still empty since it's not supported
self.assertEqual(len(r), 0)
......@@ -121,8 +119,7 @@ class UpdaterWriterTest(UpdaterTestUtil, CommonSchedulerTest,
data = list(self.scheduler_updater_backend.cache_read())
self.assertEqual(len(data), expected_length)
r = self.scheduler_backend.peek_ready_tasks(
'origin-update-git')
r = self.scheduler_backend.peek_ready_tasks('load-git')
# first read on an empty scheduling db results with nothing in it
self.assertEqual(len(r), 0)
......@@ -131,14 +128,13 @@ class UpdaterWriterTest(UpdaterTestUtil, CommonSchedulerTest,
self.writer.run()
# now, we should have scheduling task ready
r = self.scheduler_backend.peek_ready_tasks(
'origin-update-git')
r = self.scheduler_backend.peek_ready_tasks('load-git')
self.assertEqual(len(r), expected_length)
# Check the task has been scheduled
for t in r:
self.assertEqual(t['type'], 'origin-update-git')
self.assertEqual(t['type'], 'load-git')
self.assertEqual(t['priority'], 'normal')
self.assertEqual(t['policy'], 'oneshot')
self.assertEqual(t['status'], 'next_run_not_scheduled')
......@@ -152,7 +148,6 @@ class UpdaterWriterTest(UpdaterTestUtil, CommonSchedulerTest,
self.assertEqual(len(data), 0)
# provided, no runner is ran, still the same amount of scheduling tasks
r = self.scheduler_backend.peek_ready_tasks(
'origin-update-git')
r = self.scheduler_backend.peek_ready_tasks('load-git')
self.assertEqual(len(r), expected_length)
......@@ -47,7 +47,7 @@ class UpdaterWriter:
"""
if event['origin_type'] == 'git':
return create_oneshot_task_dict(
'origin-update-git',
'load-git',
event['url'],
priority='normal')
self.log.warning('Type %s is not supported for now, only git' % (
......
......@@ -31,8 +31,8 @@ def create_task_dict(type, policy, *args, **kwargs):
Args:
type (str): Type of oneshot task as per swh-scheduler's db
table task_type's column (Ex: origin-update-git,
swh-deposit-archive-checks)
table task_type's column (Ex: load-git,
check-deposit)
policy (str): oneshot or recurring policy
Returns:
......@@ -64,8 +64,8 @@ def create_oneshot_task_dict(type, *args, **kwargs):
Args:
type (str): Type of oneshot task as per swh-scheduler's db
table task_type's column (Ex: origin-update-git,
swh-deposit-archive-checks)
table task_type's column (Ex: load-git,
check-deposit)
Returns:
Expected dictionary for the one-shot task scheduling api
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment