OLD | NEW |
---|---|
1 # Copyright 2016 The Chromium Authors. All rights reserved. | 1 # Copyright 2016 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 """Quest and Execution for running a test in Swarming. | 5 """Quest and Execution for running a test in Swarming. |
6 | 6 |
7 This is the only Quest/Execution where the Execution has a reference back to | 7 This is the only Quest/Execution where the Execution has a reference back to |
8 modify the Quest. | 8 modify the Quest. |
9 """ | 9 """ |
10 | 10 |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
90 self._isolate_hash = isolate_hash | 90 self._isolate_hash = isolate_hash |
91 self._first_execution = first_execution | 91 self._first_execution = first_execution |
92 | 92 |
93 self._task_id = None | 93 self._task_id = None |
94 self._bot_id = None | 94 self._bot_id = None |
95 | 95 |
96 @property | 96 @property |
97 def bot_id(self): | 97 def bot_id(self): |
98 return self._bot_id | 98 return self._bot_id |
99 | 99 |
100 def _AsDict(self): | |
101 return { | |
102 'bot_id': self._bot_id or '', | |
perezju
2017/08/22 09:49:48
nit: ditto
| |
103 'task_id': self._task_id, | |
104 'input_isolate_hash': self._isolate_hash, | |
105 } | |
106 | |
100 def _Poll(self): | 107 def _Poll(self): |
101 if not self._task_id: | 108 if not self._task_id: |
102 self._StartTask() | 109 self._StartTask() |
103 return | 110 return |
104 | 111 |
105 result = swarming_service.Task(self._task_id).Result() | 112 result = swarming_service.Task(self._task_id).Result() |
106 | 113 |
107 if 'bot_id' in result: | 114 if 'bot_id' in result: |
108 # Set bot_id to pass the info back to the Quest. | 115 # Set bot_id to pass the info back to the Quest. |
109 self._bot_id = result['bot_id'] | 116 self._bot_id = result['bot_id'] |
110 | 117 |
111 if result['state'] == 'PENDING' or result['state'] == 'RUNNING': | 118 if result['state'] == 'PENDING' or result['state'] == 'RUNNING': |
112 return | 119 return |
113 | 120 |
114 if result['state'] != 'COMPLETED': | 121 if result['state'] != 'COMPLETED': |
115 raise SwarmingTaskError(self._task_id, result['state']) | 122 raise SwarmingTaskError(self._task_id, result['state']) |
116 | 123 |
117 if result['failure']: | 124 if result['failure']: |
118 raise SwarmingTestError(self._task_id, result['exit_code']) | 125 raise SwarmingTestError(self._task_id, result['exit_code']) |
119 | 126 |
120 result_arguments = {'isolate_hash': result['outputs_ref']['isolated']} | 127 self._Complete( |
121 self._Complete(result_arguments=result_arguments) | 128 result_arguments={'isolate_hash': result['outputs_ref']['isolated']}) |
122 | 129 |
123 | 130 |
124 def _StartTask(self): | 131 def _StartTask(self): |
125 """Kick off a Swarming task to run a test.""" | 132 """Kick off a Swarming task to run a test.""" |
126 if self._first_execution and not self._first_execution._bot_id: | 133 if self._first_execution and not self._first_execution._bot_id: |
127 if self._first_execution.failed: | 134 if self._first_execution.failed: |
128 # If the first Execution fails before it gets a bot ID, it's likely it | 135 # If the first Execution fails before it gets a bot ID, it's likely it |
129 # couldn't find any device to run on. Subsequent Executions probably | 136 # couldn't find any device to run on. Subsequent Executions probably |
130 # wouldn't have any better luck, and failing fast is less complex than | 137 # wouldn't have any better luck, and failing fast is less complex than |
131 # handling retries. | 138 # handling retries. |
(...skipping 16 matching lines...) Expand all Loading... | |
148 'inputs_ref': {'isolated': self._isolate_hash}, | 155 'inputs_ref': {'isolated': self._isolate_hash}, |
149 'extra_args': self._extra_args, | 156 'extra_args': self._extra_args, |
150 'dimensions': dimensions, | 157 'dimensions': dimensions, |
151 'execution_timeout_secs': '3600', | 158 'execution_timeout_secs': '3600', |
152 'io_timeout_secs': '3600', | 159 'io_timeout_secs': '3600', |
153 }, | 160 }, |
154 } | 161 } |
155 response = swarming_service.Tasks().New(body) | 162 response = swarming_service.Tasks().New(body) |
156 | 163 |
157 self._task_id = response['task_id'] | 164 self._task_id = response['task_id'] |
OLD | NEW |