| OLD | NEW |
| 1 # Copyright 2015 The Chromium Authors. All rights reserved. | 1 # Copyright 2015 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 | 5 |
| 6 from recipe_engine import recipe_api | 6 from recipe_engine import recipe_api |
| 7 | 7 |
| 8 | 8 |
| 9 CT_GS_BUCKET = 'cluster-telemetry' | 9 CT_GS_BUCKET = 'cluster-telemetry' |
| 10 | 10 |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 The artifacts are downloaded into subdirectories in the downloads_dir. | 62 The artifacts are downloaded into subdirectories in the downloads_dir. |
| 63 | 63 |
| 64 Args: | 64 Args: |
| 65 page_type: str. The CT page type. Eg: 1k, 10k. | 65 page_type: str. The CT page type. Eg: 1k, 10k. |
| 66 slave_num: int. The number of the slave used to determine which GS | 66 slave_num: int. The number of the slave used to determine which GS |
| 67 directory to download from. Eg: for the top 1k, slave1 will | 67 directory to download from. Eg: for the top 1k, slave1 will |
| 68 contain webpages 1-10, slave2 will contain 11-20. | 68 contain webpages 1-10, slave2 will contain 11-20. |
| 69 """ | 69 """ |
| 70 # Download page sets. | 70 # Download page sets. |
| 71 page_sets_dir = self.downloads_dir.join('slave%s' % slave_num, 'page_sets') | 71 page_sets_dir = self.downloads_dir.join('slave%s' % slave_num, 'page_sets') |
| 72 self.m.file.makedirs('Create page_sets dir', page_sets_dir) | 72 self.m.file.makedirs('page_sets dir', page_sets_dir) |
| 73 self.m.gsutil.download( | 73 self.m.gsutil.download( |
| 74 bucket=CT_GS_BUCKET, | 74 bucket=CT_GS_BUCKET, |
| 75 source='swarming/page_sets/%s/slave%s/*' % (page_type, slave_num), | 75 source='swarming/page_sets/%s/slave%s/*' % (page_type, slave_num), |
| 76 dest=page_sets_dir) | 76 dest=page_sets_dir) |
| 77 | 77 |
| 78 # Download archives. | 78 # Download archives. |
| 79 wpr_dir = page_sets_dir.join('data') | 79 wpr_dir = page_sets_dir.join('data') |
| 80 self.m.file.makedirs('Create WPR dir', wpr_dir) | 80 self.m.file.makedirs('WPR dir', wpr_dir) |
| 81 self.m.gsutil.download( | 81 self.m.gsutil.download( |
| 82 bucket=CT_GS_BUCKET, | 82 bucket=CT_GS_BUCKET, |
| 83 source='swarming/webpage_archives/%s/slave%s/*' % (page_type, | 83 source='swarming/webpage_archives/%s/slave%s/*' % (page_type, |
| 84 slave_num), | 84 slave_num), |
| 85 dest=wpr_dir) | 85 dest=wpr_dir) |
| 86 | 86 |
| 87 def download_skps(self, page_type, slave_num, skps_chromium_build): |
| 88 """Downloads SKPs corresponding to the specified page type, slave and build. |
| 89 |
| 90 The SKPs are downloaded into subdirectories in the downloads_dir. |
| 91 |
| 92 Args: |
| 93 page_type: str. The CT page type. Eg: 1k, 10k. |
| 94 slave_num: int. The number of the slave used to determine which GS |
| 95 directory to download from. Eg: for the top 1k, slave1 will |
| 96 contain SKPs from webpages 1-10, slave2 will contain 11-20. |
| 97 skps_chromium_build: str. The build the SKPs were captured from. |
| 98 """ |
| 99 skps_dir = self.downloads_dir.join('slave%s' % slave_num, 'skps') |
| 100 self.m.file.rmtree('SKPs dir', skps_dir) |
| 101 self.m.file.makedirs('SKPs dir', skps_dir) |
| 102 full_source = 'gs://%s/skps/%s/%s/slave%s/*' % ( |
| 103 CT_GS_BUCKET, page_type, skps_chromium_build, slave_num) |
| 104 self.m.gsutil(['-m', 'cp', full_source, skps_dir]) |
| 105 |
| 87 def create_isolated_gen_json(self, isolate_path, base_dir, os_type, | 106 def create_isolated_gen_json(self, isolate_path, base_dir, os_type, |
| 88 slave_num, extra_variables): | 107 slave_num, extra_variables): |
| 89 """Creates an isolated.gen.json file. | 108 """Creates an isolated.gen.json file. |
| 90 | 109 |
| 91 Args: | 110 Args: |
| 92 isolate_path: path obj. Path to the isolate file. | 111 isolate_path: path obj. Path to the isolate file. |
| 93 base_dir: path obj. Dir that is the base of all paths in the isolate file. | 112 base_dir: path obj. Dir that is the base of all paths in the isolate file. |
| 94 os_type: str. The OS type to use when archiving the isolate file. | 113 os_type: str. The OS type to use when archiving the isolate file. |
| 95 Eg: linux. | 114 Eg: linux. |
| 96 slave_num: int. The slave we want to create isolated.gen.json file for. | 115 slave_num: int. The slave we want to create isolated.gen.json file for. |
| 97 extra_variables: dict of str to str. The extra vars to pass to isolate. | 116 extra_variables: dict of str to str. The extra vars to pass to isolate. |
| 98 Eg: {'SLAVE_NUM': '1', 'MASTER': 'ChromiumPerfFYI'} | 117 Eg: {'SLAVE_NUM': '1', 'MASTER': 'ChromiumPerfFYI'} |
| 99 | 118 |
| 100 Returns: | 119 Returns: |
| 101 Path to the isolated.gen.json file. | 120 Path to the isolated.gen.json file. |
| 102 """ | 121 """ |
| 103 self.m.file.makedirs('Create swarming tmp dir', self.swarming_temp_dir) | 122 self.m.file.makedirs('swarming tmp dir', self.swarming_temp_dir) |
| 104 isolated_path = self.swarming_temp_dir.join( | 123 isolated_path = self.swarming_temp_dir.join( |
| 105 'ct-task-%s.isolated' % slave_num) | 124 'ct-task-%s.isolated' % slave_num) |
| 106 isolate_args = [ | 125 isolate_args = [ |
| 107 '--isolate', isolate_path, | 126 '--isolate', isolate_path, |
| 108 '--isolated', isolated_path, | 127 '--isolated', isolated_path, |
| 109 '--config-variable', 'OS', os_type, | 128 '--config-variable', 'OS', os_type, |
| 110 ] | 129 ] |
| 111 for k, v in extra_variables.iteritems(): | 130 for k, v in extra_variables.iteritems(): |
| 112 isolate_args.extend(['--extra-variable', k, v]) | 131 isolate_args.extend(['--extra-variable', k, v]) |
| 113 isolated_gen_dict = { | 132 isolated_gen_dict = { |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 self.m.swarming.trigger(swarming_tasks) | 176 self.m.swarming.trigger(swarming_tasks) |
| 158 return swarming_tasks | 177 return swarming_tasks |
| 159 | 178 |
| 160 def collect_swarming_tasks(self, swarming_tasks): | 179 def collect_swarming_tasks(self, swarming_tasks): |
| 161 """Collects all swarming tasks triggered by this recipe. | 180 """Collects all swarming tasks triggered by this recipe. |
| 162 | 181 |
| 163 Args: | 182 Args: |
| 164 swarming_tasks: list of swarming.SwarmingTask instances. | 183 swarming_tasks: list of swarming.SwarmingTask instances. |
| 165 """ | 184 """ |
| 166 return self.m.swarming.collect(swarming_tasks) | 185 return self.m.swarming.collect(swarming_tasks) |
| OLD | NEW |