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

Side by Side Diff: scripts/slave/archive_profiling_data.py

Issue 10826217: Script to archive profiling data collected from (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/build/
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 | scripts/slave/runtest.py » ('j') | scripts/slave/runtest.py » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #!/usr/bin/env python
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
5
6 """A tool to archive Chrome profiling data generated by perf buildbots.
7
8 Pushes generated profiling data to Google Storage.
9
10 For a list of command-line options, call this script with '--help'.
11 """
12
13
14 import optparse
15 import os
16 import re
17 import sys
18
19 from slave import slave_utils
20
21 FILENAME = 'task_profile.json'
22 GOOGLE_STORAGE_BUCKET = 'chromium-browser-profiling-data'
23
24
25 def CopyToGoogleStorage(src, dst):
26 """Copies a file to the given Google Storage destination url.
27
28 Args:
29 src: path to file to be copied
30 dst: Google Storage destination url (i.e., gs://...)
31 Returns:
32 whether the copy was successful
33 """
34 if not os.path.exists(src):
35 print 'No such file', src
36 return False
37 return slave_utils.GSUtilCopy(src, dst, None, 'public-read')
38
39
40 def Archive(run_id, build_dir):
41 """Archive the profiling data to Google Storage.
42
43 Args:
44 run_id: the unique identifier of this run
45 build_dir: the path to the build directory
46 Returns:
47 whether profiling data correctly uploaded or not
48 """
49 if not os.path.exists(build_dir):
50 print 'No build directory'
51 return True
52
53 # Profiling data is in /b/build/slave/SLAVE_NAME/build/src/chrome/test/data
54 profiling_data_dir = os.path.join(build_dir, 'src', 'chrome', 'test', 'data')
55 if not os.path.exists(profiling_data_dir):
56 print 'No profiling_data_dir: ', profiling_data_dir
57 return True
58
59 profiling_file = os.path.join(profiling_data_dir, 'task_profile.json')
60 if not os.path.exists(profiling_file):
61 print 'No profiling_file: ', profiling_file
62 return True
63
64 run_id = re.sub('\W+', '_', run_id)
65
66 view_url = 'http://%s.commondatastorage.googleapis.com/' \
67 'view_test_results.html?%s' % (GOOGLE_STORAGE_BUCKET, run_id)
68 print 'See %s for this run\'s test results' % view_url
69 run_url = 'gs://%s/runs/%s/' % (GOOGLE_STORAGE_BUCKET, run_id)
70 print 'Pushing results to %s...' % run_url
71
72 if not CopyToGoogleStorage(profiling_file, run_url + FILENAME):
73 return False
74 return True
75
76
77 def main():
78 option_parser = optparse.OptionParser()
79 option_parser.add_option('', '--run-id', default=None,
80 help='unique id for this run')
81 option_parser.add_option('', '--build-dir', default=None,
82 help=('path to the build directory'))
83 options = option_parser.parse_args()[0]
84 if (options.run_id is None or options.build_dir is None):
85 print 'All command options are required. Use --help.'
86 return 1
87
88 if Archive(options.run_id, options.build_dir):
89 return 0
90 return 2
91
92
93 if '__main__' == __name__:
94 sys.exit(main())
OLDNEW
« no previous file with comments | « no previous file | scripts/slave/runtest.py » ('j') | scripts/slave/runtest.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698