Exemplo n.º 1
0
 def create_scheduled_tasks(cls):
   tasks = []
   for name in ['foo', 'bar', 'baz']:
     task = ScheduledTask()
     task.failure_count = 0
     task.assignedTask = AssignedTask()
     task.assignedTask.taskId = 1287391823
     task.assignedTask.slaveHost = 'slavehost'
     task.assignedTask.task = TaskConfig()
     task.assignedTask.task.maxTaskFailures = 1
     task.assignedTask.task.executorConfig = ExecutorConfig()
     task.assignedTask.task.executorConfig.data = Mock()
     task.assignedTask.task.metadata = []
     task.assignedTask.task.job = JobKey(role=cls.TEST_ROLE, environment=cls.TEST_ENV, name=name)
     task.assignedTask.task.owner = Identity(role=cls.TEST_ROLE)
     task.assignedTask.task.environment = cls.TEST_ENV
     task.assignedTask.task.jobName = name
     task.assignedTask.task.numCpus = 2
     task.assignedTask.task.ramMb = 2
     task.assignedTask.task.diskMb = 2
     task.assignedTask.instanceId = 4237894
     task.assignedTask.assignedPorts = {}
     task.status = ScheduleStatus.RUNNING
     event = TaskEvent()
     event.timestamp = 28234726395
     event.status = ScheduleStatus.RUNNING
     event.message = "Hi there"
     task.taskEvents = [event]
     tasks.append(task)
   return tasks
Exemplo n.º 2
0
 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'),
                         isService=False,
                         resources=frozenset([
                             Resource(numCpus=2),
                             Resource(ramMb=2048),
                             Resource(diskMb=4096)
                         ]),
                         priority=7,
                         maxTaskFailures=3,
                         production=False),
         assignedPorts={"http": 1001},
         instanceId=instance),
                          status=2,
                          failureCount=instance + 4,
                          taskEvents=create_task_events(start_time),
                          ancestorId="random_task_ancestor%s" %
                          instance)
     return task
Exemplo n.º 3
0
    def create_scheduled_tasks(cls):
        tasks = []
        for name in ['foo', 'bar', 'baz']:
            task = ScheduledTask(
                failureCount=0,
                assignedTask=AssignedTask(
                    taskId=1287391823,
                    slaveHost='slavehost',
                    task=TaskConfig(
                        maxTaskFailures=1,
                        executorConfig=ExecutorConfig(data='fake data'),
                        metadata=[],
                        job=JobKey(role=cls.TEST_ROLE,
                                   environment=cls.TEST_ENV,
                                   name=name),
                        owner=Identity(role=cls.TEST_ROLE),
                        environment=cls.TEST_ENV,
                        jobName=name,
                        numCpus=2,
                        ramMb=2,
                        diskMb=2),
                    instanceId=4237894,
                    assignedPorts={}),
                status=ScheduleStatus.RUNNING,
                taskEvents=[
                    TaskEvent(timestamp=28234726395,
                              status=ScheduleStatus.RUNNING,
                              message="Hi there")
                ])

            tasks.append(task)
        return tasks
Exemplo n.º 4
0
 def create_task(cls):
     return [
         ScheduledTask(assignedTask=AssignedTask(
             instanceId=0,
             task=TaskConfig(
                 job=JobKey(role='role', environment='test', name='job'))),
                       status=ScheduleStatus.RUNNING)
     ]
Exemplo n.º 5
0
 def create_task(cls):
     return [
         ScheduledTask(assignedTask=AssignedTask(
             instanceId=0,
             task=TaskConfig(owner=Identity(role='test_role'),
                             jobName='test_job')),
                       status=ScheduleStatus.RUNNING)
     ]
Exemplo n.º 6
0
 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
Exemplo n.º 7
0
 def mock_status_active_tasks(self, instance_ids):
   tasks = []
   for i in instance_ids:
     tasks.append(ScheduledTask(
         status=ScheduleStatus.RUNNING,
         assignedTask=AssignedTask(task=TaskConfig(), instanceId=i)
     ))
   response = make_response(result=Result(scheduleStatusResult=ScheduleStatusResult(tasks=tasks)))
   self.mock_scheduler.getTasksWithoutConfigs(IgnoreArg()).AndReturn(response)
Exemplo n.º 8
0
 def expect_get_tasks(self, tasks, ignore_ids=None, response_code=ResponseCode.OK):
   scheduled = []
   for index, task in enumerate(tasks):
     if not ignore_ids or index not in ignore_ids:
       scheduled.append(ScheduledTask(assignedTask=AssignedTask(task=task, instanceId=index)))
   response = make_response(response_code)
   response.result = Result(scheduleStatusResult=ScheduleStatusResult(tasks=scheduled))
   query = TaskQuery(jobKeys=[self._job_key], statuses=ACTIVE_STATES)
   self._scheduler.getTasksStatus(query).AndReturn(response)
Exemplo n.º 9
0
 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
Exemplo n.º 10
0
 def create_scheduled_task(cls,
                           instance_id,
                           status=ScheduleStatus.RUNNING,
                           task_id=None,
                           initial_time=None):
     task = ScheduledTask(
         status=status,
         assignedTask=AssignedTask(instanceId=instance_id,
                                   taskId=task_id or "Task%s" % instance_id,
                                   slaveId="Slave%s" % instance_id,
                                   slaveHost="Slave%s" % instance_id,
                                   task=TaskConfig()),
         taskEvents=[TaskEvent(timestamp=initial_time or 1000)])
     return task
Exemplo n.º 11
0
 def create_task(self, duration, id, host=None, name=None, prod=None):
     return ScheduledTask(assignedTask=AssignedTask(
         instanceId=id,
         slaveHost=host,
         task=TaskConfig(production=prod if prod is not None else True,
                         job=JobKey(role=self._role,
                                    environment=self._env,
                                    name=name or self._name))),
                          status=ScheduleStatus.RUNNING,
                          taskEvents=[
                              TaskEvent(status=ScheduleStatus.RUNNING,
                                        timestamp=(time.time() - duration) *
                                        1000)
                          ])
Exemplo n.º 12
0
    def mock_status_active_tasks(self, instance_ids):
        tasks = []
        for i in instance_ids:
            tasks.append(
                ScheduledTask(status=ScheduleStatus.RUNNING,
                              assignedTask=AssignedTask(task=TaskConfig(),
                                                        instanceId=i)))
        response = Response(responseCode=ResponseCode.OK,
                            messageDEPRECATED='test')
        response.result = Result()
        response.result.scheduleStatusResult = ScheduleStatusResult(
            tasks=tasks)

        self.mock_scheduler.getTasksWithoutConfigs(
            IgnoreArg()).AndReturn(response)
Exemplo n.º 13
0
 def expect_get_tasks(self, tasks, ignore_ids=None, response_code=None):
     response_code = ResponseCode.OK if response_code is None else response_code
     response = Response(responseCode=response_code,
                         messageDEPRECATED='test')
     scheduled = []
     for index, task in enumerate(tasks):
         if not ignore_ids or index not in ignore_ids:
             scheduled.append(
                 ScheduledTask(assignedTask=AssignedTask(task=task,
                                                         instanceId=index)))
     response.result = Result(scheduleStatusResult=ScheduleStatusResult(
         tasks=scheduled))
     query = TaskQuery(owner=Identity(role=self._job_key.role),
                       environment=self._job_key.environment,
                       jobName=self._job_key.name,
                       statuses=ACTIVE_STATES)
     self._scheduler.getTasksStatus(query).AndReturn(response)
Exemplo n.º 14
0
    def create_scheduled_tasks(cls):
        tasks = []
        for name in ['foo', 'bar', 'baz']:
            task = ScheduledTask(failureCount=0,
                                 assignedTask=AssignedTask(
                                     taskId=1287391823,
                                     slaveHost='slavehost',
                                     task=cls.create_task_config(name),
                                     instanceId=4237894,
                                     assignedPorts={}),
                                 status=ScheduleStatus.RUNNING,
                                 taskEvents=[
                                     TaskEvent(timestamp=28234726395,
                                               status=ScheduleStatus.RUNNING,
                                               message="Hi there")
                                 ])

            tasks.append(task)
        return tasks
 def create_task(self, status, id):
     return ScheduledTask(
         assignedTask=AssignedTask(instanceId=id, taskId=id),
         status=status,
         taskEvents=[TaskEvent(status=status, timestamp=10)])
Exemplo n.º 16
0
 def create_task(self, instance_id):
     return ScheduledTask(assignedTask=AssignedTask(instanceId=instance_id,
                                                    task=TaskConfig()))
Exemplo n.º 17
0
 def create_tasks(cls):
   return [ScheduledTask(assignedTask=AssignedTask(instanceId=index)) for index in cls.INSTANCES]
Exemplo n.º 18
0
 def create_task(self, instance_id, task_id, status=RUNNING):
   assigned_task = AssignedTask(taskId=task_id,
                                instanceId=instance_id,
                                task=TaskConfig())
   return ScheduledTask(assignedTask=assigned_task, status=status)