Beispiel #1
0
 def test_task_lists(self):
     x = HippoTask(definition={'id':'foo'},redis_client=self.redis_client)
     x.queue()
     self.assertEqual(len(HippoTask.all_tasks(self.redis_client)),1)
     self.assertEqual(len(HippoTask.waiting_tasks(self.redis_client)),1)
     x.work()
     self.assertEqual(len(HippoTask.working_tasks(self.redis_client)),1)
     self.assertEqual(len(HippoTask.waiting_tasks(self.redis_client)),0)
     x.finish()
     self.assertEqual(len(HippoTask.working_tasks(self.redis_client)),0)
     x.delete()
     self.assertEqual(len(HippoTask.all_tasks(self.redis_client)),0)
Beispiel #2
0
 def test_retry(self):
     x = HippoTask(definition={'id':'foo'},redis_client=self.redis_client)
     x.queue()
     x.work()
     x.definition['task_retries'] = 1
     x.definition['mesos_state'] = 'TASK_FAILED'
     x.finish()
     x.retry()
     self.assertEqual(len(HippoTask.all_tasks(self.redis_client)),2)
     waiting_tasks = HippoTask.waiting_tasks(self.redis_client)
     self.assertEqual(len(waiting_tasks),1)
     w = waiting_tasks[0]
     self.assertEqual(w.definition['task_retries'],0)
     w.finish()
     w.definition['mesos_state'] = 'TASK_LOST'
     w.retry()
     self.assertEqual(len(HippoTask.waiting_tasks(self.redis_client)),2)
Beispiel #3
0
 def test_resourceOffers(self):
     driver = Mock()
     x = HippoTask(definition={'id':'foo'},redis_client=self.redis_client)
     x.queue()
     x.work()
     scheduler = HippoScheduler(self.redis_client)
     offer = Dict()
     cres = Dict()
     cres.name = 'cpus'
     cres.scalar.value = 1.0
     mres = Dict()
     mres.name = 'mem'
     mres.scalar.value = 1024
     offer.resources = [cres,mres]
     offer.id = 'foooffer'
     offer.agent_id.value = 'fooagent'
     offers = [offer]
     scheduler.resourceOffers(driver,offers)