def test_nonexistent_run_get_run_list(self): query = RunDBQuery(self.bad_runno) if __hostname__.find('plus'): query._cmd_ = [os.path.dirname(__file__) + '/rdbt', '2'] query.parse() self.assertFalse(query.get_valid_runs(1800))
def test_good_range_get_run_list(self): query = RunDBQuery(self.good_runrange) if __hostname__.find('plus'): query._cmd_ = [os.path.dirname(__file__) + '/rdbt', '1'] query.parse() self.assertTrue(query.get_valid_runs(1800))
def test_filename_parsing(self): query = RunDBQuery(self.good_runrange) if __hostname__.find('plus'): query._cmd_ = [os.path.dirname(__file__) + '/rdbt', '4'] query.parse() self.assertEqual(len(query.get_files(self.good_runno)), 70)
debug('No run range or list was provided. ' \ 'List of runs will be determined automagically!') # NOTE: We only process runs longer than time threshold (~30 min # default), many runs are likely to be skipped b/c of this # condition. Assign an arbitrary run range (1k is long enough to # cover a technical stop) such that we always find at least one # significant run. last_run = max(get_last_run(runlist),get_last_run(graveyardrunlist)) runs = [last_run + 1, last_run + 1000] ## trim list of runs by run duration from run database. from crontools.rundbquery import RunDBQuery debug('Run list before trimming: %s' % runs) # query the database and get validated list of runs query = RunDBQuery(runs) query.parse() runs = query.get_valid_runs(_cliopts.threshold) # NOTE: If there is a need to further filter the run list according to # other criteria, one can use something like this: # def _my_filter(run): # rinfo = query.get_run_info(run) # if test(rinfo): return True # return False # runs = filter(_my_filter, runs) debug('Run list after trimming: %s' % runs) ## acquire lock and run job from glob import glob from crontools.utils import add_runs, get_dir_tree, mkdir_p