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

Side by Side Diff: tools/get_archive.py

Issue 10828077: Rerun each CL 10 times to smooth out noise in perf testing. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | tools/get_drt.py » ('j') | tools/testing/perf_testing/run_perf_tests.py » ('J')
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 # 2 #
3 # Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 3 # Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
4 # for details. All rights reserved. Use of this source code is governed by a 4 # for details. All rights reserved. Use of this source code is governed by a
5 # BSD-style license that can be found in the LICENSE file. 5 # BSD-style license that can be found in the LICENSE file.
6 6
7 # Gets or updates a DumpRenderTree (a nearly headless build of chrome). This is 7 # Gets or updates a DumpRenderTree (a nearly headless build of chrome). This is
8 # used for running browser tests of client applications. 8 # used for running browser tests of client applications.
9 9
10 import json
10 import optparse 11 import optparse
11 import os 12 import os
12 import platform 13 import platform
13 import shutil 14 import shutil
14 import subprocess 15 import subprocess
15 import sys 16 import sys
16 import tempfile 17 import tempfile
17 import zipfile 18 import zipfile
18 19
20 import utils
21
19 def NormJoin(path1, path2): 22 def NormJoin(path1, path2):
20 return os.path.normpath(os.path.join(path1, path2)) 23 return os.path.normpath(os.path.join(path1, path2))
21 24
22 # Change into the dart directory as we want the project to be rooted here. 25 # Change into the dart directory as we want the project to be rooted here.
23 dart_src = NormJoin(os.path.dirname(sys.argv[0]), os.pardir) 26 dart_src = NormJoin(os.path.dirname(sys.argv[0]), os.pardir)
24 os.chdir(dart_src) 27 os.chdir(dart_src)
25 28
26 GSUTIL_DIR = os.path.join('third_party', 'gsutil') 29 GSUTIL_DIR = os.path.join('third_party', 'gsutil')
27 GSUTIL = GSUTIL_DIR + '/gsutil' 30 GSUTIL = GSUTIL_DIR + '/gsutil'
28 31
29 DRT_DIR = os.path.join('client', 'tests', 'drt') 32 DRT_DIR = os.path.join('client', 'tests', 'drt')
30 DRT_VERSION = os.path.join(DRT_DIR, 'LAST_VERSION') 33 DRT_VERSION = os.path.join(DRT_DIR, 'LAST_VERSION')
31 DRT_LATEST_PATTERN = ( 34 DRT_LATEST_PATTERN = (
32 'gs://dartium-archive/latest/drt-%(osname)s-inc-*.zip') 35 'gs://dartium-archive/latest/drt-%(osname)s-inc-*.zip')
33 DRT_PERMANENT_PREFIX = 'gs://dartium-archive/drt-%(osname)s-inc' 36 DRT_PERMANENT_PREFIX = 'gs://dartium-archive/drt-%(osname)s-inc'
34 37
35 DARTIUM_DIR = os.path.join('client', 'tests', 'dartium') 38 DARTIUM_DIR = os.path.join('client', 'tests', 'dartium')
36 DARTIUM_VERSION = os.path.join(DARTIUM_DIR, 'LAST_VERSION') 39 DARTIUM_VERSION = os.path.join(DARTIUM_DIR, 'LAST_VERSION')
37 DARTIUM_LATEST_PATTERN = ( 40 DARTIUM_LATEST_PATTERN = (
38 'gs://dartium-archive/latest/dartium-%(osname)s-inc-*.zip') 41 'gs://dartium-archive/latest/dartium-%(osname)s-inc-*.zip')
39 DARTIUM_PERMANENT_PREFIX = 'gs://dartium-archive/dartium-%(osname)s-inc' 42 DARTIUM_PERMANENT_PREFIX = 'gs://dartium-archive/dartium-%(osname)s-inc'
40 43
41 CHROMEDRIVER_DIR = os.path.join('tools', 'testing', 'dartium-chromedriver') 44 CHROMEDRIVER_DIR = os.path.join('tools', 'testing', 'dartium-chromedriver')
42 CHROMEDRIVER_VERSION = os.path.join(CHROMEDRIVER_DIR, 'LAST_VERSION') 45 CHROMEDRIVER_VERSION = os.path.join(CHROMEDRIVER_DIR, 'LAST_VERSION')
43 CHROMEDRIVER_LATEST_PATTERN = ( 46 CHROMEDRIVER_LATEST_PATTERN = (
44 'gs://dartium-archive/latest/chromedriver-%(osname)s-inc-*.zip') 47 'gs://dartium-archive/latest/chromedriver-%(osname)s-inc-*.zip')
45 CHROMEDRIVER_PERMANENT_PREFIX = ( 48 CHROMEDRIVER_PERMANENT_PREFIX = (
46 'gs://dartium-archive/chromedriver-%(osname)s-inc') 49 'gs://dartium-archive/chromedriver-%(osname)s-inc')
47 50
51 SDK_DIR = os.path.join(utils.GetBuildRoot(utils.GuessOS(), 'release', 'ia32'),
52 'dart-sdk')
53 SDK_VERSION = os.path.join(SDK_DIR, 'LAST_VERSION')
54 SDK_LATEST_PATTERN = 'gs://dart-editor-archive-continuous/latest/VERSION'
55 # TODO(efortuna): Once the x64 VM also is optimized, select the version
56 # based on whether we are running on a 32-bit or 64-bit system.
57 SDK_PERMANENT = ('gs://dart-editor-archive-continuous/%(version_num)s/' +
58 'dartsdk-%(osname)s-32.zip')
59
48 sys.path.append(os.path.join(GSUTIL_DIR, 'boto')) 60 sys.path.append(os.path.join(GSUTIL_DIR, 'boto'))
49 import boto 61 import boto
50 62
51 63
52 def execute_command(*cmd): 64 def execute_command(*cmd):
53 """Execute a command in a subprocess.""" 65 """Execute a command in a subprocess."""
54 pipe = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) 66 pipe = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
55 output, error = pipe.communicate() 67 output, error = pipe.communicate()
56 return pipe.returncode, output 68 return pipe.returncode, output
57 69
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 * You need to do a one-time configuration step to access Google Storage. 111 * You need to do a one-time configuration step to access Google Storage.
100 * Please run this command and follow the instructions: 112 * Please run this command and follow the instructions:
101 * %s config 113 * %s config
102 * 114 *
103 * NOTE: When prompted you can leave "project-id" blank. Just hit enter. 115 * NOTE: When prompted you can leave "project-id" blank. Just hit enter.
104 ******************************************************************************* 116 *******************************************************************************
105 ''' % GSUTIL 117 ''' % GSUTIL
106 sys.exit(1) 118 sys.exit(1)
107 119
108 120
109 def get_latest(name, directory, version_file, latest_pattern, permanent_prefix): 121 def get_dartium_latest(name, directory, version_file, latest_pattern,
110 """Get the latest DumpRenderTree or Dartium binary depending on arguments. 122 permanent_prefix):
123 """Get the latest binary that is stored in the dartium archive.
111 124
112 Args: 125 Args:
126 name: the name of the desired download.
113 directory: target directory (recreated) to install binary 127 directory: target directory (recreated) to install binary
114 version_file: name of file with the current version stamp 128 version_file: name of file with the current version stamp
115 latest_pattern: the google store url pattern pointing to the latest binary 129 latest_pattern: the google store url pattern pointing to the latest binary
116 permanent_prefix: stable google store folder used to download versions 130 permanent_prefix: stable google store folder used to download versions
117 """ 131 """
132 osdict = {'Darwin':'mac', 'Linux':'lucid64', 'Windows':'win'}
133 def latest_func(out, osname):
134 output_lines = out.split()
135 latest = output_lines[-1]
136 latest = (permanent_prefix % { 'osname' : osname }
137 + latest[latest.rindex('/'):])
138 return latest
139
140 get_from_gsutil(name, directory, version_file, latest_pattern, osdict,
141 latest_func)
142
143 def get_sdk_revision(name, directory, version_file, latest_pattern,
144 permanent_prefix, revision_num):
145 """Get a revision of the SDK from the editor build archive.
146
147 Args:
148 name: the name of the desired download
149 directory: target directory (recreated) to install binary
150 version_file: name of file with the current version stamp
151 latest_pattern: the google store url pattern pointing to the latest binary
152 permanent_prefix: stable google store folder used to download versions
153 revision_num: the desired revision number, or None for the most recent
154 """
155 osdict = {'Darwin':'macos', 'Linux':'linux', 'Windows':'win32'}
156 def find_permanent_url(out, osname):
157 rev_num = revision_num
158 if not rev_num:
159 temp_file = tempfile.NamedTemporaryFile()
160 temp_file_url = 'file://' + temp_file.name
161 gsutil('cp', latest_pattern % {'osname' : osname }, temp_file_url)
162 temp_file.seek(0)
163 version_info = temp_file.read()
164 temp_file.close()
165 if version_info != '':
166 rev_num = json.loads(version_info)['revision']
167 else:
168 print 'Unable to get latest version information.'
169 return ''
170 latest = (permanent_prefix % { 'osname' : osname, 'version_num': rev_num})
171 return latest
172
173 get_from_gsutil(name, directory, version_file, latest_pattern, osdict,
174 find_permanent_url)
175
176 def get_from_gsutil(name, directory, version_file, latest_pattern,
177 os_name_dict, get_permanent_url):
178 """Download and unzip the desired file from Google Storage.
179 Args:
180 name: the name of the desired download
181 directory: target directory (recreated) to install binary
182 version_file: name of file with the current version stamp
183 latest_pattern: the google store url pattern pointing to the latest binary
184 os_name_dict: a dictionary of operating system names and their corresponding
185 strings on the google storage site.
186 get_permanent_url: a function that accepts a listing of available files
187 and the os name, and returns a permanent URL for downloading.
188 """
118 system = platform.system() 189 system = platform.system()
119 if system == 'Darwin': 190 try:
120 osname = 'mac' 191 osname = os_name_dict[system]
121 elif system == 'Linux': 192 except KeyError:
122 osname = 'lucid64'
123 elif system == 'Windows':
124 osname = 'win'
125 else:
126 print >>sys.stderr, ('WARNING: platform "%s" does not support' 193 print >>sys.stderr, ('WARNING: platform "%s" does not support'
127 '%s for tests') % (system, name) 194 '%s.') % (system, name)
128 return 0 195 return 0
129 196
130 ensure_config() 197 ensure_config()
131 198
132 # Query for the lastest version 199 # Query for the lastest version
133 pattern = latest_pattern % { 'osname' : osname } 200 pattern = latest_pattern % { 'osname' : osname }
134 result, out = gsutil('ls', pattern) 201 result, out = gsutil('ls', pattern)
135 if result == 0: 202 if result == 0:
136 latest = out.split()[-1]
137 # use permanent link instead, just in case the latest zip entry gets deleted 203 # use permanent link instead, just in case the latest zip entry gets deleted
138 # while we are downloading it. 204 # while we are downloading it.
139 latest = (permanent_prefix % { 'osname' : osname } 205 latest = get_permanent_url(out, osname)
140 + latest[latest.rindex('/'):])
141 else: # e.g. no access 206 else: # e.g. no access
142 print "Couldn't download %s: %s\n%s" % (name, pattern, out) 207 print "Couldn't download %s: %s\n%s" % (name, pattern, out)
143 if not os.path.exists(version_file): 208 if not os.path.exists(version_file):
144 print "Tests using %s will not work. Please try again later." % name 209 print "Using %s will not work. Please try again later." % name
145 return 0 210 return 0
146 211
147 # Check if we need to update the file 212 # Check if we need to update the file
148 if os.path.exists(version_file): 213 if os.path.exists(version_file):
149 v = open(version_file, 'r').read() 214 v = open(version_file, 'r').read()
150 if v == latest: 215 if v == latest:
151 if not in_runhooks(): 216 if not in_runhooks():
152 print name + ' is up to date.\nVersion: ' + latest 217 print name + ' is up to date.\nVersion: ' + latest
153 return 0 # up to date 218 return 0 # up to date
154 219
(...skipping 10 matching lines...) Expand all
165 gsutil_visible('cp', latest, temp_zip_url) 230 gsutil_visible('cp', latest, temp_zip_url)
166 231
167 if platform.system() != 'Windows': 232 if platform.system() != 'Windows':
168 # The Python zip utility does not preserve executable permissions, but 233 # The Python zip utility does not preserve executable permissions, but
169 # this does not seem to be a problem for Windows, which does not have a 234 # this does not seem to be a problem for Windows, which does not have a
170 # built in zip utility. :-/ 235 # built in zip utility. :-/
171 result, out = execute_command('unzip', temp_zip, '-d', temp_dir) 236 result, out = execute_command('unzip', temp_zip, '-d', temp_dir)
172 if result != 0: 237 if result != 0:
173 raise Exception('Execution of "unzip %s -d %s" failed: %s' % 238 raise Exception('Execution of "unzip %s -d %s" failed: %s' %
174 (temp_zip, temp_dir, str(out))) 239 (temp_zip, temp_dir, str(out)))
175 unzipped_dir = temp_dir + '/' + os.path.basename(latest)[:-4] #Remove .zip 240 unzipped_dir = temp_dir + '/' + os.path.basename(latest)[:-len('.zip')]
176 else: 241 else:
177 z = zipfile.ZipFile(temp_zip) 242 z = zipfile.ZipFile(temp_zip)
178 z.extractall(temp_dir) 243 z.extractall(temp_dir)
179 # -4 = remove .zip for dir name 244 unzipped_dir = os.path.join(temp_dir,
180 unzipped_dir = os.path.join(temp_dir, os.path.basename(latest)[:-4]) 245 os.path.basename(latest)[:-len('.zip')])
181 z.close() 246 z.close()
247 if directory == SDK_DIR:
248 unzipped_dir = os.path.join(temp_dir, 'dart-sdk')
182 shutil.move(unzipped_dir, directory) 249 shutil.move(unzipped_dir, directory)
183 finally: 250 finally:
184 shutil.rmtree(temp_dir) 251 shutil.rmtree(temp_dir)
185 252
186 # create the version stamp 253 # create the version stamp
187 v = open(version_file, 'w') 254 v = open(version_file, 'w')
188 v.write(latest) 255 v.write(latest)
189 v.close() 256 v.close()
190 257
191 print 'Successfully downloaded to %s' % directory 258 print 'Successfully downloaded to %s' % directory
192 return 0 259 return 0
193 260
194 261
195 def main(): 262 def main():
196 parser = optparse.OptionParser() 263 parser = optparse.OptionParser(usage='usage: %prog [options] download_name')
197 parser.add_option('--dartium', dest='dartium', 264 parser.add_option('-r', '--revision', dest='revision',
198 help='Get latest Dartium', action='store_true', 265 help='Desired revision number to retrieve for the SDK. If '
199 default=False) 266 'unspecified, retrieve the latest SDK build.',
200 parser.add_option('--chromedriver', dest='chromedriver', 267 action='store', default=None)
201 help='Get the latest built ChromeDriver', 268 args, positional = parser.parse_args()
202 action='store_true', default=False)
203 args, _ = parser.parse_args()
204 269
205 if args.dartium: 270 if args.revision and positional[0] != 'sdk':
206 get_latest('Dartium', DARTIUM_DIR, DARTIUM_VERSION, 271 print ('Error: You can only specify the revision number for the SDK target.'
207 DARTIUM_LATEST_PATTERN, DARTIUM_PERMANENT_PREFIX) 272 ' For all other targets we return the latest build.')
208 elif args.chromedriver: 273 sys.exit(1)
209 get_latest('chromedriver', CHROMEDRIVER_DIR, CHROMEDRIVER_VERSION, 274 if positional[0] == 'dartium':
210 CHROMEDRIVER_LATEST_PATTERN, CHROMEDRIVER_PERMANENT_PREFIX) 275 get_dartium_latest('Dartium', DARTIUM_DIR, DARTIUM_VERSION,
276 DARTIUM_LATEST_PATTERN, DARTIUM_PERMANENT_PREFIX)
277 elif positional[0] == 'chromedriver':
278 get_dartium_latest('chromedriver', CHROMEDRIVER_DIR, CHROMEDRIVER_VERSION,
279 CHROMEDRIVER_LATEST_PATTERN,
280 CHROMEDRIVER_PERMANENT_PREFIX)
281 elif positional[0] == 'sdk':
282 get_sdk_revision('sdk', SDK_DIR, SDK_VERSION, SDK_LATEST_PATTERN,
283 SDK_PERMANENT, args.revision)
284 elif positional[0] == 'drt':
285 get_dartium_latest('DumpRenderTree', DRT_DIR, DRT_VERSION,
286 DRT_LATEST_PATTERN, DRT_PERMANENT_PREFIX)
211 else: 287 else:
212 get_latest('DumpRenderTree', DRT_DIR, DRT_VERSION, 288 print ('Please specify the target you wish to download from Google Storage '
213 DRT_LATEST_PATTERN, DRT_PERMANENT_PREFIX) 289 '("drt", "dartium", "chromedriver", or "sdk")')
214 290
215 if __name__ == '__main__': 291 if __name__ == '__main__':
216 sys.exit(main()) 292 sys.exit(main())
OLDNEW
« no previous file with comments | « no previous file | tools/get_drt.py » ('j') | tools/testing/perf_testing/run_perf_tests.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698