Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(88)

Unified Diff: infra/tools/builder_alerts/buildbot.py

Issue 475943002: Add time and state to builder revision data (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « infra/tools/builder_alerts/__main__.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: infra/tools/builder_alerts/buildbot.py
diff --git a/infra/tools/builder_alerts/buildbot.py b/infra/tools/builder_alerts/buildbot.py
index 7f138b1ce7fa129d21f36eb27299da9a9091ca03..68b83afa4839df8e3cdec7d9990ad893e2f4914b 100644
--- a/infra/tools/builder_alerts/buildbot.py
+++ b/infra/tools/builder_alerts/buildbot.py
@@ -178,21 +178,38 @@ def revisions_from_build(build_json): # pragma: no cover
revisions[repo_name] = revision
return revisions
+def latest_update_time_for_builder(state, last_build):
ojan 2014/08/14 22:47:19 Look at alert_builder_tests.test_find_current_step
+ last_update = float(0)
+ if state == 'offline':
ojan 2014/08/14 22:47:19 We should get the same time whether the bot is off
+ last_update = float(last_build['times'][1])
+ else:
+ for step in last_build['steps']:
+ step_time = float(step['times'][0])
+ last_update = max(step_time, last_update)
+ return last_update
+
# "line too long" pylint: disable=C0301
-def latest_revisions_for_master(cache, master_url, master_json): # pragma: no cover
- latest_revisions = collections.defaultdict(dict)
+def latest_builder_info_for_master(cache, master_url, master_json): # pragma: no cover
ojan 2014/08/14 22:47:19 If you'd be willing to write tests for this while
+ latest_builder_info = collections.defaultdict(dict)
master_name = master_name_from_url(master_url)
for builder_name, builder_json in master_json['builders'].items():
# recent_builds can include current builds
recent_builds = set(builder_json['cachedBuilds'])
active_builds = set(builder_json['currentBuilds'])
+ state = builder_json['state']
last_finished_id = sorted(recent_builds - active_builds, reverse=True)[0]
+ #last update from here -- if offline last finish time,
+ # otherwise iterate across steps to find the start time of the running one
ojan 2014/08/14 22:47:19 Leftover comment?
last_build = fetch_build_json(cache,
master_url, builder_name, last_finished_id)
- latest_revisions[master_name][builder_name] = \
+ latest_builder_info[master_name][builder_name] = collections.defaultdict(dict)
ojan 2014/08/14 22:47:19 No need to defaultdict here. latest_builder_info[
+ latest_builder_info[master_name][builder_name]['revisions'] = \
ojan 2014/08/14 22:47:19 The old code had the wrong style. multi-lines shou
revisions_from_build(last_build)
- return latest_revisions
+ latest_builder_info[master_name][builder_name]['state'] = state
+ latest_builder_info[master_name][builder_name]['lastUpdateTime'] = \
+ latest_update_time_for_builder(state, last_build)
+ return latest_builder_info
def warm_build_cache(cache, master_url, builder_name,
« no previous file with comments | « infra/tools/builder_alerts/__main__.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698