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

Side by Side Diff: scripts/slave/recipe_modules/skia/resources/trigger_wait_ct_task.py

Issue 1373863002: Fixes to CT's trybot recipe (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/build@master
Patch Set: Initial upload Created 5 years, 2 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2015 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2015 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 """Python utility that triggers and waits for tasks to complete on CTFE.""" 6 """Python utility that triggers and waits for tasks to complete on CTFE."""
7 7
8 import base64 8 import base64
9 import hashlib 9 import hashlib
10 import json 10 import json
11 import optparse 11 import optparse
12 import requests 12 import requests
13 import sys 13 import sys
14 import time 14 import time
15 15
16 16
17 CTFE_HOST = "http://ct.skia.org" 17 CTFE_HOST = "https://ct.skia.org"
18 CTFE_QUEUE = CTFE_HOST + '/queue/' 18 CTFE_QUEUE = CTFE_HOST + '/queue/'
19 CHROMIUM_PERF_TASK_POST_URI = CTFE_HOST + "/_/webhook_add_chromium_perf_task" 19 CHROMIUM_PERF_TASK_POST_URI = CTFE_HOST + "/_/webhook_add_chromium_perf_task"
20 GET_CHROMIUM_PERF_RUN_STATUS_URI = CTFE_HOST + "/get_chromium_perf_run_status" 20 GET_CHROMIUM_PERF_RUN_STATUS_URI = CTFE_HOST + "/get_chromium_perf_run_status"
21 CHROMIUM_PERF_RUNS_HISTORY = CTFE_HOST + "/chromium_perf_runs/" 21 CHROMIUM_PERF_RUNS_HISTORY = CTFE_HOST + "/chromium_perf_runs/"
22 GCE_WEBHOOK_SALT_METADATA_URI = ( 22 GCE_WEBHOOK_SALT_METADATA_URI = (
23 "http://metadata/computeMetadata/v1/project/attributes/" 23 "http://metadata/computeMetadata/v1/project/attributes/"
24 "webhook_request_salt") 24 "webhook_request_salt")
25 25
26 26
27 POLLING_FREQUENCY_SECS = 60 # 1 minute. 27 POLLING_FREQUENCY_SECS = 60 # 1 minute.
(...skipping 28 matching lines...) Expand all
56 56
57 57
58 def _GetWebhookSaltFromMetadata(): 58 def _GetWebhookSaltFromMetadata():
59 """Gets webhook_request_salt from GCE's metadata server.""" 59 """Gets webhook_request_salt from GCE's metadata server."""
60 headers = {"Metadata-Flavor": "Google"} 60 headers = {"Metadata-Flavor": "Google"}
61 resp = requests.get(GCE_WEBHOOK_SALT_METADATA_URI, headers=headers) 61 resp = requests.get(GCE_WEBHOOK_SALT_METADATA_URI, headers=headers)
62 if resp.status_code != 200: 62 if resp.status_code != 200:
63 raise CtTrybotException( 63 raise CtTrybotException(
64 'Return code from %s was %s' % (GCE_WEBHOOK_SALT_METADATA_URI, 64 'Return code from %s was %s' % (GCE_WEBHOOK_SALT_METADATA_URI,
65 resp.status_code)) 65 resp.status_code))
66 return resp.text 66 return base64.standard_b64decode(resp.text)
67 67
68 68
69 def _TriggerTask(options): 69 def _TriggerTask(options):
70 """Triggers the requested task on CTFE and returns the new task's ID.""" 70 """Triggers the requested task on CTFE and returns the new task's ID."""
71 task = _CreateTaskJSON(options) 71 task = _CreateTaskJSON(options)
72 m = hashlib.sha512() 72 m = hashlib.sha512()
73 m.update(task) 73 m.update(task)
74 m.update('notverysecret' if options.local else _GetWebhookSaltFromMetadata()) 74 m.update('notverysecret' if options.local else _GetWebhookSaltFromMetadata())
75 encoded = base64.standard_b64encode(m.digest()) 75 encoded = base64.standard_b64encode(m.digest())
76 76
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 '', '--local', default=False, action='store_true', 164 '', '--local', default=False, action='store_true',
165 help='Uses a dummy metadata salt if this flag is true else it tries to ' 165 help='Uses a dummy metadata salt if this flag is true else it tries to '
166 'get the salt from GCE metadata.') 166 'get the salt from GCE metadata.')
167 options, unused_args = option_parser.parse_args() 167 options, unused_args = option_parser.parse_args()
168 if (not options.issue or not options.patchset or not options.requester 168 if (not options.issue or not options.patchset or not options.requester
169 or not options.benchmark): 169 or not options.benchmark):
170 option_parser.error('Must specify issue, patchset, requester and benchmark') 170 option_parser.error('Must specify issue, patchset, requester and benchmark')
171 171
172 sys.exit(TriggerAndWait(options)) 172 sys.exit(TriggerAndWait(options))
173 173
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698