Пример #1
0
 def testSpawnThreads(self):
     self.jobmanager.loadJob(Job(1, "*/2 * * * *", "echo haha", 5))
     self.jobmanager.indexJobs()
     
     self.assertEqual(1, len(self.jobmanager.hour_index[15]))
     
     threads = self.jobmanager.spwanTasks(DateUtil.datetime("2014-02-18 15:30:00"), DateUtil.datetime("2014-02-18 16:00:00"))
     self.assertEqual(15, len(threads))
     
     threads = self.jobmanager.spwanTasks(DateUtil.datetime("2014-02-18 15:30:23"), DateUtil.datetime("2014-02-18 16:00:00"))
     self.assertEqual(14, len(threads))
Пример #2
0
 def testSpawnThreads2(self):
     self.jobmanager.loadJob(Job(1, "* * * * *", "echo haha", 5))
     self.jobmanager.indexJobs()
     
     threads = self.jobmanager.spwanTasks(DateUtil.datetime("2014-02-19 15:00:00"), DateUtil.datetime("2014-02-19 16:00:00"))
     self.assertEqual(60, len(threads))
     print threads[0].args[0].get_exc_time()
Пример #3
0
 def testNextScheduleSectionOverLongBatch(self):
     '''
     Test get next schedule Section
      
     Test invalid over long interval
     '''
     self.engine._fillclock(11, 4)  # Get clock list [3, 7, 11, 15, 19, 23]
     try:
         self.engine._getNextScheduleSection(DateUtil.datetime('2014-02-14 15:06:34'), 23)
     except Exception:
         raise
Пример #4
0
 def testMatchTimePattern(self):
     self.assertEqual(True, TimeMatcher.matchTimePattern(TimePattern("* * * * *"), 
                                                         DateUtil.datetime("2014-02-17 20:28:35")))
     self.assertEqual(True, TimeMatcher.matchTimePattern(TimePattern("28 * * * *"), 
                                                         DateUtil.datetime("2014-02-17 20:28:35")))
     self.assertEqual(True, TimeMatcher.matchTimePattern(TimePattern("* 20 * * *"), 
                                                         DateUtil.datetime("2014-02-17 20:28:35")))
     self.assertEqual(True, TimeMatcher.matchTimePattern(TimePattern("* * 17 * *"), 
                                                         DateUtil.datetime("2014-02-17 20:28:35")))
     self.assertEqual(True, TimeMatcher.matchTimePattern(TimePattern("* * * 2 *"), 
                                                         DateUtil.datetime("2014-02-17 20:28:35")))
     self.assertEqual(True, TimeMatcher.matchTimePattern(TimePattern("* * * * 1"), 
                                                         DateUtil.datetime("2014-02-17 20:28:35")))
     self.assertEqual(True, TimeMatcher.matchTimePattern(TimePattern("28 20 17 2 1"), 
                                                         DateUtil.datetime("2014-02-17 20:28:35")))
     self.assertEqual(True, TimeMatcher.matchTimePattern(TimePattern("*/2 * * * *"), 
                                                         DateUtil.datetime("2014-02-17 20:28:35")))
     
     self.assertEqual(False, TimeMatcher.matchTimePattern(TimePattern("*/3 * * * *"), 
                                                         DateUtil.datetime("2014-02-17 20:28:35")))