コード例 #1
0
 def test_make_up(self):
     task = make_task()
     queue = make_queue()
     s = Schedule.create(task, queue, 1, 10, -10, True)
     self._scheduler.flag.set()
     wait_until(lambda: s.instances.count() == 10, 5)
     s = Schedule.create(task, queue, 60, 10, -10, False)
     self._scheduler.flag.set()
     wait_until(lambda: s.instances.count() == 1, 5)
コード例 #2
0
ファイル: job_test.py プロジェクト: xuanhan863/norc
 def test_job(self):
     schedule = Schedule.create(self.job, self.queue, 1)
     instance = Instance.objects.create(task=self.job, schedule=schedule)
     # instance.log = log.Log(os.devnull)
     self.thread = Thread(target=instance.start)
     self.thread.start()
     wait_until(lambda: self.queue.count() == 2, 2)
     self.assertEqual(set([i.item.node for i in self.queue.items.all()]),
                      set([self.nodes[0], self.nodes[1]]))
     for i in self.queue_items():
         self._start_instance(i)
     self.assertEqual(set([i.item.node for i in self.queue.items.all()]),
                      set([self.nodes[2], self.nodes[4]]))
     for i in self.queue_items():
         self._start_instance(i)
     self.assertEqual(set([i.item.node for i in self.queue.items.all()]),
                      set([self.nodes[3]]))
     for i in self.queue_items():
         self._start_instance(i)
     self.assertEqual(set([i.item.node for i in self.queue.items.all()]),
                      set([self.nodes[5]]))
     for i in self.queue_items():
         self._start_instance(i)
     self.thread.join(2)
     self.assertFalse(self.thread.isAlive())
コード例 #3
0
 def test_duplicate(self):
     task = make_task()
     queue = make_queue()
     s = Schedule.create(task, queue, 1, 2, start=2)
     self._scheduler.flag.set()
     wait_until(lambda: self.scheduler.schedules.count() == 1, 2)
     s = Schedule.objects.get(pk=s.pk)
     s.scheduler = None
     s.save()
     self._scheduler.flag.set()
     wait_until(lambda: s.instances.count() == 2, 5)
コード例 #4
0
 def test_schedule(self):
     task = make_task()
     queue = make_queue()
     s = Schedule.create(task, queue, 0, 5)
     self._scheduler.flag.set()
     wait_until(lambda: s.instances.count() == 5, 5)