cgit.tests: Check the tasks from the scheduler
This commit is contained in:
parent
04ca318680
commit
394658e53b
6 changed files with 123 additions and 102 deletions
|
@ -5,7 +5,6 @@
|
|||
|
||||
import os
|
||||
import logging
|
||||
import pkg_resources
|
||||
from copy import deepcopy
|
||||
from importlib import import_module
|
||||
|
||||
|
@ -15,15 +14,12 @@ from sqlalchemy import create_engine
|
|||
from swh.core.cli import CONTEXT_SETTINGS
|
||||
from swh.scheduler import get_scheduler
|
||||
from swh.scheduler.task import SWHTask
|
||||
from swh.lister import get_lister, SUPPORTED_LISTERS, LISTERS
|
||||
from swh.lister.core.models import initialize
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
LISTERS = {entry_point.name.split('.', 1)[1]: entry_point
|
||||
for entry_point in pkg_resources.iter_entry_points('swh.workers')
|
||||
if entry_point.name.split('.', 1)[0] == 'lister'}
|
||||
SUPPORTED_LISTERS = list(LISTERS)
|
||||
|
||||
# the key in this dict is the suffix used to match new task-type to be added.
|
||||
# For example for a task which function name is "list_gitlab_full', the default
|
||||
|
@ -45,31 +41,6 @@ DEFAULT_TASK_TYPE = {
|
|||
}
|
||||
|
||||
|
||||
def get_lister(lister_name, db_url=None, **conf):
|
||||
"""Instantiate a lister given its name.
|
||||
|
||||
Args:
|
||||
lister_name (str): Lister's name
|
||||
conf (dict): Configuration dict (lister db cnx, policy, priority...)
|
||||
|
||||
Returns:
|
||||
Tuple (instantiated lister, drop_tables function, init schema function,
|
||||
insert minimum data function)
|
||||
|
||||
"""
|
||||
if lister_name not in LISTERS:
|
||||
raise ValueError(
|
||||
'Invalid lister %s: only supported listers are %s' %
|
||||
(lister_name, SUPPORTED_LISTERS))
|
||||
if db_url:
|
||||
conf['lister'] = {'cls': 'local', 'args': {'db': db_url}}
|
||||
|
||||
registry_entry = LISTERS[lister_name].load()()
|
||||
lister_cls = registry_entry['lister']
|
||||
lister = lister_cls(override_config=conf)
|
||||
return lister
|
||||
|
||||
|
||||
@click.group(name='lister', context_settings=CONTEXT_SETTINGS)
|
||||
@click.option('--config-file', '-C', default=None,
|
||||
type=click.Path(exists=True, dir_okay=False,),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue