aboutsummaryrefslogtreecommitdiffhomepage
path: root/infra/bots/recipes
diff options
context:
space:
mode:
authorGravatar Eric Boren <borenet@google.com>2016-09-27 11:30:48 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2016-09-27 15:54:27 +0000
commitcfdd64f41f957d7465658c42dfa39802dd6c702c (patch)
treeb32c5a31c6f9848af5b4da6983da034c6eb5d7b1 /infra/bots/recipes
parent600c6a716df4aa72af873471f4a6bd3a851ceca1 (diff)
Fix dm/nanobench uploads for Gerrit-based trybots
BUG=skia:5719 GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2710 Change-Id: I43f03b19a9d7223b67de7dc7c4efea8cb75dba05 Reviewed-on: https://skia-review.googlesource.com/2710 Reviewed-by: Eric Boren <borenet@google.com> Commit-Queue: Eric Boren <borenet@google.com>
Diffstat (limited to 'infra/bots/recipes')
-rw-r--r--infra/bots/recipes/upload_dm_results.expected/recipe_with_gerrit_patch.json125
-rw-r--r--infra/bots/recipes/upload_dm_results.py28
-rw-r--r--infra/bots/recipes/upload_nano_results.expected/recipe_with_gerrit_patch.json31
-rw-r--r--infra/bots/recipes/upload_nano_results.py28
4 files changed, 208 insertions, 4 deletions
diff --git a/infra/bots/recipes/upload_dm_results.expected/recipe_with_gerrit_patch.json b/infra/bots/recipes/upload_dm_results.expected/recipe_with_gerrit_patch.json
new file mode 100644
index 0000000000..29a618c7c1
--- /dev/null
+++ b/infra/bots/recipes/upload_dm_results.expected/recipe_with_gerrit_patch.json
@@ -0,0 +1,125 @@
+[
+ {
+ "cmd": [
+ "python",
+ "-u",
+ "\nimport shutil\nimport sys\nshutil.copy(sys.argv[1], sys.argv[2])\n",
+ "[CWD]/dm/dm.json",
+ "/path/to/tmp/json"
+ ],
+ "name": "validate dm.json",
+ "~followup_annotations": [
+ "@@@STEP_LOG_LINE@json.output (invalid)@null@@@",
+ "@@@STEP_LOG_END@json.output (invalid)@@@"
+ ]
+ },
+ {
+ "cmd": [
+ "python",
+ "-u",
+ "\nimport sys, os\npath = sys.argv[1]\nmode = int(sys.argv[2])\nif not os.path.isdir(path):\n if os.path.exists(path):\n print \"%s exists but is not a dir\" % path\n sys.exit(1)\n os.makedirs(path, mode)\n",
+ "[CWD]/tmp_upload",
+ "511"
+ ],
+ "name": "makedirs tmp dir",
+ "~followup_annotations": [
+ "@@@STEP_LOG_LINE@python.inline@@@@",
+ "@@@STEP_LOG_LINE@python.inline@import sys, os@@@",
+ "@@@STEP_LOG_LINE@python.inline@path = sys.argv[1]@@@",
+ "@@@STEP_LOG_LINE@python.inline@mode = int(sys.argv[2])@@@",
+ "@@@STEP_LOG_LINE@python.inline@if not os.path.isdir(path):@@@",
+ "@@@STEP_LOG_LINE@python.inline@ if os.path.exists(path):@@@",
+ "@@@STEP_LOG_LINE@python.inline@ print \"%s exists but is not a dir\" % path@@@",
+ "@@@STEP_LOG_LINE@python.inline@ sys.exit(1)@@@",
+ "@@@STEP_LOG_LINE@python.inline@ os.makedirs(path, mode)@@@",
+ "@@@STEP_LOG_END@python.inline@@@"
+ ]
+ },
+ {
+ "cmd": [
+ "python",
+ "-u",
+ "\nimport shutil\nimport sys\nshutil.copy(sys.argv[1], sys.argv[2])\n",
+ "[CWD]/dm/dm.json",
+ "[CWD]/tmp_upload"
+ ],
+ "name": "copy dm.json"
+ },
+ {
+ "cmd": [
+ "python",
+ "-u",
+ "\nimport shutil\nimport sys\nshutil.copy(sys.argv[1], sys.argv[2])\n",
+ "[CWD]/dm/verbose.log",
+ "[CWD]/tmp_upload"
+ ],
+ "name": "copy verbose.log"
+ },
+ {
+ "cmd": [
+ "python",
+ "-u",
+ "\nimport os\nimport sys\nos.remove(sys.argv[1])\n",
+ "[CWD]/dm/dm.json"
+ ],
+ "name": "rm old dm.json",
+ "~followup_annotations": [
+ "@@@STEP_LOG_LINE@python.inline@@@@",
+ "@@@STEP_LOG_LINE@python.inline@import os@@@",
+ "@@@STEP_LOG_LINE@python.inline@import sys@@@",
+ "@@@STEP_LOG_LINE@python.inline@os.remove(sys.argv[1])@@@",
+ "@@@STEP_LOG_END@python.inline@@@"
+ ]
+ },
+ {
+ "cmd": [
+ "python",
+ "-u",
+ "\nimport os\nimport sys\nos.remove(sys.argv[1])\n",
+ "[CWD]/dm/verbose.log"
+ ],
+ "name": "rm old verbose.log",
+ "~followup_annotations": [
+ "@@@STEP_LOG_LINE@python.inline@@@@",
+ "@@@STEP_LOG_LINE@python.inline@import os@@@",
+ "@@@STEP_LOG_LINE@python.inline@import sys@@@",
+ "@@@STEP_LOG_LINE@python.inline@os.remove(sys.argv[1])@@@",
+ "@@@STEP_LOG_END@python.inline@@@"
+ ]
+ },
+ {
+ "cmd": [
+ "python",
+ "-u",
+ "\nimport glob\nimport sys\nwith open(sys.argv[1], 'w') as f:\n f.write('\\n'.join(glob.glob(sys.argv[2])))\n",
+ "/path/to/tmp/",
+ "[CWD]/dm/*"
+ ],
+ "name": "find images"
+ },
+ {
+ "cmd": [
+ "gsutil",
+ "cp",
+ "[CWD]/dm/*",
+ "gs://skia-infra-gm/dm-images-v1"
+ ],
+ "name": "upload images"
+ },
+ {
+ "cmd": [
+ "gsutil",
+ "cp",
+ "-z",
+ "json,log",
+ "[CWD]/tmp_upload/*",
+ "gs://skia-infra-gm/trybot/dm-json-v1/2012/05/14/12/abc123/Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Debug-Trybot/1337018001/2100/2"
+ ],
+ "name": "upload JSON and logs"
+ },
+ {
+ "name": "$result",
+ "recipe_result": null,
+ "status_code": 0
+ }
+] \ No newline at end of file
diff --git a/infra/bots/recipes/upload_dm_results.py b/infra/bots/recipes/upload_dm_results.py
index 20d2c064c3..49dc2ac505 100644
--- a/infra/bots/recipes/upload_dm_results.py
+++ b/infra/bots/recipes/upload_dm_results.py
@@ -28,8 +28,17 @@ VERBOSE_LOG = 'verbose.log'
def RunSteps(api):
builder_name = api.properties['buildername']
revision = api.properties['revision']
- issue = str(api.properties.get('issue', ''))
- patchset = str(api.properties.get('patchset', ''))
+
+ patch_storage = api.properties.get('patch_storage', 'rietveld')
+ issue = None
+ patchset = None
+ if builder_name.endswith('-Trybot'):
+ if patch_storage == 'gerrit':
+ issue = str(api.properties['event.change.number'])
+ patchset = str(api.properties['event.patchSet.ref'].split('/')[-1])
+ else:
+ issue = str(api.properties['issue'])
+ patchset = str(api.properties['patchset'])
results_dir = api.path['cwd'].join('dm')
@@ -104,3 +113,18 @@ def GenTests(api):
issue='12345',
patchset='1002')
)
+
+ gerrit_kwargs = {
+ 'patch_storage': 'gerrit',
+ 'repository': 'skia',
+ 'event.patchSet.ref': 'refs/changes/00/2100/2',
+ 'event.change.number': '2100',
+ }
+ yield (
+ api.test('recipe_with_gerrit_patch') +
+ api.properties(
+ buildername=builder,
+ revision='abc123',
+ path_config='kitchen',
+ **gerrit_kwargs)
+ )
diff --git a/infra/bots/recipes/upload_nano_results.expected/recipe_with_gerrit_patch.json b/infra/bots/recipes/upload_nano_results.expected/recipe_with_gerrit_patch.json
new file mode 100644
index 0000000000..1ed5afec76
--- /dev/null
+++ b/infra/bots/recipes/upload_nano_results.expected/recipe_with_gerrit_patch.json
@@ -0,0 +1,31 @@
+[
+ {
+ "cmd": [
+ "python",
+ "-u",
+ "\nimport glob\nimport sys\nwith open(sys.argv[1], 'w') as f:\n f.write('\\n'.join(glob.glob(sys.argv[2])))\n",
+ "/path/to/tmp/",
+ "nanobench*.json"
+ ],
+ "cwd": "[CWD]/perfdata/Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Debug-Trybot/data",
+ "name": "find results"
+ },
+ {
+ "cmd": [
+ "gsutil",
+ "cp",
+ "-a",
+ "public-read",
+ "-z",
+ "json",
+ "[CWD]/perfdata/Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Debug-Trybot/data/nanobench_abc123.json",
+ "gs://skia-perf/trybot/nano-json-v1/2012/05/14/12/Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Debug-Trybot/2100/2/nanobench_abc123.json"
+ ],
+ "name": "upload"
+ },
+ {
+ "name": "$result",
+ "recipe_result": null,
+ "status_code": 0
+ }
+] \ No newline at end of file
diff --git a/infra/bots/recipes/upload_nano_results.py b/infra/bots/recipes/upload_nano_results.py
index 2abe388e85..1508f03080 100644
--- a/infra/bots/recipes/upload_nano_results.py
+++ b/infra/bots/recipes/upload_nano_results.py
@@ -18,8 +18,17 @@ DEPS = [
def RunSteps(api):
# Upload the nanobench resuls.
builder_name = api.properties['buildername']
- issue = str(api.properties.get('issue', ''))
- patchset = str(api.properties.get('patchset', ''))
+
+ patch_storage = api.properties.get('patch_storage', 'rietveld')
+ issue = None
+ patchset = None
+ if builder_name.endswith('-Trybot'):
+ if patch_storage == 'gerrit':
+ issue = str(api.properties['event.change.number'])
+ patchset = str(api.properties['event.patchSet.ref'].split('/')[-1])
+ else:
+ issue = str(api.properties['issue'])
+ patchset = str(api.properties['patchset'])
now = api.time.utcnow()
@@ -71,3 +80,18 @@ def GenTests(api):
issue='12345',
patchset='1002')
)
+
+ gerrit_kwargs = {
+ 'patch_storage': 'gerrit',
+ 'repository': 'skia',
+ 'event.patchSet.ref': 'refs/changes/00/2100/2',
+ 'event.change.number': '2100',
+ }
+ yield (
+ api.test('recipe_with_gerrit_patch') +
+ api.properties(
+ buildername=builder,
+ revision='abc123',
+ path_config='kitchen',
+ **gerrit_kwargs)
+ )