OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright 2014 The LUCI Authors. All rights reserved. | 2 # Copyright 2014 The LUCI Authors. All rights reserved. |
3 # Use of this source code is governed under the Apache License, Version 2.0 | 3 # Use of this source code is governed under the Apache License, Version 2.0 |
4 # that can be found in the LICENSE file. | 4 # that can be found in the LICENSE file. |
5 | 5 |
6 import datetime | 6 import datetime |
7 import logging | 7 import logging |
8 import os | 8 import os |
9 import random | 9 import random |
10 import sys | 10 import sys |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 self.assertEqual('Deduped', task_result.state_to_string(f)) | 143 self.assertEqual('Deduped', task_result.state_to_string(f)) |
144 | 144 |
145 def test_new_result_summary(self): | 145 def test_new_result_summary(self): |
146 request = mkreq(_gen_request()) | 146 request = mkreq(_gen_request()) |
147 actual = task_result.new_result_summary(request) | 147 actual = task_result.new_result_summary(request) |
148 expected = { | 148 expected = { |
149 'abandoned_ts': None, | 149 'abandoned_ts': None, |
150 'bot_dimensions': None, | 150 'bot_dimensions': None, |
151 'bot_id': None, | 151 'bot_id': None, |
152 'bot_version': None, | 152 'bot_version': None, |
| 153 'cipd_pins': None, |
153 'children_task_ids': [], | 154 'children_task_ids': [], |
154 'completed_ts': None, | 155 'completed_ts': None, |
155 'costs_usd': [], | 156 'costs_usd': [], |
156 'cost_saved_usd': None, | 157 'cost_saved_usd': None, |
157 'created_ts': self.now, | 158 'created_ts': self.now, |
158 'deduped_from': None, | 159 'deduped_from': None, |
159 'duration': None, | 160 'duration': None, |
160 'exit_code': None, | 161 'exit_code': None, |
161 'failure': False, | 162 'failure': False, |
162 'id': '1d69b9f088008810', | 163 'id': '1d69b9f088008810', |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 request = mkreq(_gen_request()) | 196 request = mkreq(_gen_request()) |
196 actual = task_result.new_run_result( | 197 actual = task_result.new_run_result( |
197 request, 1, 'localhost', 'abc', | 198 request, 1, 'localhost', 'abc', |
198 {'id': ['localhost'], 'foo': ['bar', 'biz']}) | 199 {'id': ['localhost'], 'foo': ['bar', 'biz']}) |
199 expected = { | 200 expected = { |
200 'abandoned_ts': None, | 201 'abandoned_ts': None, |
201 'bot_dimensions': {'id': ['localhost'], 'foo': ['bar', 'biz']}, | 202 'bot_dimensions': {'id': ['localhost'], 'foo': ['bar', 'biz']}, |
202 'bot_id': 'localhost', | 203 'bot_id': 'localhost', |
203 'bot_version': 'abc', | 204 'bot_version': 'abc', |
204 'children_task_ids': [], | 205 'children_task_ids': [], |
| 206 'cipd_pins': None, |
205 'completed_ts': None, | 207 'completed_ts': None, |
206 'cost_usd': 0., | 208 'cost_usd': 0., |
207 'duration': None, | 209 'duration': None, |
208 'exit_code': None, | 210 'exit_code': None, |
209 'failure': False, | 211 'failure': False, |
210 'id': '1d69b9f088008811', | 212 'id': '1d69b9f088008811', |
211 'internal_failure': False, | 213 'internal_failure': False, |
212 'modified_ts': None, | 214 'modified_ts': None, |
213 'outputs_ref': None, | 215 'outputs_ref': None, |
214 'server_versions': ['v1a'], | 216 'server_versions': ['v1a'], |
(...skipping 12 matching lines...) Expand all Loading... |
227 request = mkreq(_gen_request()) | 229 request = mkreq(_gen_request()) |
228 result_summary = task_result.new_result_summary(request) | 230 result_summary = task_result.new_result_summary(request) |
229 to_run = task_to_run.new_task_to_run(request) | 231 to_run = task_to_run.new_task_to_run(request) |
230 result_summary.modified_ts = utils.utcnow() | 232 result_summary.modified_ts = utils.utcnow() |
231 ndb.transaction(lambda: ndb.put_multi([result_summary, to_run])) | 233 ndb.transaction(lambda: ndb.put_multi([result_summary, to_run])) |
232 expected = { | 234 expected = { |
233 'abandoned_ts': None, | 235 'abandoned_ts': None, |
234 'bot_dimensions': None, | 236 'bot_dimensions': None, |
235 'bot_id': None, | 237 'bot_id': None, |
236 'bot_version': None, | 238 'bot_version': None, |
| 239 'cipd_pins': None, |
237 'children_task_ids': [], | 240 'children_task_ids': [], |
238 'completed_ts': None, | 241 'completed_ts': None, |
239 'costs_usd': [], | 242 'costs_usd': [], |
240 'cost_saved_usd': None, | 243 'cost_saved_usd': None, |
241 'created_ts': self.now, | 244 'created_ts': self.now, |
242 'deduped_from': None, | 245 'deduped_from': None, |
243 'duration': None, | 246 'duration': None, |
244 'exit_code': None, | 247 'exit_code': None, |
245 'failure': False, | 248 'failure': False, |
246 'id': '1d69b9f088008810', | 249 'id': '1d69b9f088008810', |
(...skipping 27 matching lines...) Expand all Loading... |
274 to_run.put() | 277 to_run.put() |
275 run_result = task_result.new_run_result(request, 1, 'localhost', 'abc', {}) | 278 run_result = task_result.new_run_result(request, 1, 'localhost', 'abc', {}) |
276 run_result.modified_ts = utils.utcnow() | 279 run_result.modified_ts = utils.utcnow() |
277 result_summary.set_from_run_result(run_result, request) | 280 result_summary.set_from_run_result(run_result, request) |
278 ndb.transaction(lambda: ndb.put_multi((result_summary, run_result))) | 281 ndb.transaction(lambda: ndb.put_multi((result_summary, run_result))) |
279 expected = { | 282 expected = { |
280 'abandoned_ts': None, | 283 'abandoned_ts': None, |
281 'bot_dimensions': {}, | 284 'bot_dimensions': {}, |
282 'bot_id': u'localhost', | 285 'bot_id': u'localhost', |
283 'bot_version': u'abc', | 286 'bot_version': u'abc', |
| 287 'cipd_pins': None, |
284 'children_task_ids': [], | 288 'children_task_ids': [], |
285 'completed_ts': None, | 289 'completed_ts': None, |
286 'costs_usd': [0.], | 290 'costs_usd': [0.], |
287 'cost_saved_usd': None, | 291 'cost_saved_usd': None, |
288 'created_ts': self.now, | 292 'created_ts': self.now, |
289 'deduped_from': None, | 293 'deduped_from': None, |
290 'duration': None, | 294 'duration': None, |
291 'exit_code': None, | 295 'exit_code': None, |
292 'failure': False, | 296 'failure': False, |
293 'id': '1d69b9f088008810', | 297 'id': '1d69b9f088008810', |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
328 isolated_upload=task_result.OperationStats( | 332 isolated_upload=task_result.OperationStats( |
329 duration=0.01, items_cold='foo')).put() | 333 duration=0.01, items_cold='foo')).put() |
330 ndb.transaction(lambda: ndb.put_multi(run_result.append_output('foo', 0))) | 334 ndb.transaction(lambda: ndb.put_multi(run_result.append_output('foo', 0))) |
331 result_summary.set_from_run_result(run_result, request) | 335 result_summary.set_from_run_result(run_result, request) |
332 ndb.transaction(lambda: ndb.put_multi((result_summary, run_result))) | 336 ndb.transaction(lambda: ndb.put_multi((result_summary, run_result))) |
333 expected = { | 337 expected = { |
334 'abandoned_ts': None, | 338 'abandoned_ts': None, |
335 'bot_dimensions': {}, | 339 'bot_dimensions': {}, |
336 'bot_id': u'localhost', | 340 'bot_id': u'localhost', |
337 'bot_version': u'abc', | 341 'bot_version': u'abc', |
| 342 'cipd_pins': None, |
338 'children_task_ids': [], | 343 'children_task_ids': [], |
339 'completed_ts': complete_ts, | 344 'completed_ts': complete_ts, |
340 'costs_usd': [0.], | 345 'costs_usd': [0.], |
341 'cost_saved_usd': None, | 346 'cost_saved_usd': None, |
342 'created_ts': self.now, | 347 'created_ts': self.now, |
343 'deduped_from': None, | 348 'deduped_from': None, |
344 'duration': 0.1, | 349 'duration': 0.1, |
345 'exit_code': 0, | 350 'exit_code': 0, |
346 'failure': False, | 351 'failure': False, |
347 'id': '1d69b9f088008810', | 352 'id': '1d69b9f088008810', |
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
691 task_result.TaskOutput.CHUNK_SIZE * '\x00' + 'Baz\x00Bar\x00FooWow', | 696 task_result.TaskOutput.CHUNK_SIZE * '\x00' + 'Baz\x00Bar\x00FooWow', |
692 self.run_result.get_output()) | 697 self.run_result.get_output()) |
693 self.assertTaskOutputChunk( | 698 self.assertTaskOutputChunk( |
694 [{'chunk': 'Baz\x00Bar\x00FooWow', 'gaps': [3, 4, 7, 8]}]) | 699 [{'chunk': 'Baz\x00Bar\x00FooWow', 'gaps': [3, 4, 7, 8]}]) |
695 | 700 |
696 | 701 |
697 if __name__ == '__main__': | 702 if __name__ == '__main__': |
698 if '-v' in sys.argv: | 703 if '-v' in sys.argv: |
699 unittest.TestCase.maxDiff = None | 704 unittest.TestCase.maxDiff = None |
700 unittest.main() | 705 unittest.main() |
OLD | NEW |