Kevin Lubick | 556350d | 2018-10-12 15:21:17 -0400 | [diff] [blame] | 1 | # Copyright 2018 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 | # Recipe which runs the PathKit tests using docker |
| 6 | |
| 7 | DEPS = [ |
| 8 | 'checkout', |
| 9 | 'infra', |
| 10 | 'recipe_engine/file', |
| 11 | 'recipe_engine/path', |
| 12 | 'recipe_engine/properties', |
| 13 | 'recipe_engine/python', |
| 14 | 'recipe_engine/step', |
| 15 | 'run', |
| 16 | 'vars', |
| 17 | ] |
| 18 | |
| 19 | |
| 20 | DOCKER_IMAGE = 'gcr.io/skia-public/perf-karma-chrome-tests:68.0.3440.106_v1' |
| 21 | INNER_KARMA_SCRIPT = '/SRC/skia/infra/pathkit/perf_pathkit.sh' |
| 22 | |
| 23 | |
| 24 | def RunSteps(api): |
| 25 | api.vars.setup() |
| 26 | checkout_root = api.checkout.default_checkout_root |
| 27 | out_dir = api.vars.swarming_out_dir |
| 28 | api.checkout.bot_update(checkout_root=checkout_root) |
| 29 | |
| 30 | # Make sure this exists, otherwise Docker will make it with root permissions. |
| 31 | api.file.ensure_directory('mkdirs out_dir', out_dir, mode=0777) |
| 32 | |
| 33 | # The karma script is configured to look in ./npm-(asmjs|wasm)/bin/ for |
| 34 | # the test files to load, so we must copy them there (see Set up for docker). |
| 35 | copy_dest = checkout_root.join('skia', 'modules', 'pathkit', |
| 36 | 'npm-wasm', 'bin') |
| 37 | if 'asmjs' in api.vars.builder_name: |
| 38 | copy_dest = checkout_root.join('skia', 'modules', 'pathkit', |
| 39 | 'npm-asmjs', 'bin') |
| 40 | |
| 41 | base_dir = api.vars.build_dir |
| 42 | bundle_name = 'pathkit.wasm' |
| 43 | if 'asmjs' in api.vars.builder_name: |
| 44 | bundle_name = 'pathkit.js.mem' |
| 45 | |
| 46 | api.python.inline( |
| 47 | name='Set up for docker', |
| 48 | program='''import errno |
| 49 | import os |
| 50 | import shutil |
| 51 | import sys |
| 52 | |
| 53 | copy_dest = sys.argv[1] |
| 54 | base_dir = sys.argv[2] |
| 55 | bundle_name = sys.argv[3] |
| 56 | out_dir = sys.argv[4] |
| 57 | |
| 58 | # Clean out old binaries (if any) |
| 59 | try: |
| 60 | shutil.rmtree(copy_dest) |
| 61 | except OSError as e: |
| 62 | if e.errno != errno.ENOENT: |
| 63 | raise |
| 64 | |
| 65 | # Make folder |
| 66 | try: |
| 67 | os.makedirs(copy_dest) |
| 68 | except OSError as e: |
| 69 | if e.errno != errno.EEXIST: |
| 70 | raise |
| 71 | |
| 72 | # Copy binaries (pathkit.js and pathkit.wasm) to where the karma tests |
| 73 | # expect them ($SKIA_ROOT/modules/pathkit/npm-wasm/) |
| 74 | dest = os.path.join(copy_dest, 'pathkit.js') |
| 75 | shutil.copyfile(os.path.join(base_dir, 'pathkit.js'), dest) |
| 76 | os.chmod(dest, 0o644) # important, otherwise non-privileged docker can't read. |
| 77 | |
| 78 | if bundle_name: |
| 79 | dest = os.path.join(copy_dest, bundle_name) |
| 80 | shutil.copyfile(os.path.join(base_dir, bundle_name), dest) |
| 81 | os.chmod(dest, 0o644) # important, otherwise non-privileged docker can't read. |
| 82 | |
| 83 | # Prepare output folder, api.file.ensure_directory doesn't touch |
| 84 | # the permissions of the out directory if it already exists. |
| 85 | os.chmod(out_dir, 0o777) # important, otherwise non-privileged docker can't write. |
| 86 | ''', |
| 87 | args=[copy_dest, base_dir, bundle_name, out_dir], |
| 88 | infra_step=True) |
| 89 | |
| 90 | |
| 91 | |
| 92 | cmd = ['docker', 'run', '--shm-size=2gb', '--rm', |
| 93 | '-v', '%s:/SRC' % checkout_root, '-v', '%s:/OUT' % out_dir] |
| 94 | |
| 95 | if 'asmjs' in api.vars.builder_name: |
| 96 | cmd.extend(['-e', 'ASM_JS=1']) # -e sets environment variables |
| 97 | |
| 98 | cmd.extend([ |
| 99 | DOCKER_IMAGE, INNER_KARMA_SCRIPT, |
| 100 | '--builder', api.vars.builder_name, |
| 101 | '--git_hash', api.properties['revision'], |
| 102 | '--buildbucket_build_id', api.properties.get('buildbucket_build_id', |
| 103 | ''), |
| 104 | '--bot_id', api.vars.swarming_bot_id, |
| 105 | '--task_id', api.vars.swarming_task_id, |
| 106 | '--browser', 'Chrome', |
| 107 | '--config', api.vars.configuration, |
| 108 | ]) |
| 109 | |
| 110 | if 'asmjs' in api.vars.builder_name: |
| 111 | cmd.extend(['--compiled_language', 'asmjs']) # the default is wasm |
| 112 | |
| 113 | if api.vars.is_trybot: |
| 114 | cmd.extend([ |
| 115 | '--issue', api.vars.issue, |
| 116 | '--patchset', api.vars.patchset, |
| 117 | '--patch_storage', api.vars.patch_storage, |
| 118 | ]) |
| 119 | |
| 120 | api.run( |
| 121 | api.step, |
| 122 | 'Performance tests of PathKit with Docker', |
| 123 | cmd=cmd) |
| 124 | |
| 125 | |
| 126 | def GenTests(api): |
| 127 | yield ( |
| 128 | api.test('Perf-Debian9-EMCC-GCE-CPU-AVX2-wasm-Release-All-PathKit') + |
| 129 | api.properties(buildername=('Perf-Debian9-EMCC-GCE-CPU-AVX2' |
| 130 | '-wasm-Release-All-PathKit'), |
| 131 | repository='https://skia.googlesource.com/skia.git', |
| 132 | revision='abc123', |
| 133 | path_config='kitchen', |
| 134 | swarm_out_dir='[SWARM_OUT_DIR]') |
| 135 | ) |
| 136 | |
| 137 | yield ( |
| 138 | api.test('Perf-Debian9-EMCC-GCE-CPU-AVX2-asmjs-Release-All-PathKit') + |
| 139 | api.properties(buildername=('Perf-Debian9-EMCC-GCE-CPU-AVX2' |
| 140 | '-asmjs-Release-All-PathKit'), |
| 141 | repository='https://skia.googlesource.com/skia.git', |
| 142 | revision='abc123', |
| 143 | path_config='kitchen', |
| 144 | swarm_out_dir='[SWARM_OUT_DIR]') |
| 145 | ) |
| 146 | |
| 147 | yield ( |
| 148 | api.test('pathkit_trybot') + |
| 149 | api.properties(buildername=('Perf-Debian9-EMCC-GCE-CPU-AVX2' |
| 150 | '-wasm-Release-All-PathKit'), |
| 151 | repository='https://skia.googlesource.com/skia.git', |
| 152 | revision='abc123', |
| 153 | path_config='kitchen', |
| 154 | swarm_out_dir='[SWARM_OUT_DIR]', |
| 155 | patch_ref='89/456789/12', |
| 156 | patch_repo='https://skia.googlesource.com/skia.git', |
| 157 | patch_storage='gerrit', |
| 158 | patch_set=7, |
| 159 | patch_issue=1234, |
| 160 | gerrit_project='skia', |
| 161 | gerrit_url='https://skia-review.googlesource.com/') |
| 162 | ) |