Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 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 """Set of utilities to add commands to a buildbot factory. | 5 """Set of utilities to add commands to a buildbot factory. |
| 6 | 6 |
| 7 This is based on commands.py and adds swarm-specific commands.""" | 7 This is based on commands.py and adds swarm-specific commands.""" |
| 8 | 8 |
| 9 from buildbot.process.properties import WithProperties | 9 from buildbot.process.properties import WithProperties |
| 10 from buildbot.steps import shell, source | 10 from buildbot.steps import shell, source |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 82 'swarm_hashes' is already related to GetSwarmTests(). | 82 'swarm_hashes' is already related to GetSwarmTests(). |
| 83 """ | 83 """ |
| 84 # Only used for pass gtest filters specified by the user via 'testfilter'. | 84 # Only used for pass gtest filters specified by the user via 'testfilter'. |
| 85 swarm_tests = commands.GetSwarmTests(self) | 85 swarm_tests = commands.GetSwarmTests(self) |
| 86 # The 'swarm_hashes' build property has been set by the | 86 # The 'swarm_hashes' build property has been set by the |
| 87 # CalculateIsolatedSha1s build step. It will have all the steps that can be | 87 # CalculateIsolatedSha1s build step. It will have all the steps that can be |
| 88 # triggered. This implicitly takes account 'testfilter'. | 88 # triggered. This implicitly takes account 'testfilter'. |
| 89 swarm_tests_hash_mapping = commands.GetProp(self, 'swarm_hashes', {}) | 89 swarm_tests_hash_mapping = commands.GetProp(self, 'swarm_hashes', {}) |
| 90 | 90 |
| 91 command = self.command[:] | 91 command = self.command[:] |
| 92 requester = commands.GetProp(self, 'requester', None) | |
| 93 # 'ci' means Continuous Integration and it's jobs that are meant to test | |
| 94 # code that has just been committed but yet tested. That's what most people | |
| 95 # call 'the waterfall' or the 'main master'. | |
| 96 tasktype = 'ci' | |
| 97 if requester == 'commit-bot@chromium.org': | |
| 98 tasktype = 'cq' | |
| 99 elif requester or commands.GetProp(self, 'testfilter', None): | |
| 100 tasktype = 'tryjob' | |
| 101 # TODO(maruel): Determine difference between CI and FYI masters. | |
| 102 command.extend(('--type', tasktype)) | |
| 103 | |
| 92 for swarm_test in self.tests: | 104 for swarm_test in self.tests: |
| 93 if swarm_tests_hash_mapping.get(swarm_test.test_name): | 105 if swarm_tests_hash_mapping.get(swarm_test.test_name): |
| 94 command.extend( | 106 command.extend( |
| 95 [ | 107 [ |
| 96 '--run_from_hash', | 108 '--run_from_hash', |
| 97 swarm_tests_hash_mapping[swarm_test.test_name], | 109 swarm_tests_hash_mapping[swarm_test.test_name], |
| 98 swarm_test.test_name, | 110 swarm_test.test_name, |
| 99 '%d' % swarm_test.shards, | 111 '%d' % swarm_test.shards, |
| 100 # '*' is a special value to mean no filter. This is used so '' is | 112 # '*' is a special value to mean no filter. This is used so '' is |
| 101 # not used, as '' may be misinterpreted by the shell, especially | 113 # not used, as '' may be misinterpreted by the shell, especially |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 112 | 124 |
| 113 class SwarmCommands(commands.FactoryCommands): | 125 class SwarmCommands(commands.FactoryCommands): |
| 114 """Encapsulates methods to add swarm commands to a buildbot factory""" | 126 """Encapsulates methods to add swarm commands to a buildbot factory""" |
| 115 def __init__(self, *args, **kwargs): | 127 def __init__(self, *args, **kwargs): |
| 116 super(SwarmCommands, self).__init__(*args, **kwargs) | 128 super(SwarmCommands, self).__init__(*args, **kwargs) |
| 117 self._swarming_client_dir = self.PathJoin('src', 'tools', 'swarming_client') | 129 self._swarming_client_dir = self.PathJoin('src', 'tools', 'swarming_client') |
| 118 | 130 |
| 119 def AddTriggerSwarmTestStep(self, swarm_server, isolation_outdir, tests, | 131 def AddTriggerSwarmTestStep(self, swarm_server, isolation_outdir, tests, |
| 120 doStepIf): | 132 doStepIf): |
| 121 assert all(t.__class__.__name__ == 'SwarmTest' for t in tests) | 133 assert all(t.__class__.__name__ == 'SwarmTest' for t in tests) |
| 122 script_path = self.PathJoin( | 134 swarm_request_name_prefix = WithProperties( |
|
Isaac (away)
2013/08/20 22:22:33
While this is OK, the preferred style is probably
| |
| 123 self._swarming_client_dir, 'swarm_trigger_step.py') | 135 '%s-%s-', 'buildername:-None', 'buildnumber:-None') |
| 124 | |
| 125 swarm_request_name_prefix = WithProperties('%s-%s-', | |
| 126 'buildername:-None', | |
| 127 'buildnumber:-None') | |
| 128 | 136 |
| 129 command = [ | 137 command = [ |
| 130 self._python, | 138 self._python, |
| 131 script_path, | 139 self.PathJoin(self._script_dir, 'trigger_swarm.py'), |
| 132 '-o', WithProperties('%s', 'target_os:-%s' % self._target_platform), | 140 '--os', WithProperties('%s', 'target_os:-%s' % self._target_platform), |
| 133 '-u', swarm_server, | 141 '--swarming', swarm_server, |
| 134 '-t', swarm_request_name_prefix, | 142 '--task-prefix', swarm_request_name_prefix, |
| 135 '-d', isolation_outdir, | 143 '--isolate-server', isolation_outdir, |
| 136 ] | 144 ] |
| 137 assert all(i for i in command), command | 145 assert all(i for i in command), command |
| 138 self._factory.addStep( | 146 self._factory.addStep( |
| 139 SwarmShellForTriggeringTests, | 147 SwarmShellForTriggeringTests, |
| 140 name='swarm_trigger_tests', | 148 name='swarm_trigger_tests', |
| 141 description='Trigger swarm steps', | 149 description='Trigger swarm steps', |
| 142 command=command, | 150 command=command, |
| 143 tests=tests, | 151 tests=tests, |
| 144 doStepIf=doStepIf) | 152 doStepIf=doStepIf) |
| 145 | 153 |
| 146 def AddGetSwarmTestStep(self, swarm_server, test_name, num_shards): | 154 def AddGetSwarmTestStep(self, swarm_server, test_name, num_shards): |
| 147 """Adds the step to retrieve the Swarm job results asynchronously.""" | 155 """Adds the step to retrieve the Swarm job results asynchronously.""" |
| 148 # TODO(maruel): assert test_name.endswith('_swarm') once swarm retrieve | 156 # TODO(maruel): assert test_name.endswith('_swarm') once swarm retrieve |
| 149 # results steps have _swarm suffix. | 157 # results steps have _swarm suffix. |
| 150 script_path = self.PathJoin(self._script_dir, 'get_swarm_results.py') | 158 script_path = self.PathJoin(self._script_dir, 'get_swarm_results.py') |
| 151 | 159 |
| 152 swarm_request_name = WithProperties('%s-%s-' + test_name, | 160 swarm_request_name = WithProperties('%s-%s-' + test_name, |
| 153 'buildername:-None', | 161 'buildername:-None', |
| 154 'buildnumber:-None') | 162 'buildnumber:-None') |
| 155 | 163 |
| 156 args = ['-u', swarm_server, '-s', '%d' % num_shards, swarm_request_name] | 164 args = [ |
| 165 '--swarming', swarm_server, | |
| 166 '--shards', '%d' % num_shards, | |
| 167 swarm_request_name, | |
| 168 ] | |
| 157 wrapper_args = [ | 169 wrapper_args = [ |
| 158 '--no-xvfb', '--annotate=gtest', '--test-type=%s' % test_name, | 170 '--no-xvfb', '--annotate=gtest', '--test-type=%s' % test_name, |
| 159 ] | 171 ] |
| 160 | 172 |
| 161 command = self.GetPythonTestCommand(script_path, arg_list=args, | 173 command = self.GetPythonTestCommand(script_path, arg_list=args, |
| 162 wrapper_args=wrapper_args) | 174 wrapper_args=wrapper_args) |
| 163 | 175 |
| 164 # Swarm handles the timeouts due to no ouput being produced for 10 minutes, | 176 # Swarm handles the timeouts due to no ouput being produced for 10 minutes, |
| 165 # but we don't have access to the output until the whole test is done, which | 177 # but we don't have access to the output until the whole test is done, which |
| 166 # may take more than 10 minutes, so we increase the buildbot timeout. | 178 # may take more than 10 minutes, so we increase the buildbot timeout. |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 224 | 236 |
| 225 command = [self._python, script_path, '--drive', drive, | 237 command = [self._python, script_path, '--drive', drive, |
| 226 '--network_path', network_path] | 238 '--network_path', network_path] |
| 227 | 239 |
| 228 self._factory.addStep( | 240 self._factory.addStep( |
| 229 shell.ShellCommand, | 241 shell.ShellCommand, |
| 230 name='setup_windows_network_storage', | 242 name='setup_windows_network_storage', |
| 231 description='setup_windows_network_storage', | 243 description='setup_windows_network_storage', |
| 232 descriptionDone='setup_windows_network_storage', | 244 descriptionDone='setup_windows_network_storage', |
| 233 command=command) | 245 command=command) |
| OLD | NEW |