| OLD | NEW |
| 1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 DEPS = [ | 5 DEPS = [ |
| 6 'file', | 6 'file', |
| 7 'isolate', | 7 'isolate', |
| 8 'recipe_engine/path', | 8 'recipe_engine/path', |
| 9 'recipe_engine/properties', | 9 'recipe_engine/properties', |
| 10 'recipe_engine/python', | 10 'recipe_engine/python', |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 try: | 58 try: |
| 59 api.swarming.default_env['invalid'] = 'foo' | 59 api.swarming.default_env['invalid'] = 'foo' |
| 60 except TypeError: | 60 except TypeError: |
| 61 pass | 61 pass |
| 62 | 62 |
| 63 # Create a temp dir to put *.isolated files into. | 63 # Create a temp dir to put *.isolated files into. |
| 64 temp_dir = api.path.mkdtemp('hello_isolated_world') | 64 temp_dir = api.path.mkdtemp('hello_isolated_world') |
| 65 | 65 |
| 66 # Prepare a bunch of swarming tasks to run hello_world on multiple platforms. | 66 # Prepare a bunch of swarming tasks to run hello_world on multiple platforms. |
| 67 tasks = [] | 67 tasks = [] |
| 68 platform_priority_adjustment = {'win': '125', 'linux': 'max', 'mac': None} |
| 68 for platform in ('win', 'linux', 'mac'): | 69 for platform in ('win', 'linux', 'mac'): |
| 69 # Isolate example hello_world.isolate from swarming client repo. | 70 # Isolate example hello_world.isolate from swarming client repo. |
| 70 # TODO(vadimsh): Add a thin wrapper around isolate.py to 'isolate' module? | 71 # TODO(vadimsh): Add a thin wrapper around isolate.py to 'isolate' module? |
| 71 step_result = api.python( | 72 step_result = api.python( |
| 72 'archive for %s' % platform, | 73 'archive for %s' % platform, |
| 73 api.swarming_client.path.join('isolate.py'), | 74 api.swarming_client.path.join('isolate.py'), |
| 74 [ | 75 [ |
| 75 'archive', | 76 'archive', |
| 76 '--isolate', api.swarming_client.path.join( | 77 '--isolate', api.swarming_client.path.join( |
| 77 'example', 'payload', 'hello_world.isolate'), | 78 'example', 'payload', 'hello_world.isolate'), |
| 78 '--isolated', temp_dir.join('hello_world.isolated'), | 79 '--isolated', temp_dir.join('hello_world.isolated'), |
| 79 '--isolate-server', api.isolate.isolate_server, | 80 '--isolate-server', api.isolate.isolate_server, |
| 80 '--config-variable', 'OS', platform, | 81 '--config-variable', 'OS', platform, |
| 81 '--verbose', | 82 '--verbose', |
| 82 ], stdout=api.raw_io.output()) | 83 ], stdout=api.raw_io.output()) |
| 83 # TODO(vadimsh): Pass result from isolate.py though --output-json option. | 84 # TODO(vadimsh): Pass result from isolate.py though --output-json option. |
| 84 isolated_hash = step_result.stdout.split()[0].strip() | 85 isolated_hash = step_result.stdout.split()[0].strip() |
| 85 | 86 |
| 86 # Create a task to run the isolated file on swarming, set OS dimension. | 87 # Create a task to run the isolated file on swarming, set OS dimension. |
| 87 # Also generate code coverage for multi-shard case by triggering multiple | 88 # Also generate code coverage for multi-shard case by triggering multiple |
| 88 # shards on Linux. | 89 # shards on Linux. |
| 89 task = api.swarming.task('hello_world', isolated_hash, | 90 task = api.swarming.task('hello_world', isolated_hash, |
| 90 task_output_dir=temp_dir.join('task_output_dir')) | 91 task_output_dir=temp_dir.join('task_output_dir')) |
| 91 task.dimensions['os'] = api.swarming.prefered_os_dimension(platform) | 92 task.dimensions['os'] = api.swarming.prefered_os_dimension(platform) |
| 92 task.shards = 2 if platform == 'linux' else 1 | 93 task.shards = 2 if platform == 'linux' else 1 |
| 93 task.tags.add('os:' + platform) | 94 task.tags.add('os:' + platform) |
| 95 task.priority = api.swarming.parse_priority_adjustment( |
| 96 platform_priority_adjustment[platform]) or api.swarming.default_priority |
| 94 tasks.append(task) | 97 tasks.append(task) |
| 95 | 98 |
| 96 # Launch all tasks. | 99 # Launch all tasks. |
| 97 for task in tasks: | 100 for task in tasks: |
| 98 step_result = api.swarming.trigger_task(task) | 101 step_result = api.swarming.trigger_task(task) |
| 99 assert step_result.swarming_task in tasks | 102 assert step_result.swarming_task in tasks |
| 100 | 103 |
| 101 # Recipe can do something useful here locally while tasks are | 104 # Recipe can do something useful here locally while tasks are |
| 102 # running on swarming. | 105 # running on swarming. |
| 103 api.step('local step', ['echo', 'running something locally']) | 106 api.step('local step', ['echo', 'running something locally']) |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 stdout=api.raw_io.output('hash_for_linux hello_world.isolated')) + | 177 stdout=api.raw_io.output('hash_for_linux hello_world.isolated')) + |
| 175 api.step_data( | 178 api.step_data( |
| 176 'archive for mac', | 179 'archive for mac', |
| 177 stdout=api.raw_io.output('hash_for_mac hello_world.isolated')) + | 180 stdout=api.raw_io.output('hash_for_mac hello_world.isolated')) + |
| 178 api.properties( | 181 api.properties( |
| 179 rietveld="https://codereview.chromium.org", | 182 rietveld="https://codereview.chromium.org", |
| 180 issue="123", | 183 issue="123", |
| 181 patchset="1001", | 184 patchset="1001", |
| 182 simulated_version=(0, 5), | 185 simulated_version=(0, 5), |
| 183 show_isolated_out_in_collect_step=False)) | 186 show_isolated_out_in_collect_step=False)) |
| OLD | NEW |