예제 #1
0
파일: test_job.py 프로젝트: jawahars16/ci
    def test_add_job(self):
        service = JobService(self.testdb)
        service.add_job('Test title', 'Test description')

        jobs = service.get_jobs()
        self.assertEqual(1, len(jobs))
        self.assertEqual(jobs[0].title, 'Test title')
예제 #2
0
 def _on_job_remove(self, event):
     from service.job_service import JobService
     job_id = event.job_id
     job = JobService.get_job(job_id)
     # 有自动删除的情况
     if job.status != job.Status.STOPPED.value:
         JobService.change_job_status(job_id, job.Status.STOPPED)
     logger.info('定时任务%s被移除了调度器,信息:%s' % (job_id, str(job)))
예제 #3
0
 def _on_job_add(self, event):
     from service.job_service import JobService
     job_id = event.job_id
     job = JobService.get_job(job_id)
     # 有自动加入的情况
     if job.status != job.Status.RUNNING.value:
         JobService.change_job_status(job_id, job.Status.RUNNING)
         job.status = job.Status.RUNNING.value
     logger.info('定时任务%s加入了调度器,信息:%s' % (job_id, str(job)))
예제 #4
0
 def _on_job_modify(self, event):
     from service.job_service import JobService
     job_id = event.job_id
     job = self._scheduler.get_job(job_id)
     if job.next_run_time is None:
         job = JobService.get_job(job_id)
         logger.info('定时任务%s已暂停,信息:%s' % (job_id, str(job)))
         if job.status != job.Status.SUSPENDED.value:
             JobService.change_job_status(job_id, job.Status.SUSPENDED)
     else:
         logger.info('定时任务%s被修改或重启了并正在运行中,信息:%s' % (job_id, str(job)))
예제 #5
0
파일: test_job.py 프로젝트: jawahars16/ci
    def test_add_steps_to_job(self):
        service = JobService(self.testdb)
        service.add_job('Test title', 'Test description')

        jobs = service.get_jobs()
        job_id = jobs[0].id

        step1_parameter1 = TaskParameter(key='step1_key1',
                                         value='step1_value1')
        step1_parameter2 = TaskParameter(key='step1_key2',
                                         value='step1_value2')

        step1 = Step('Test step 1', job_id)
        step1.parameters = [step1_parameter1, step1_parameter2]

        step2_parameter1 = TaskParameter(key='step2_key1',
                                         value='step2_value1')
        step2_parameter2 = TaskParameter(key='step2_key2',
                                         value='step2_value2')
        step2_parameter3 = TaskParameter(key='step2_key3',
                                         value='step2_value3')

        step2 = Step('Test step 2', job_id)
        step2.parameters = [
            step2_parameter1, step2_parameter2, step2_parameter3
        ]

        service.add_steps(job_id, [step1, step2])

        steps = service.get_steps(job_id)
        self.assertEqual(2, len(steps))
        self.assertEqual('Test step 1', steps[0].title)
예제 #6
0
파일: test_build.py 프로젝트: jawahars16/ci
    def test_queue_build(self):
        build_service = BuildService(self.testdb)
        job_service = JobService(self.testdb)

        job_service.add_job('Test job')
        job = job_service.get_jobs()[0]

        self.assertIsNotNone(job)

        build_service.queueBuild(job.id)
        build_service.queueBuild(job.id)

        builds = build_service.get_queue_builds(job.id)

        self.assertEqual(2, len(builds))
        self.assertFalse(builds[0].id == builds[1].id)
예제 #7
0
 def _on_job_error(self, event):
     from service.job_service import JobService
     e = event.exception
     job_id = event.job_id
     logger.warn('定时任务%s发生错误,将被移除调度器' % job_id)
     logger.error(str(e))
     task = JobService.get_job(job_id)
     self.remove_job(task)
예제 #8
0
 def pause_job(self, job_id):
     return JobService.pause_job(job_id)
예제 #9
0
def test_submit_job():
    bytes = "#!/usr/bin/env python3\n# -*- coding: utf-8 -*-\ndef run():"
    config = {'name': 'hahah', 'job_id': 'jjjj', 'cron': 'ddd'}
    JobService.submit_job(bytes, config)
예제 #10
0
def test_pause_job(job_id):
    JobService.pause_job(job_id)
예제 #11
0
def test_modify_job(job_id):
    JobService.modify_job(job_id, {'name': 'test', 'cron': '{"seconds": 8}'})
예제 #12
0
def test_stop_job(job_id):
    JobService.stop_job(job_id)
예제 #13
0
def test_start_job(job_id):
    JobService.start_job(job_id)
예제 #14
0
def test_resume_scheduler():
    JobService.resume_scheduler()
예제 #15
0
 def pause_scheduler(self):
     return JobService.pause_scheduler()
예제 #16
0
 def modify_job(self, job_id, config):
     return JobService.modify_job(job_id, config)
예제 #17
0
 def resume_scheduler(self):
     return JobService.resume_scheduler()
예제 #18
0
파일: test_job.py 프로젝트: jawahars16/ci
    def test_add_job_without_title(self):
        service = JobService(self.testdb)
        service.add_job(None)

        jobs = service.get_jobs()
        self.assertEqual(0, len(jobs))
예제 #19
0
 def stop_job(self, job_id):
     return JobService.stop_job(job_id)
예제 #20
0
 def status(self):
     return JobService.status()
예제 #21
0
 def submit_job(self, file_bytes, config):
     return JobService.submit_job(file_bytes, config)
예제 #22
0
class JobBaseController(BaseController):
    job_service = JobService()
예제 #23
0
def test_stop_scheduler():
    JobService.stop_scheduler()
예제 #24
0
 def _on_job_execute(self, event):
     from service.job_service import JobService
     job_id = event.job_id
     logger.info('定时任务%s开始执行' % job_id)
     JobService.add_executed_times(job_id, 1)
예제 #25
0
def test_pause_scheduler():
    JobService.pause_scheduler()
예제 #26
0
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
'执行入口'
from common.log import logger
from service.job_service import JobService
from thrift_server import server

__author__ = 'Jiateng Liang'

if __name__ == '__main__':
    # 防止意外停止
    JobService.stop_all_jobs()
    try:
        server.run()
    except Exception as ex:
        logger.error(ex)
예제 #27
0
 def stop_scheduler(self):
     return JobService.stop_scheduler()