def __init__(self, dict): global all_test_run self.dict = dict self.missing = [] self.test_run = self._lookup("test_run") all_test_run[self.test_run] = 1 self.project = self._lookup("project") self.test_name = self._lookup("test_name") self.context = self._lookup("context", 'default') self.host = self._lookup("host", "unknown") self.location = self._lookup("location", "") self.test_runner = self._lookup("test_runner") self.status = self._lookup("status") self.log = self._lookup("log", "") self.start_time = self._lookup("start_time", '') self.end_time = self._lookup("end_time", '') self.has_okfile = 'tda__okfile' in dict # no space in test name if '\n' in self.test_name: self.test_name = self.test_name.replace('\n', '_') if ' ' in self.test_name: self.test_name = self.test_name.replace(' ', '_') if '\t' in self.test_name: self.test_name = self.test_name.replace('\t', '_') # avoid excess / or . at beginning (easy to do by mistake in some # runners) while self.test_name.startswith('/') or self.test_name.startswith('.'): self.test_name = self.test_name[1:] try: if self.start_time != '': self.start_time = common.parse_time(self.start_time) self.start_time = common.sql_time(self.start_time) except ValueError: print("") print("INVALID START TIME, line %d" % line_count) try: if self.end_time != '': self.end_time = common.parse_time(self.end_time) self.end_time = common.sql_time(self.end_time) except ValueError: print("") print("INVALID END TIME, line %d" % line_count) self.tda = {} self.tra = {} for x in dict: if x.startswith("tda_"): self.tda[x[4:]] = self._lookup(x) if x.startswith("tra_"): self.tra[x[4:]] = self._lookup(x) if len(self.missing) > 0: print("FIELDS MISSING %s %d" % (self.missing, line_count)) exit_status = 1
def check_chronic(test_run_type, test_run=None, project=None, context=None, host=None): today_time = common.looks_like_a_date(test_run) print "XXX %s XXX" % today_time if today_time is None: raise Exception("test_run does not appear to have a date in it") today_time = common.parse_time(today_time) where_str, where_dict = pdk_db.where_dict( [('test_run_type', test_run_type), ('project', project), ('context', context), ('host', host)], ) print where_str, where_dict sql = "SELECT project, context, host, test_name, xwhen FROM chronic %s" % where_str c = pdk_db.execute(sql, where_dict) for x in c: print x, today_time project, context, host, test_name, xwhen = x c1 = pdk_db.execute( "SELECT key_id, status FROM result_scalar WHERE test_run = :1 AND project = :2 AND context = :3 AND host = :4 AND test_name = :5 ", (test_run, project, context, host, test_name)) tmp = c1.fetchone() if tmp is None: # there is a test in chronic that is not in the test run # this is not an error - just ignore it continue key_id, status = tmp if status == 'P' or status == 'D': res = 'F' else: print " ", xwhen xwhen = common.parse_time(xwhen) if xwhen is None: res = 'C' else: if (today_time - xwhen).days > 10: res = 'C' else: res = 'N' if res == 'C': print "chronic", key_id pdk_db.execute( "UPDATE result_scalar SET chronic = '1' WHERE key_id = :1", (key_id, )) pdk_db.commit() elif res == 'F': print "fixed" pdk_db.execute( "DELETE FROM chronic WHERE test_run_type = :1 AND project = :2 AND context = :3 AND host = :4 AND test_name = :5 ", (test_run_type, project, context, host, test_name)) elif res == 'N': print "not chronic" else: assert 0, "this never happens" pdk_db.commit()
def __init__(self, dictt) : self.dict = dictt self.missing = [ ] self.hash = '' self.test_run = self._lookup("test_run") all_test_run[self.test_run] = 1 self.project = self._lookup("project") self.test_name = self._lookup("test_name") self.context = self._lookup("context",'default') self.custom = self._lookup("custom",'') self.host = self._lookup("host","unknown") self.location = self._lookup("location","") self.test_runner= self._lookup("test_runner") self.status = self._lookup("status") self.log = self._lookup("log","") self.start_time = self._lookup("start_time",'') self.end_time = self._lookup("end_time",'') self.has_okfile = 'tda__okfile' in self.dict # no space in test name if '\n' in self.test_name : self.test_name = self.test_name.replace('\n','_') if ' ' in self.test_name : self.test_name = self.test_name.replace(' ','_') if '\t' in self.test_name : self.test_name = self.test_name.replace('\t','_') # avoid excess / or . at beginning (easy to do by mistake in some runners) while self.test_name.startswith('/') or self.test_name.startswith('.') : self.test_name = self.test_name[1:] try : if self.start_time != '' : self.start_time = common.parse_time(self.start_time) self.start_time = common.sql_time(self.start_time) except ValueError : print("") print("INVALID START TIME, line",line_count) try : if self.end_time != '' : self.end_time = common.parse_time(self.end_time) self.end_time = common.sql_time(self.end_time) except ValueError : print("") print("INVALID END TIME, line",line_count) self.tda = { } self.tra = { } for x in self.dict: if x.startswith("tda_"): self.tda[x[4:]] = self._lookup(x) if x.startswith("tra_"): self.tra[x[4:]] = self._lookup(x) #print() #print('TDAs for %s are %s' %(self.test_name, str(self.tda))) #print('TRAs for %s are %s' %(self.test_name, str(self.tra))) #print() if len(self.missing) > 0 : print("FIELDS MISSING",self.missing,line_count) exit_status = 1
def check_chronic( test_run_type, test_run=None, project=None, context=None, custom=None, host=None): today_time = common.looks_like_a_date(test_run) print("XXX %s XXX" % today_time) if today_time is None: raise Exception("test_run does not appear to have a date in it") today_time = common.parse_time(today_time) where_str, where_dict = pdk_db.where_dict([ ('test_run_type', test_run_type), ('project', project), ('context', context), ('custom', custom), ('host', host) ], ) print("%s %s" % (where_str, where_dict)) sql = "SELECT project, context, custom, host, test_name, xwhen FROM chronic %s" % where_str c = pdk_db.execute(sql, where_dict) for x in c: print("%s %s" % (x, today_time)) project, context, custom, host, test_name, xwhen = x c1 = pdk_db.execute( "SELECT key_id, status FROM result_scalar WHERE test_run = :1 AND project = :2 AND context = :3 AND custom = :4 AND host = :5 AND test_name = :6 ", (test_run, project, context, custom, host, test_name)) tmp = c1.fetchone() if tmp is None: # there is a test in chronic that is not in the test run # this is not an error - just ignore it continue key_id, status = tmp if status == 'P' or status == 'D': res = 'F' else: print(" %s" % xwhen) xwhen = common.parse_time(xwhen) if xwhen is None: res = 'C' else: if (today_time - xwhen) . days > 10: res = 'C' else: res = 'N' if res == 'C': print("chronic %d" % key_id) pdk_db.execute( "UPDATE result_scalar SET chronic = '1' WHERE key_id = :1", (key_id, )) pdk_db.commit() elif res == 'F': print("fixed") pdk_db.execute( "DELETE FROM chronic WHERE test_run_type = :1 AND project = :2 AND context = :3 AND custom = :4 AND host = :5 AND test_name = :6 ", (test_run_type, project, context, custom, host, test_name)) elif res == 'N': print("not chronic") else: assert 0, "this never happens" pdk_db.commit()