Esempio n. 1
0
    def run_task(self, task):
        """Actually run a task, inserting a DB row and generating the celery task."""
        job = tables.BadpennyJob(task_id=task.task_id, created_at=time.now())
        current_app.db.session('relengapi').add(job)
        current_app.db.session('relengapi').commit()

        execution.submit_job(task_name=task.name, job_id=job.id)
Esempio n. 2
0
    def run_task(self, task):
        """Actually run a task, inserting a DB row and generating the celery task."""
        job = tables.BadpennyJob(
            task_id=task.task_id,
            created_at=time.now())
        current_app.db.session('relengapi').add(job)
        current_app.db.session('relengapi').commit()

        execution.submit_job(task_name=task.name, job_id=job.id)
Esempio n. 3
0
def run_task_now(task_name):
    """Force the given badpenny task to run now."""
    t = tables.BadpennyTask.query.filter(
        tables.BadpennyTask.name == task_name).first()
    if not t:
        raise NotFound

    session = current_app.db.session('relengapi')
    job = tables.BadpennyJob(task=t, created_at=time.now())
    session.add(job)
    session.commit()

    execution.submit_job(task_name=t.name, job_id=job.id)
    return job.to_jsonjob()
Esempio n. 4
0
def run_task_now(task_name):
    """Force the given badpenny task to run now."""
    t = tables.BadpennyTask.query.filter(
        tables.BadpennyTask.name == task_name).first()
    if not t:
        raise NotFound

    session = current_app.db.session('relengapi')
    job = tables.BadpennyJob(task=t, created_at=time.now())
    session.add(job)
    session.commit()

    execution.submit_job(task_name=t.name, job_id=job.id)
    return job.to_jsonjob()
Esempio n. 5
0
def test_submit_job():
    """`execution.submit_job` just invokes _run_job via Celery"""
    with mock.patch('relengapi.blueprints.badpenny.execution._run_job') as _run_job:
        execution.submit_job('foo', 10)
        _run_job.delay.assert_called_with('foo', 10)
Esempio n. 6
0
def test_submit_job():
    """`execution.submit_job` just invokes _run_job via Celery"""
    with mock.patch(
            'relengapi.blueprints.badpenny.execution._run_job') as _run_job:
        execution.submit_job('foo', 10)
        _run_job.delay.assert_called_with('foo', 10)