Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 # Copyright 2015 The Chromium Authors. All rights reserved. | |
| 2 # Use of this source code is governed by a BSD-style license that can be | |
| 3 # found in the LICENSE file. | |
| 4 | |
| 5 import os | |
|
M-A Ruel
2015/11/06 18:56:06
You are not supposed to import anything in recipes
rmistry
2015/11/09 16:23:50
Done.
| |
| 6 import shutil | |
| 7 import tempfile | |
| 8 import time | |
| 9 | |
| 10 | |
| 11 DEPS = [ | |
| 12 'archive', | |
| 13 'bot_update', | |
| 14 'chromium', | |
| 15 'file', | |
| 16 'gclient', | |
| 17 'gsutil', | |
| 18 'isolate', | |
| 19 'path', | |
| 20 'platform', | |
| 21 'properties', | |
| 22 'python', | |
| 23 'step', | |
| 24 'swarming', | |
| 25 'swarming_client', | |
| 26 'zip', | |
| 27 ] | |
| 28 | |
| 29 | |
| 30 CT_BUCKET = 'cluster-telemetry' | |
| 31 CT_PAGE_TYPE = '1k' | |
| 32 CT_BINARY = 'run_chromium_perf_swarming' | |
| 33 CT_ISOLATE_TEMPLATE = 'ct_top1k.isolate.tmpl' | |
| 34 | |
| 35 # Number of slaves to shard CT runs to. | |
|
M-A Ruel
2015/11/06 18:56:06
s/slaves/bots/
rmistry
2015/11/09 16:23:49
I used "slaves" here to be consistent with CT's no
M-A Ruel
2015/11/09 16:51:21
There's two points of view:
- the word slave was m
rmistry
2015/11/09 19:37:24
The word slave was used in CT independently of bui
| |
| 36 # TODO(rmistry): Change the below to 100 when ready to run the full top 1k. | |
| 37 CT_NUM_SLAVES = 2 | |
| 38 | |
| 39 | |
| 40 def _DownloadAndExtractBinary(api): | |
| 41 """Downloads the binary from the revision passed to the recipe.""" | |
| 42 build_archive_url = api.properties['parent_build_archive_url'] | |
| 43 api.archive.download_and_unzip_build( | |
| 44 step_name='Download and Extract Binary', | |
| 45 target='Release', | |
| 46 build_url=None, # This is a required parameter, but has no effect. | |
| 47 build_archive_url=build_archive_url) | |
| 48 | |
| 49 | |
| 50 # TODO(rmistry): What priority can I give the below tasks?? | |
| 51 def RunSteps(api): | |
| 52 # Figure out which benchmark to use. | |
| 53 buildername = api.properties['buildername'] | |
| 54 if 'Repaint' in buildername: | |
| 55 benchmark = 'repaint' | |
| 56 elif 'RR' in buildername: | |
| 57 benchmark = 'rasterize_and_record_micro' | |
| 58 else: | |
| 59 raise Exception('Do not recognise the buildername %s.' % buildername) | |
| 60 | |
| 61 # Checkout chromium and swarming. | |
| 62 api.chromium.set_config('chromium') | |
| 63 api.gclient.set_config('chromium') | |
| 64 api.bot_update.ensure_checkout(force=True) | |
| 65 api.swarming_client.checkout() | |
| 66 | |
| 67 # Download the prebuilt chromium binary. | |
| 68 _DownloadAndExtractBinary(api) | |
| 69 | |
| 70 # Path to the chromium src directory. | |
| 71 chromium_src_dir = str(api.path['checkout']) | |
| 72 # Path to where artifacts should be downloaded from Google Storage. | |
| 73 downloads_dir = os.path.join(chromium_src_dir, 'content', 'test', 'ct') | |
|
M-A Ruel
2015/11/06 18:56:06
Why not put this in tmp too?
rmistry
2015/11/09 16:23:49
I initially went that route but it made the isolat
| |
| 74 # Path where swarming artifacts (isolate file, json output) will be stored. | |
| 75 swarming_temp_dir = str(api.path.mkdtemp('swarming-temp-dir')) | |
|
M-A Ruel
2015/11/06 18:56:06
Use self.m.path['tmp_base'] instead. That's what _
rmistry
2015/11/09 16:23:49
Done.
| |
| 76 | |
| 77 # Download Cluster Telemetry binary. | |
| 78 ct_binary_path = os.path.join(downloads_dir, CT_BINARY) | |
| 79 api.gsutil.download( | |
| 80 bucket=CT_BUCKET, | |
| 81 source=os.path.join('swarming', 'binaries', CT_BINARY), | |
| 82 dest=ct_binary_path) | |
| 83 | |
| 84 # Record how long the step took in swarming tasks. | |
| 85 swarming_start_time = time.time() | |
| 86 | |
| 87 for slave_num in range(1, CT_NUM_SLAVES + 1): | |
| 88 slave_dir = os.path.join(downloads_dir, 'slave%s' % slave_num) | |
| 89 os.makedirs(slave_dir) | |
| 90 | |
| 91 # Download page sets. | |
| 92 page_sets_dir = os.path.join(slave_dir, 'page_sets') | |
|
M-A Ruel
2015/11/06 18:56:06
I don't understand why you need to download files
rmistry
2015/11/09 16:23:49
The purpose of this recipe is to run benchmarks on
| |
| 93 os.makedirs(page_sets_dir) | |
| 94 api.gsutil.download( | |
| 95 bucket=CT_BUCKET, | |
| 96 source=os.path.join('swarming', 'page_sets', CT_PAGE_TYPE, | |
| 97 'slave%s' % slave_num, '*'), | |
| 98 dest=page_sets_dir) | |
| 99 | |
| 100 # Download archives. | |
| 101 wpr_dir = os.path.join(page_sets_dir, 'data') | |
| 102 os.makedirs(wpr_dir) | |
| 103 api.gsutil.download( | |
| 104 bucket=CT_BUCKET, | |
| 105 source=os.path.join('swarming', 'webpage_archives', CT_PAGE_TYPE, | |
| 106 'slave%s' % slave_num, '*'), | |
| 107 dest=wpr_dir) | |
| 108 | |
| 109 # TODO(rmistry): Remove the entire below section after crrev.com/1410353007 | |
| 110 # is submitted. | |
| 111 api.file.copy( | |
| 112 'copy %s' % CT_ISOLATE_TEMPLATE, | |
| 113 '/repos/chromium/src/chrome/%s' % CT_ISOLATE_TEMPLATE, | |
| 114 os.path.join(chromium_src_dir, 'chrome', CT_ISOLATE_TEMPLATE)) | |
| 115 for f in ['run_ct_top1k.py', 'path_util.py']: | |
| 116 api.file.copy( | |
| 117 'copy %s' % f, | |
| 118 '/repos/chromium/src/content/test/ct/%s' % f, | |
| 119 os.path.join(chromium_src_dir, 'content', 'test', 'ct', f)) | |
| 120 | |
| 121 # Create this slave's isolate file from the CT_ISOLATE_TEMPLATE. | |
| 122 isolate_dir = os.path.join(chromium_src_dir, 'chrome') | |
| 123 isolate_template_path = os.path.join(isolate_dir, CT_ISOLATE_TEMPLATE) | |
| 124 | |
| 125 generated_isolate_path = os.path.join(isolate_dir, 'ct_top1k.isolate') | |
| 126 with open(generated_isolate_path, 'wt') as fout: | |
| 127 with open(isolate_template_path, 'rt') as fin: | |
|
M-A Ruel
2015/11/06 18:56:06
use b instead of t, we don't want any CR character
rmistry
2015/11/09 16:23:49
Agreed. Done.
| |
| 128 for line in fin: | |
| 129 fout.write(line.replace('[[SLAVE_NUM]]', str(slave_num)) | |
| 130 .replace('[[MASTER]]', api.properties['mastername']) | |
| 131 .replace('[[BUILDER]]', api.properties['buildername']) | |
| 132 .replace('[[GIT_HASH]]', | |
| 133 api.properties['git_revision']) | |
| 134 .replace('[[BENCHMARK]]', benchmark)) | |
| 135 fout.close() | |
|
M-A Ruel
2015/11/06 18:56:06
When using with open() ..., you shouldn't close th
rmistry
2015/11/09 16:23:49
Done.
| |
| 136 | |
| 137 # Archive everything on the isolate server. | |
| 138 isolated_path = os.path.join( | |
| 139 swarming_temp_dir, 'ct-1k-task-%s.isolated' % slave_num) | |
| 140 isolate_args = [ | |
| 141 'archive', | |
| 142 '--isolate', generated_isolate_path, | |
| 143 '--isolated', isolated_path, | |
| 144 '--config-variable', 'OS', 'linux', | |
| 145 '--isolate-server', api.isolate.isolate_server, | |
| 146 # TODO(rmistry): Why do I need PRODUCT_DIR ? fails without it. It also | |
| 147 # requires bitmaptools in PRODUCT_DIR. | |
| 148 '--path-variable', 'PRODUCT_DIR', tempfile.gettempdir(), | |
|
M-A Ruel
2015/11/06 18:56:06
Can you add more details about what fails?
rmistry
2015/11/09 16:23:49
If I do not specify --path-variable then it fails
M-A Ruel
2015/11/09 16:51:21
Do you need this file at all? If not, we should fi
rmistry
2015/11/09 19:37:24
+nednyugen
Ned, is this file required? if yes then
| |
| 149 ] | |
| 150 api.python( | |
| 151 'archiving isolate for slave%s' % slave_num, | |
| 152 os.path.join(str(api.swarming_client.path), 'isolate.py'), | |
| 153 isolate_args) | |
| 154 | |
| 155 # Trigger swarming task. | |
| 156 task_name = 'ct-1k-task-%s' % slave_num | |
| 157 json_output = os.path.join( | |
| 158 swarming_temp_dir, 'ct-1k-task-%s.json' % slave_num) | |
| 159 swarming_trigger_args = [ | |
| 160 'trigger', | |
| 161 '--task-name', task_name, | |
| 162 isolated_path, | |
| 163 '--swarming', api.swarming.swarming_server, | |
| 164 '--dimension', 'os', 'Ubuntu', | |
| 165 '--dimension', 'gpu', '10de', | |
| 166 '--isolate-server', api.isolate.isolate_server, | |
| 167 '--dump-json', json_output | |
| 168 ] | |
| 169 api.python( | |
| 170 'triggering task for slave%s' % slave_num, | |
| 171 os.path.join(str(api.swarming_client.path), 'swarming.py'), | |
| 172 swarming_trigger_args) | |
| 173 | |
| 174 # We have triggered this slave's swarming task. Cleanup slave artifacts. | |
| 175 shutil.rmtree(slave_dir) | |
| 176 | |
| 177 # Now collect all tasks. | |
| 178 for slave_num in range(1, CT_NUM_SLAVES + 1): | |
| 179 json_output = os.path.join( | |
| 180 swarming_temp_dir, 'ct-1k-task-%s.json' % slave_num) | |
| 181 swarming_collect_args = [ | |
| 182 'collect', | |
| 183 '--swarming', api.swarming.swarming_server, | |
| 184 '--json', json_output | |
| 185 ] | |
| 186 api.python( | |
| 187 'collecting task for slave%s' % slave_num, | |
| 188 os.path.join(str(api.swarming_client.path), 'swarming.py'), | |
| 189 swarming_collect_args) | |
| 190 | |
| 191 # TODO(rmistry): Delete me! | |
|
M-A Ruel
2015/11/06 18:56:06
:)
rmistry
2015/11/09 16:23:49
Deleted.
| |
| 192 print 'my outputs!!!!' | |
| 193 print downloads_dir | |
| 194 print isolate_template_path | |
| 195 print generated_isolate_path | |
| 196 | |
| 197 | |
| 198 # Cleanup the temporary swarming dir. | |
| 199 shutil.rmtree(swarming_temp_dir) | |
|
M-A Ruel
2015/11/06 18:56:06
git gs "def rmtree"
gave me
recipe_modules/file/ap
rmistry
2015/11/09 16:23:49
Done.
| |
| 200 | |
| 201 print ('Running isolating, triggering and collecting swarming tasks took a ' | |
| 202 'total of %s seconds') % (time.time() - swarming_start_time) | |
| OLD | NEW |