コード例 #1
0
ファイル: app.py プロジェクト: mautotest/runner
def work():
    cmd = request.form["cmd"]
    app.logger.info('get work!========>cmd:{}'.format(cmd))
    if s.status != StatusType.ONELINE:
        return Result().bulid_fail()
    s.status = StatusType.PENDING
    date = datetime.datetime.now() + datetime.timedelta(seconds=3)
    args = [cmd, "12345"]
    from queue import Queue
    test_queue = Queue()
    job = start_work(date=date, args=args, test_queue=test_queue)
    return Result({
        "status": StatusType.PENDING,
        "job": job.id
    }).bulid_success()
コード例 #2
0
 def post(self):
   try:
     result = Result.from_request(request)
   except BadRequestError as e:
     return e.message, e.code
   if result.success:
     job = Job.find(result.job_id)
     for worker_enqueue_agrs in result.workers_to_enqueue:
       job.enqueue(*worker_enqueue_agrs)
     job.task_succeeded(result.task_name)
   else:
     job = Job.find(result.job_id)
     job.task_failed(result.task_name)
   return 'OK', 200
コード例 #3
0
 def run(self, runner_type):
     """
     run all test suits which in the config file
     
     Arguments:
         runner_type {GenerateType} -- generate type, which type you want to generate, current it supports Html and xml
     """
     result = Result()
     try:
         file_name = 'TEST-REPORT-{0}.{1}'.format(
             time.strftime("%Y%m%d%H%M%S"), runner_type)
         suites = self.load()
         if runner_type == GenerateType().XML:
             result.msg = self.__run_xml(suites, file_name)
         else:
             result.msg = self.__run_html(suites, file_name)
         result.ok = True
     except Exception as e:
         result.ok = False
         result.msg = "error durring run suits {}".format(e)
     finally:
         return result
コード例 #4
0
 def to_json(self):
     from common.result import Result, SignResult
     ret = Result()
     ret = SignResult(ret, self)
     return ret.get_ret()
コード例 #5
0
def start_task():
  try:
    task = Task.from_request(request)
  except (BadRequestError, TooEarlyError) as e:
    return e.message, e.code

  worker_class = workers.find(task.worker_class)
  worker_params = task.worker_params.copy()
  for setting in worker_class.GLOBAL_SETTINGS:
    worker_params[setting] = task.general_settings[setting]
  worker = worker_class(worker_params, task.pipeline_id, task.job_id)

  try:
    workers_to_enqueue = worker.execute()
  except WorkerException as e:
    worker.log_error('Execution failed: %s: %s', e.__class__.__name__, e)
    result = Result(task.name, task.job_id, False)
    result.report()
  except Exception as e:  # pylint: disable=broad-except
    worker.log_error('Unexpected error %s', format_exc())
    if task.attempts < worker.MAX_ATTEMPTS:
      task.reenqueue()
    else:
      worker.log_error('Giving up after %i attempt(s)', task.attempts)
      result = Result(task.name, task.job_id, False)
      result.report()
  else:
    result = Result(task.name, task.job_id, True, workers_to_enqueue)
    result.report()
  return 'OK', 200