Exemple #1
0
    def get_task_status_json(cls):
        def create_task_events(start_time):
            """Create a list of task events, tracing the task from pending to assigned to running"""
            return [
                TaskEvent(timestamp=start_time,
                          status=0,
                          message="looking for a host"),
                TaskEvent(timestamp=start_time + 10,
                          status=9,
                          message="found a host"),
                TaskEvent(timestamp=start_time + 20,
                          status=2,
                          message="running")
            ]

        def create_scheduled_task(instance, start_time):
            task = ScheduledTask(assignedTask=AssignedTask(
                taskId="task_%s" % instance,
                slaveId="random_machine_id",
                slaveHost="junk.nothing",
                task=TaskConfig(job=JobKey(role="nobody",
                                           environment="prod",
                                           name='flibber'),
                                owner=Identity(role="nobody"),
                                environment="prod",
                                jobName="flibber",
                                isService=False,
                                numCpus=2,
                                ramMb=2048,
                                diskMb=4096,
                                priority=7,
                                maxTaskFailures=3,
                                production=False,
                                requestedPorts=["http"]),
                assignedPorts={"http": 1001},
                instanceId=instance),
                                 status=2,
                                 failureCount=instance + 4,
                                 taskEvents=create_task_events(start_time),
                                 ancestorId="random_task_ancestor%s" %
                                 instance)
            return task

        resp = cls.create_simple_success_response()
        scheduleStatus = ScheduleStatusResult()
        scheduleStatus.tasks = [
            create_scheduled_task(0, 123456),
            create_scheduled_task(1, 234567)
        ]
        resp.result = Result(scheduleStatusResult=scheduleStatus)
        return resp
Exemple #2
0
    def get_task_status_json(cls):
        def create_task_events(start_time):
            """Create a list of task events, tracing the task from pending to assigned to running"""
            return [
                TaskEvent(timestamp=start_time,
                          status=0,
                          message="looking for a host"),
                TaskEvent(timestamp=start_time + 10,
                          status=9,
                          message="found a host"),
                TaskEvent(timestamp=start_time + 20,
                          status=2,
                          message="running")
            ]

        def create_scheduled_task(instance, start_time):
            task = ScheduledTask()
            task.assignedTask = AssignedTask()
            task.assignedTask.taskId = "task_%s" % instance
            task.assignedTask.slaveId = "random_machine_id"
            task.assignedTask.slaveHost = "junk.nothing"
            task.assignedTask.task = TaskConfig()
            task.assignedTask.task.owner = Identity(role="nobody")
            task.assignedTask.task.environment = "prod"
            task.assignedTask.task.jobName = "flibber"
            task.assignedTask.task.isService = False
            task.assignedTask.task.numCpus = 2
            task.assignedTask.task.ramMb = 2048
            task.assignedTask.task.diskMb = 4096
            task.assignedTask.task.priority = 7
            task.assignedTask.task.maxTaskFailures = 3
            task.assignedTask.task.production = False
            task.assignedTask.task.requestedPorts = ["http"]
            task.assignedTask.assignedPorts = {"http": 1001}
            task.assignedTask.instanceId = 0
            task.status = 2
            task.failureCount = instance + 4
            task.taskEvents = create_task_events(start_time)
            task.ancestorId = "random_task_ancestor%s" % instance
            return task

        resp = cls.create_simple_success_response()
        scheduleStatus = ScheduleStatusResult()
        scheduleStatus.tasks = [
            create_scheduled_task(0, 123456),
            create_scheduled_task(1, 234567)
        ]
        resp.result.scheduleStatusResult = scheduleStatus
        return resp
Exemple #3
0
  def get_task_status_json(cls):
    def create_task_events(start_time):
      """Create a list of task events, tracing the task from pending to assigned to running"""
      return [
          TaskEvent(timestamp=start_time, status=0, message="looking for a host"),
          TaskEvent(timestamp=start_time + 10, status=9, message="found a host"),
          TaskEvent(timestamp=start_time + 20, status=2, message="running")
      ]

    def create_scheduled_task(instance, start_time):
      task = ScheduledTask(
        assignedTask=AssignedTask(
          taskId="task_%s" % instance,
          slaveId="random_machine_id",
          slaveHost="junk.nothing",
          task=TaskConfig(
            job=JobKey(role="nobody", environment="prod", name='flibber'),
            owner=Identity(role="nobody"),
            environment="prod",
            jobName="flibber",
            isService=False,
            numCpus=2,
            ramMb=2048,
            diskMb=4096,
            priority=7,
            maxTaskFailures=3,
            production=False,
            requestedPorts=["http"]),
          assignedPorts={"http": 1001},
          instanceId=instance),
        status=2,
        failureCount=instance + 4,
        taskEvents=create_task_events(start_time),
        ancestorId="random_task_ancestor%s" % instance)
      return task

    resp = cls.create_simple_success_response()
    scheduleStatus = ScheduleStatusResult()
    scheduleStatus.tasks = [
      create_scheduled_task(0, 123456),
      create_scheduled_task(1, 234567)
    ]
    resp.result.scheduleStatusResult = scheduleStatus
    return resp
  def get_task_status_json(cls):
    def create_task_events(start_time):
      """Create a list of task events, tracing the task from pending to assigned to running"""
      return [
          TaskEvent(timestamp=start_time, status=0, message="looking for a host"),
          TaskEvent(timestamp=start_time + 10, status=9, message="found a host"),
          TaskEvent(timestamp=start_time + 20, status=2, message="running")
      ]

    def create_scheduled_task(instance, start_time):
      task = ScheduledTask()
      task.assignedTask = AssignedTask()
      task.assignedTask.taskId = "task_%s" % instance
      task.assignedTask.slaveId = "random_machine_id"
      task.assignedTask.slaveHost = "junk.nothing"
      task.assignedTask.task = TaskConfig()
      task.assignedTask.task.owner = Identity(role="nobody")
      task.assignedTask.task.environment = "prod"
      task.assignedTask.task.jobName = "flibber"
      task.assignedTask.task.isService = False
      task.assignedTask.task.numCpus = 2
      task.assignedTask.task.ramMb = 2048
      task.assignedTask.task.diskMb = 4096
      task.assignedTask.task.priority = 7
      task.assignedTask.task.maxTaskFailures = 3
      task.assignedTask.task.production = False
      task.assignedTask.task.requestedPorts = ["http"]
      task.assignedTask.assignedPorts = {"http": 1001}
      task.assignedTask.instanceId = 0
      task.status = 2
      task.failureCount = instance + 4
      task.taskEvents = create_task_events(start_time)
      task.ancestorId = "random_task_ancestor%s" % instance
      return task

    resp = cls.create_simple_success_response()
    scheduleStatus = ScheduleStatusResult()
    scheduleStatus.tasks = [
      create_scheduled_task(0, 123456),
      create_scheduled_task(1, 234567)
    ]
    resp.result.scheduleStatusResult = scheduleStatus
    return resp