示例#1
0
 def testRescheduleTask(self):
   self.assertTrue(command_task_store.LeaseTask('task_id1'))
   task = command_task_store._Key('task_id1').get()
   old_schedule_timestamp = task.schedule_timestamp
   self.assertFalse(task.leasable)
   command_task_store.RescheduleTask('task_id1', 1, 2)
   task = command_task_store._Key('task_id1').get()
   self.assertTrue(task.leasable)
   self.assertEqual(1, task.run_index)
   self.assertEqual(2, task.attempt_index)
   self.assertIsNotNone(task.schedule_timestamp)
   self.assertNotEqual(old_schedule_timestamp, task.schedule_timestamp)
示例#2
0
 def testLeaseTask(self):
   # lease works for the first time
   self.assertTrue(command_task_store.LeaseTask('task_id1'))
   # lease fails for the second time
   self.assertFalse(command_task_store.LeaseTask('task_id1'))
   task = command_task_store._Key('task_id1').get()
   self.assertFalse(task.leasable)
   self.assertIsNotNone(task.lease_timestamp)
示例#3
0
 def testCreateTask(self):
   task = command_task_store._Key('task_id1').get()
   self.assertIsNotNone(task)
   self.assertEqual('task_id1', task.task_id)
   self.assertEqual(
       ['run_target1', 'run_target2', 'run_target3', 'run_target4'],
       task.run_targets)
   self.assertTrue(task.leasable)
   self.assertEqual(0, task.lease_count)
   self.assertEqual(1, task.priority)
   self.assertIsNotNone(task.schedule_timestamp)
示例#4
0
 def testCreateTask_largeTextCommandLine(self):
   command_line = 'command_line ' + 'arg ' * 10000
   command_task_args = command_task_store.CommandTaskArgs(
       request_id='request_id3',
       command_id='command_id3',
       task_id='task_id3',
       command_line=command_line,
       run_count=1,
       run_index=0,
       attempt_index=0,
       shard_count=None,
       shard_index=None,
       cluster='cluster',
       run_target='run_target5',
       priority=1,
       request_type=None,
       plugin_data={'ants_invocation_id': 'i123', 'ants_work_unit_id': 'w123'})
   command_task_store.CreateTask(command_task_args)
   task = command_task_store._Key('task_id3').get()
   self.assertTrue(task.leasable)
   self.assertEqual('task_id3', task.task_id)
   self.assertEqual(command_line, task.command_line)
   self.assertIsNotNone(task.schedule_timestamp)
示例#5
0
 def testDeleteTasks(self):
   self.assertIsNotNone(command_task_store._Key('task_id1').get())
   self.assertIsNotNone(command_task_store._Key('task_id2').get())
   command_task_store.DeleteTasks(['task_id1', 'task_id2'])
   self.assertIsNone(command_task_store._Key('task_id1').get())
   self.assertIsNone(command_task_store._Key('task_id2').get())
示例#6
0
 def testDeleteTask(self):
   task = command_task_store._Key('task_id1').get()
   self.assertIsNotNone(task)
   command_task_store.DeleteTask('task_id1')
   task1 = command_task_store._Key('task_id1').get()
   self.assertIsNone(task1)