summaryrefslogtreecommitdiffstats
path: root/tools/perf
diff options
context:
space:
mode:
authordtu@chromium.org <dtu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-08-03 01:39:38 +0000
committerdtu@chromium.org <dtu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-08-03 01:39:38 +0000
commit7c97bc24bc91ee5ba25296a11e88ad2dd574829c (patch)
tree9461d3f6425ee053c246e11f20fb9d747b8b508e /tools/perf
parent6e16cf561ae01244dc961e1ca56e5870535887ba (diff)
downloadchromium_src-7c97bc24bc91ee5ba25296a11e88ad2dd574829c.zip
chromium_src-7c97bc24bc91ee5ba25296a11e88ad2dd574829c.tar.gz
chromium_src-7c97bc24bc91ee5ba25296a11e88ad2dd574829c.tar.bz2
[telemetry] Automatic hash file creation and upload to Cloud Storage.
BUG=223667 TEST=None. Review URL: https://chromiumcodereview.appspot.com/21684002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@215445 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'tools/perf')
-rw-r--r--tools/perf/PRESUBMIT.py6
-rw-r--r--tools/perf/page_sets/.gitignore12
-rw-r--r--tools/perf/page_sets/PRESUBMIT.py66
3 files changed, 83 insertions, 1 deletions
diff --git a/tools/perf/PRESUBMIT.py b/tools/perf/PRESUBMIT.py
index e2a028e..9bb8eb1 100644
--- a/tools/perf/PRESUBMIT.py
+++ b/tools/perf/PRESUBMIT.py
@@ -4,14 +4,16 @@
import os
import sys
+
PYLINT_BLACKLIST = []
PYLINT_DISABLED_WARNINGS = ['R0923', 'R0201', 'E1101']
+
def _CommonChecks(input_api, output_api):
results = []
old_sys_path = sys.path
try:
- sys.path = [os.path.join('..', 'telemetry')] + sys.path
+ sys.path = [os.path.join(os.pardir, 'telemetry')] + sys.path
results.extend(input_api.canned_checks.RunPylint(
input_api, output_api,
black_list=PYLINT_BLACKLIST,
@@ -20,11 +22,13 @@ def _CommonChecks(input_api, output_api):
sys.path = old_sys_path
return results
+
def CheckChangeOnUpload(input_api, output_api):
report = []
report.extend(_CommonChecks(input_api, output_api))
return report
+
def CheckChangeOnCommit(input_api, output_api):
report = []
report.extend(_CommonChecks(input_api, output_api))
diff --git a/tools/perf/page_sets/.gitignore b/tools/perf/page_sets/.gitignore
new file mode 100644
index 0000000..c48247e
--- /dev/null
+++ b/tools/perf/page_sets/.gitignore
@@ -0,0 +1,12 @@
+*.gif
+*.jpeg
+*.jpg
+*.m4a
+*.mp3
+*.mp4
+*.ogg
+*.ogv
+*.png
+*.wav
+*.webm
+*.wpr
diff --git a/tools/perf/page_sets/PRESUBMIT.py b/tools/perf/page_sets/PRESUBMIT.py
new file mode 100644
index 0000000..5fae0e8
--- /dev/null
+++ b/tools/perf/page_sets/PRESUBMIT.py
@@ -0,0 +1,66 @@
+# Copyright 2013 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+import os
+import re
+import sys
+
+
+DEFAULT_BUCKET = 'chromium-wpr'
+
+
+def _SyncFilesToCloud(input_api, output_api):
+ """Searches for .sha1 files and uploads them to Cloud Storage.
+
+ It validates all the hashes and skips upload if not necessary.
+ """
+ # Because this script will be called from a magic PRESUBMIT demon,
+ # avoid angering it; don't pollute its sys.path.
+ old_sys_path = sys.path
+ try:
+ sys.path = [os.path.join(os.pardir, os.pardir, 'telemetry')] + sys.path
+ from telemetry.page import cloud_storage
+ finally:
+ sys.path = old_sys_path
+
+ hashes_in_cloud_storage = cloud_storage.List(DEFAULT_BUCKET)
+
+ results = []
+ for hash_path in input_api.AbsoluteLocalPaths():
+ file_path, extension = os.path.splitext(hash_path)
+ if extension != '.sha1':
+ continue
+
+ with open(hash_path, 'rb') as f:
+ file_hash = f.read(1024).rstrip()
+ if file_hash in hashes_in_cloud_storage:
+ results.append(output_api.PresubmitNotifyResult(
+ 'File already in Cloud Storage, skipping upload: %s' % hash_path))
+ continue
+
+ if not re.match('^([A-Za-z0-9]{40})$', file_hash):
+ results.append(output_api.PresubmitError(
+ 'Hash file does not contain a valid SHA-1 hash: %s' % hash_path))
+ continue
+ if not os.path.exists(file_path):
+ results.append(output_api.PresubmitError(
+ 'Hash file exists, but file not found: %s' % hash_path))
+ continue
+ if cloud_storage.GetHash(file_path) != file_hash:
+ results.append(output_api.PresubmitError(
+ 'Hash file does not match file\'s actual hash: %s' % hash_path))
+ continue
+
+ try:
+ cloud_storage.Insert(DEFAULT_BUCKET, file_hash, file_path)
+ except cloud_storage.CloudStorageError:
+ results.append(output_api.PresubmitError(
+ 'Unable to upload to Cloud Storage: %s' % hash_path))
+
+ return results
+
+
+def CheckChangeOnCommit(input_api, output_api):
+ results = []
+ results += _SyncFilesToCloud(input_api, output_api)
+ return results