def GetWaitTimes(pool='buildpool', mpb=15, starttime=None, endtime=None, int_size=0, maxb=0): """Get wait times and statistics for buildpool. Input: pool - name of the pool (e.g. buildpool, or trybuildpool) mpb - minutes per block, length of wait time block in minutes starttime - start time (UNIX timestamp in seconds), if not specified, endtime minus 24 hours endtime - end time (UNIX timestamp in seconds), if not specified, starttime plus 24 hours or current time (if starttime is not specified either) int_size - break down results per interval (in seconds), if specified maxb - maximum block size; for wait times larger than maxb, group into the largest block Output: wait times report """ starttime, endtime = get_time_interval(starttime, endtime) q = WaitTimesQuery(starttime, endtime, pool) q_results = q.execute() report = WaitTimesReport(pool, starttime, endtime, mpb=mpb, maxb=maxb, int_size=int_size, masters=get_masters_for_pool(pool)) for r in q_results: buildername = r['buildername'] # start time is changes.when_timestamp, or buildrequests.submitted_at # if build has no changes stime = r['when_timestamp'] or r['submitted_at'] etime = r['start_time'] platform = get_platform(buildername) has_no_changes = not bool(r['when_timestamp']) wt = WaitTime(stime, etime, platform, buildername=buildername, has_no_changes=has_no_changes) report.add(wt) return report
def __init__(self, pool, starttime, endtime, mpb=15, maxb=0, int_size=0, masters=None): IntervalsReport.__init__(self, starttime, endtime, int_size=int_size) self.pool = pool self.masters = masters or get_masters_for_pool(pool) self.mpb = mpb self.maxb = int(maxb / mpb) * mpb # normalize self.otherplatforms = set() self.unknownbuilders = set() self._init_report()
def __init__(self, pool, starttime, endtime, mpb=15, maxb=0, int_size=0, masters=None): IntervalsReport.__init__(self, starttime, endtime, int_size=int_size) self.pool = pool self.masters = masters or get_masters_for_pool(pool) self.mpb = mpb self.maxb = int(maxb / mpb) * mpb # normalize self.otherplatforms = set() self.unknownbuilders = set() self._init_report()
def GetWaitTimes(pool='buildpool', mpb=15, starttime=None, endtime=None, int_size=0, maxb=0): """Get wait times and statistics for buildpool. Input: pool - name of the pool (e.g. buildpool, or trybuildpool) mpb - minutes per block, length of wait time block in minutes starttime - start time (UNIX timestamp in seconds), if not specified, endtime minus 24 hours endtime - end time (UNIX timestamp in seconds), if not specified, starttime plus 24 hours or current time (if starttime is not specified either) int_size - break down results per interval (in seconds), if specified maxb - maximum block size; for wait times larger than maxb, group into the largest block Output: wait times report """ starttime, endtime = get_time_interval(starttime, endtime) q = WaitTimesQuery(starttime, endtime, pool) q_results = q.execute() report = WaitTimesReport(pool, starttime, endtime, mpb=mpb, maxb=maxb, int_size = int_size, masters=get_masters_for_pool(pool)) for r in q_results: buildername = r['buildername'] # start time is changes.when_timestamp, or buildrequests.submitted_at # if build has no changes stime = r['when_timestamp'] or r['submitted_at'] etime = r['start_time'] platform = get_platform(buildername) has_no_changes = not bool(r['when_timestamp']) wt = WaitTime(stime, etime, platform, buildername=buildername, has_no_changes=has_no_changes) report.add(wt) return report
def WaitTimesQuery(starttime, endtime, pool): """Constructs the sqlalchemy query for fetching all wait times for a buildpool in the specified time interval. Input: pool - name of the pool (e.g. buildpool, or trybuildpool) starttime - start time, UNIX timestamp (in seconds) endtime - end time, UNIX timestamp (in seconds) pool - fetches the builds only for masters in pool Output: query """ b = meta.scheduler_db_meta.tables['builds'] br = meta.scheduler_db_meta.tables['buildrequests'] bs = meta.scheduler_db_meta.tables['buildsets'] s = meta.scheduler_db_meta.tables['sourcestamps'] sch = meta.scheduler_db_meta.tables['sourcestamp_changes'] c = meta.scheduler_db_meta.tables['changes'] q = outerjoin(br, b, b.c.brid == br.c.id) \ .join(bs, bs.c.id == br.c.buildsetid) \ .join(s, s.c.id == bs.c.sourcestampid) \ .outerjoin(sch, sch.c.sourcestampid == s.c.id) \ .outerjoin(c, c.c.changeid == sch.c.changeid) \ .select() \ .with_only_columns([ br.c.buildername, br.c.claimed_at, br.c.submitted_at, func.min(b.c.start_time).label("start_time"), func.min(c.c.when_timestamp).label("when_timestamp"), ]) q = q.where(bs.c.submitted_at >= starttime) q = q.where(bs.c.submitted_at < endtime) # filter by masters masters = get_masters_for_pool(pool) mnames_matcher = [ br.c.claimed_by_name.startswith(master) for master in masters ] if mnames_matcher: pending_matcher_clause = get_pending_buildrequests_query_clause( br, pool) q = q.where(or_(pending_matcher_clause, *mnames_matcher)) # exclude all rebuilds and forced builds rmatcher = [not_(bs.c.reason.like(rpat)) \ for rpat in WAITTIMES_BUILDSET_REASON_SQL_EXCLUDE] if rmatcher: q = q.where(and_(*rmatcher)) # exclude pushes which are DONTBUILD q = q.where(not_(c.c.comments.like("%DONTBUILD%"))) # exclude unrelated buildrequests.buildername-s bmatcher = [not_(br.c.buildername.like(rpat)) \ for rpat in WAITTIMES_BUILDREQUESTS_BUILDERNAME_SQL_EXCLUDE] if bmatcher: q = q.where(and_(*bmatcher)) # get one change per sourcestamp and platform # (ingnore multiple changes in one push) q = q.group_by(br.c.id) return q
def WaitTimesQuery(starttime, endtime, pool): """Constructs the sqlalchemy query for fetching all wait times for a buildpool in the specified time interval. Input: pool - name of the pool (e.g. buildpool, or trybuildpool) starttime - start time, UNIX timestamp (in seconds) endtime - end time, UNIX timestamp (in seconds) pool - fetches the builds only for masters in pool Output: query """ b = meta.scheduler_db_meta.tables['builds'] br = meta.scheduler_db_meta.tables['buildrequests'] bs = meta.scheduler_db_meta.tables['buildsets'] s = meta.scheduler_db_meta.tables['sourcestamps'] sch = meta.scheduler_db_meta.tables['sourcestamp_changes'] c = meta.scheduler_db_meta.tables['changes'] q = outerjoin(br, b, b.c.brid == br.c.id) \ .join(bs, bs.c.id == br.c.buildsetid) \ .join(s, s.c.id == bs.c.sourcestampid) \ .outerjoin(sch, sch.c.sourcestampid == s.c.id) \ .outerjoin(c, c.c.changeid == sch.c.changeid) \ .select() \ .with_only_columns([ br.c.buildername, br.c.claimed_at, br.c.submitted_at, func.min(b.c.start_time).label("start_time"), func.min(c.c.when_timestamp).label("when_timestamp"), ]) q = q.where(bs.c.submitted_at >= starttime) q = q.where(bs.c.submitted_at < endtime) # filter by masters masters = get_masters_for_pool(pool) mnames_matcher = [br.c.claimed_by_name.startswith(master) for master in masters] if mnames_matcher: pending_matcher_clause = get_pending_buildrequests_query_clause(br, pool) q = q.where(or_(pending_matcher_clause, *mnames_matcher)) # exclude all rebuilds and forced builds rmatcher = [not_(bs.c.reason.like(rpat)) \ for rpat in WAITTIMES_BUILDSET_REASON_SQL_EXCLUDE] if rmatcher: q = q.where(and_(*rmatcher)) # exclude pushes which are DONTBUILD q = q.where(not_(c.c.comments.like("%DONTBUILD%"))) # exclude unrelated buildrequests.buildername-s bmatcher = [not_(br.c.buildername.like(rpat)) \ for rpat in WAITTIMES_BUILDREQUESTS_BUILDERNAME_SQL_EXCLUDE] if bmatcher: q = q.where(and_(*bmatcher)) # get one change per sourcestamp and platform # (ingnore multiple changes in one push) q = q.group_by(br.c.id) return q